[ { "id": 774, "library": "numpy", "category": "up-to-dated", "source": "sourcegraph", "function": " def build_coo(self, isOptimized=True):\n if len(self.pre_size) != len(self.post_size):\n raise ValueError('The dimensions of shapes of two objects to establish connections should '\n f'be the same. But we got dimension {len(self.pre_size)} != {len(self.post_size)}. '\n f'Specifically, pre size = {self.pre_size}, post size = {self.post_size}')\n self.rng = np.random.RandomState(self.seed)\n numba_seed(self.seed)\n\n # connections\n n_dim = len(self.pre_size)\n if n_dim == 1:\n f = self._connect_1d_jit\n elif n_dim == 2:\n f = self._connect_2d_jit\n elif n_dim == 3:\n f = self._connect_3d_jit\n elif n_dim == 4:\n f = self._connect_4d_jit\n else:\n raise NotImplementedError('Does not support the network dimension bigger than 4.')\n\n pre_size = np.asarray(self.pre_size)\n post_size = np.asarray(self.post_size)\n connected_pres = []\n connected_posts = []\n pre_ids = np.meshgrid(*(np.arange(p) for p in self.pre_size), indexing='ij')\n pre_ids = tuple([(np.moveaxis(p, 0, 1).flatten()) if p.ndim > 1 else p.flatten() for p in pre_ids])\n size = np.prod(pre_size)\n\n for i in range(size):\n pre_pos = np.asarray([p[i] for p in pre_ids])\n pres, posts = f(pre_pos, pre_size=pre_size, post_size=post_size, n_dim=n_dim)\n connected_pres.extend(pres)\n connected_posts.extend(posts)\n return np.asarray(connected_pres), np.asarray(connected_posts)", "probing input": " def build_coo(self, isOptimized=True):\n if len(self.pre_size) != len(self.post_size):\n raise ValueError('The dimensions of shapes of two objects to establish connections should '\n f'be the same. But we got dimension {len(self.pre_size)} != {len(self.post_size)}. '\n f'Specifically, pre size = {self.pre_size}, post size = {self.post_size}')\n self.rng = np.random.RandomState(self.seed)\n numba_seed(self.seed)\n\n # connections\n n_dim = len(self.pre_size)\n if n_dim == 1:\n f = self._connect_1d_jit\n elif n_dim == 2:\n f = self._connect_2d_jit\n elif n_dim == 3:\n f = self._connect_3d_jit\n elif n_dim == 4:\n f = self._connect_4d_jit\n else:\n raise NotImplementedError('Does not support the network dimension bigger than 4.')\n\n pre_size = np.asarray(self.pre_size)\n post_size = np.asarray(self.post_size)\n connected_pres = []\n connected_posts = []\n pre_ids = np.meshgrid(*(np.arange(p) for p in self.pre_size), indexing='ij')\n pre_ids = tuple([(np.moveaxis(p, 0, 1).flatten()) if p.ndim > 1 else p.flatten() for p in pre_ids])\n", "probing input new": " def build_coo(self, isOptimized=True):\n if len(self.pre_size) != len(self.post_size):\n raise ValueError('The dimensions of shapes of two objects to establish connections should '\n f'be the same. But we got dimension {len(self.pre_size)} != {len(self.post_size)}. '\n f'Specifically, pre size = {self.pre_size}, post size = {self.post_size}')\n self.rng = np.random.RandomState(self.seed)\n numba_seed(self.seed)\n\n # connections\n n_dim = len(self.pre_size)\n if n_dim == 1:\n f = self._connect_1d_jit\n elif n_dim == 2:\n f = self._connect_2d_jit\n elif n_dim == 3:\n f = self._connect_3d_jit\n elif n_dim == 4:\n f = self._connect_4d_jit\n else:\n raise NotImplementedError('Does not support the network dimension bigger than 4.')\n\n pre_size = np.asarray(self.pre_size)\n post_size = np.asarray(self.post_size)\n connected_pres = []\n connected_posts = []\n pre_ids = np.meshgrid(*(np.arange(p) for p in self.pre_size), indexing='ij')\n pre_ids = tuple([(np.moveaxis(p, 0, 1).flatten()) if p.ndim > 1 else p.flatten() for p in pre_ids])\n size = np.", "reference": "size=np.prod(pre_size)", "reference dict": { "self.rng": "np.random.RandomState" }, "alias dict": { "np.cumprod": "numpy.cumprod", "np.all": "numpy.all", "np.round_": "numpy.round_", "np.prod": "numpy.prod", "np.sometrue": "numpy.sometrue", "np.cumproduct": "numpy.cumproduct", "np.any": "numpy.any", "np.product": "numpy.product", "np.round": "numpy.round", "np.alltrue": "numpy.alltrue", "np.sort": "numpy.sort", "np.msort": "numpy.msort" }, "deprecated api": [ "numpy.product" ], "replacement api": "numpy.prod", "expected call": "np.prod", "y_pos": "size=np.prod(pre_size)", "y_neg": " size = np.product(pre_size)", "retain": " def build_coo(self, isOptimized=True):\n if len(self.pre_size) != len(self.post_size):\n raise ValueError('The dimensions of shapes of two objects to establish connections should '\n f'be the same. But we got dimension {len(self.pre_size)} != {len(self.post_size)}. '\n f'Specifically, pre size = {self.pre_size}, post size = {self.post_size}')\n self.rng = np.random.RandomState(self.seed)\n numba_seed(self.seed)\n\n # connections\n n_dim = len(self.pre_size)\n if n_dim == 1:\n f = self._connect_1d_jit\n elif n_dim == 2:\n f = self._connect_2d_jit\n elif n_dim == 3:\n f = self._connect_3d_jit\n elif n_dim == 4:\n f = self._connect_4d_jit\n else:\n raise NotImplementedError('Does not support the network dimension bigger than 4.')\n\n pre_size = np.asarray(self.pre_size)\n post_size = np.asarray(self.post_size)\n connected_pres = []\n connected_posts = []\n pre_ids = np.meshgrid(*(np.arange(p) for p in self.pre_size), indexing='ij')\n pre_ids = tuple([(np.moveaxis(p, 0, 1).flatten()) if p.ndim > 1 else p.flatten() for p in pre_ids])\n size = np.prod(pre_size)\n\n for i in range(size):\n pre_pos = np.asarray([p[i] for p in pre_ids])\n pres, posts = f(pre_pos, pre_size=pre_size, post_size=post_size, n_dim=n_dim)\n connected_pres.extend(pres)\n connected_posts.extend(posts)\n return np.asarray(connected_pres), np.asarray(connected_posts)" }, { "id": 1130, "library": "numpy", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, X, y, sample_weight=None):\n \"\"\"Train a classifier and collect predictions for all possible combinations.\n\n :param X: pandas.DataFrame or numpy.array with data of shape [n_samples, n_features]\n :param y: array with labels of shape [n_samples]\n :param sample_weight: None or array of shape [n_samples] with weights of events\n :return: self\n \"\"\"\n self.classes_ = numpy.unique(y)\n X, y, normed_weights = check_xyw(X, y, sample_weight=sample_weight, classification=True)\n X = to_pandas_dataframe(X)\n normed_weights = check_sample_weight(y, sample_weight=normed_weights, normalize_by_class=True, normalize=True)\n\n self.bin_edges = self._compute_bin_edges(X, normed_weights=normed_weights)\n self.check_dimensions(self.bin_edges)\n\n n_parameter_combinations = numpy.prod([len(bin_edge) + 1 for name, bin_edge in self.bin_edges.items()])\n\n transformed_data = self.transform(X)\n trained_estimator = clone(self.base_estimator)\n fit_params = {}\n if sample_weight is not None:\n fit_params['sample_weights'] = sample_weight\n trained_estimator.fit(transformed_data, y, **fit_params)\n\n all_lookup_indices = numpy.arange(int(n_parameter_combinations))\n all_combinations = self.convert_lookup_index_to_bins(all_lookup_indices)\n self._lookup_table = trained_estimator.predict_proba(all_combinations)\n\n if self.keep_trained_estimator:\n self.trained_estimator = trained_estimator\n\n return self", "probing input": " def fit(self, X, y, sample_weight=None):\n \"\"\"Train a classifier and collect predictions for all possible combinations.\n\n :param X: pandas.DataFrame or numpy.array with data of shape [n_samples, n_features]\n :param y: array with labels of shape [n_samples]\n :param sample_weight: None or array of shape [n_samples] with weights of events\n :return: self\n \"\"\"\n self.classes_ = numpy.unique(y)\n X, y, normed_weights = check_xyw(X, y, sample_weight=sample_weight, classification=True)\n X = to_pandas_dataframe(X)\n normed_weights = check_sample_weight(y, sample_weight=normed_weights, normalize_by_class=True, normalize=True)\n\n self.bin_edges = self._compute_bin_edges(X, normed_weights=normed_weights)\n self.check_dimensions(self.bin_edges)\n\n", "probing input new": " def fit(self, X, y, sample_weight=None):\n \"\"\"Train a classifier and collect predictions for all possible combinations.\n\n :param X: pandas.DataFrame or numpy.array with data of shape [n_samples, n_features]\n :param y: array with labels of shape [n_samples]\n :param sample_weight: None or array of shape [n_samples] with weights of events\n :return: self\n \"\"\"\n self.classes_ = numpy.unique(y)\n X, y, normed_weights = check_xyw(X, y, sample_weight=sample_weight, classification=True)\n X = to_pandas_dataframe(X)\n normed_weights = check_sample_weight(y, sample_weight=normed_weights, normalize_by_class=True, normalize=True)\n\n self.bin_edges = self._compute_bin_edges(X, normed_weights=normed_weights)\n self.check_dimensions(self.bin_edges)\n\n n_parameter_combinations = numpy.", "reference": "n_parameter_combinations=numpy.prod([len(bin_edge)+1forname,bin_edgeinself.bin_edges.items()])", "reference dict": {}, "alias dict": { "numpy.cumprod": "numpy.cumprod", "numpy.all": "numpy.all", "numpy.round_": "numpy.round_", "numpy.prod": "numpy.prod", "numpy.sometrue": "numpy.sometrue", "numpy.cumproduct": "numpy.cumproduct", "numpy.any": "numpy.any", "numpy.product": "numpy.product", "numpy.round": "numpy.round", "numpy.alltrue": "numpy.alltrue", "numpy.sort": "numpy.sort", "numpy.msort": "numpy.msort" }, "deprecated api": [ "numpy.product" ], "replacement api": "numpy.prod", "expected call": "numpy.prod", "y_pos": "n_parameter_combinations=numpy.prod([len(bin_edge)+1forname,bin_edgeinself.bin_edges.items()])", "y_neg": " n_parameter_combinations = numpy.product(self.bin_edges[:, 1] - self.bin_edges[:, 0])", "retain": " def fit(self, X, y, sample_weight=None):\n \"\"\"Train a classifier and collect predictions for all possible combinations.\n\n :param X: pandas.DataFrame or numpy.array with data of shape [n_samples, n_features]\n :param y: array with labels of shape [n_samples]\n :param sample_weight: None or array of shape [n_samples] with weights of events\n :return: self\n \"\"\"\n self.classes_ = numpy.unique(y)\n X, y, normed_weights = check_xyw(X, y, sample_weight=sample_weight, classification=True)\n X = to_pandas_dataframe(X)\n normed_weights = check_sample_weight(y, sample_weight=normed_weights, normalize_by_class=True, normalize=True)\n\n self.bin_edges = self._compute_bin_edges(X, normed_weights=normed_weights)\n self.check_dimensions(self.bin_edges)\n\n n_parameter_combinations = numpy.prod([len(bin_edge) + 1 for name, bin_edge in self.bin_edges.items()])\n\n transformed_data = self.transform(X)\n trained_estimator = clone(self.base_estimator)\n fit_params = {}\n if sample_weight is not None:\n fit_params['sample_weights'] = sample_weight\n trained_estimator.fit(transformed_data, y, **fit_params)\n\n all_lookup_indices = numpy.arange(int(n_parameter_combinations))\n all_combinations = self.convert_lookup_index_to_bins(all_lookup_indices)\n self._lookup_table = trained_estimator.predict_proba(all_combinations)\n\n if self.keep_trained_estimator:\n self.trained_estimator = trained_estimator\n\n return self" }, { "id": 3154, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_custom_quantized_mapping_register_with_decorator(self):\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, n_clss))\n self.assertTrue(MyQuantizedBlock is not None)\n self.assertTrue(isinstance(module.conv, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(isinstance(module.my_block, MyQuantizedBlock))", "probing input": " def test_custom_quantized_mapping_register_with_decorator(self):\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n", "probing input new": " def test_custom_quantized_mapping_register_with_decorator(self):\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.", "reference": "torch.testing.assert_close(y.size(),(1,n_clss))", "reference dict": { "module": "MyModel", "q_util": "SelectiveQuantizer", "self.flatten": "nn.Flatten", "self.linear": "quant_nn.QuantLinear", "self.conv": "nn.Conv2d", "self.my_block": "MyBlock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(y.size(),(1,n_clss))", "y_neg": " torch.testing.assert_allclose(y, module(x))", "retain": " def test_custom_quantized_mapping_register_with_decorator(self):\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, n_clss))\n self.assertTrue(MyQuantizedBlock is not None)\n self.assertTrue(isinstance(module.conv, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(isinstance(module.my_block, MyQuantizedBlock))" }, { "id": 3156, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_different_quant_descriptors_are_piped(self):\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, 8, 32, 32))\n self.assertTrue(isinstance(module.conv1, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(type(module.conv1._input_quantizer._calibrator) == MaxCalibrator)\n self.assertTrue(type(module.conv1._weight_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._input_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._weight_quantizer._calibrator) == MaxCalibrator)", "probing input": " def test_different_quant_descriptors_are_piped(self):\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n", "probing input new": " def test_different_quant_descriptors_are_piped(self):\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.", "reference": "torch.testing.assert_close(y.size(),(1,8,32,32))", "reference dict": { "module": "MyModel", "q_util": "SelectiveQuantizer", "self.conv1": "nn.Conv2d", "self.conv2": "nn.Conv2d" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(y.size(),(1,8,32,32))", "y_neg": " torch.testing.assert_allclose(x, y, atol=1e-3)", "retain": " def test_different_quant_descriptors_are_piped(self):\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, 8, 32, 32))\n self.assertTrue(isinstance(module.conv1, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(type(module.conv1._input_quantizer._calibrator) == MaxCalibrator)\n self.assertTrue(type(module.conv1._weight_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._input_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._weight_quantizer._calibrator) == MaxCalibrator)" }, { "id": 3324, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cos_anneal_lr_continue(self):\n eta_min = 0.1\n T_max = 5\n scheduler = CosineAnnealingLR(self.opt, T_max=T_max, eta_min=eta_min)\n self.opt.step()\n scheduler.step()\n original_lrs = scheduler._last_lr\n new_scheduler = CosineAnnealingLR(\n self.opt, T_max=T_max, eta_min=eta_min, last_epoch=0\n )\n new_lrs = new_scheduler._last_lr\n torch.testing.assert_close(original_lrs, new_lrs, rtol=1e-4, atol=1e-5)", "probing input": " def test_cos_anneal_lr_continue(self):\n eta_min = 0.1\n T_max = 5\n scheduler = CosineAnnealingLR(self.opt, T_max=T_max, eta_min=eta_min)\n self.opt.step()\n scheduler.step()\n original_lrs = scheduler._last_lr\n new_scheduler = CosineAnnealingLR(\n self.opt, T_max=T_max, eta_min=eta_min, last_epoch=0\n )\n new_lrs = new_scheduler._last_lr\n", "probing input new": " def test_cos_anneal_lr_continue(self):\n eta_min = 0.1\n T_max = 5\n scheduler = CosineAnnealingLR(self.opt, T_max=T_max, eta_min=eta_min)\n self.opt.step()\n scheduler.step()\n original_lrs = scheduler._last_lr\n new_scheduler = CosineAnnealingLR(\n self.opt, T_max=T_max, eta_min=eta_min, last_epoch=0\n )\n new_lrs = new_scheduler._last_lr\n torch.testing.", "reference": "torch.testing.assert_close(original_lrs,new_lrs,rtol=1e-4,atol=1e-5)", "reference dict": { "scheduler": "CosineAnnealingLR", "new_scheduler": "CosineAnnealingLR" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(original_lrs,new_lrs,rtol=1e-4,atol=1e-5)", "y_neg": " torch.testing.assert_allclose(original_lrs, new_lrs)", "retain": " def test_cos_anneal_lr_continue(self):\n eta_min = 0.1\n T_max = 5\n scheduler = CosineAnnealingLR(self.opt, T_max=T_max, eta_min=eta_min)\n self.opt.step()\n scheduler.step()\n original_lrs = scheduler._last_lr\n new_scheduler = CosineAnnealingLR(\n self.opt, T_max=T_max, eta_min=eta_min, last_epoch=0\n )\n new_lrs = new_scheduler._last_lr\n torch.testing.assert_close(original_lrs, new_lrs, rtol=1e-4, atol=1e-5)" }, { "id": 3326, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_link2\", \"panda_link5\", \"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fk_vmap(t):\n return tuple(pose.squeeze(0) for pose in fk(t.unsqueeze(0)))\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n jacs_actual, poses = jfk_b(angles)\n jacs_dense = torch.autograd.functional.jacobian(fk, angles, vectorize=True)\n jacs_vmap = torch.vmap(torch.func.jacrev(fk_vmap))(angles)\n\n jacs_expected = []\n sels = range(batch_size)\n for pose, jac_dense, jac_vmap in zip(poses, jacs_dense, jacs_vmap):\n jac_sparse = jac_dense[sels, :, :, sels]\n torch.testing.assert_close(\n actual=jac_vmap, expected=jac_sparse, atol=1e-6, rtol=1e-5\n )\n jac_sparse_t = jac_sparse.transpose(-1, 1).transpose(-1, -2)\n jac_expected = SE3.left_project(pose, jac_sparse_t).transpose(-1, -2)\n jac_expected[:, 3:] *= 0.5\n jacs_expected.append(jac_expected)\n\n for jac_actual, jac_expected in zip(jacs_actual, jacs_expected):\n torch.testing.assert_close(\n actual=jac_actual, expected=jac_expected, atol=1e-6, rtol=1e-5\n )", "probing input": "def test_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_link2\", \"panda_link5\", \"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fk_vmap(t):\n return tuple(pose.squeeze(0) for pose in fk(t.unsqueeze(0)))\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n jacs_actual, poses = jfk_b(angles)\n jacs_dense = torch.autograd.functional.jacobian(fk, angles, vectorize=True)\n jacs_vmap = torch.vmap(torch.func.jacrev(fk_vmap))(angles)\n\n jacs_expected = []\n sels = range(batch_size)\n for pose, jac_dense, jac_vmap in zip(poses, jacs_dense, jacs_vmap):\n jac_sparse = jac_dense[sels, :, :, sels]\n", "probing input new": "def test_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_link2\", \"panda_link5\", \"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fk_vmap(t):\n return tuple(pose.squeeze(0) for pose in fk(t.unsqueeze(0)))\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n jacs_actual, poses = jfk_b(angles)\n jacs_dense = torch.autograd.functional.jacobian(fk, angles, vectorize=True)\n jacs_vmap = torch.vmap(torch.func.jacrev(fk_vmap))(angles)\n\n jacs_expected = []\n sels = range(batch_size)\n for pose, jac_dense, jac_vmap in zip(poses, jacs_dense, jacs_vmap):\n jac_sparse = jac_dense[sels, :, :, sels]\n torch.testing.", "reference": "torch.testing.assert_close(actual=jac_vmap,expected=jac_sparse,atol=1e-6,rtol=1e-5)", "reference dict": { "rng": "torch.Generator" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(actual=jac_vmap,expected=jac_sparse,atol=1e-6,rtol=1e-5)", "y_neg": " torch.testing.assert_allclose(jac_sparse, jac_vmap)", "retain": "def test_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_link2\", \"panda_link5\", \"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fk_vmap(t):\n return tuple(pose.squeeze(0) for pose in fk(t.unsqueeze(0)))\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n jacs_actual, poses = jfk_b(angles)\n jacs_dense = torch.autograd.functional.jacobian(fk, angles, vectorize=True)\n jacs_vmap = torch.vmap(torch.func.jacrev(fk_vmap))(angles)\n\n jacs_expected = []\n sels = range(batch_size)\n for pose, jac_dense, jac_vmap in zip(poses, jacs_dense, jacs_vmap):\n jac_sparse = jac_dense[sels, :, :, sels]\n torch.testing.assert_close(\n actual=jac_vmap, expected=jac_sparse, atol=1e-6, rtol=1e-5\n )\n jac_sparse_t = jac_sparse.transpose(-1, 1).transpose(-1, -2)\n jac_expected = SE3.left_project(pose, jac_sparse_t).transpose(-1, -2)\n jac_expected[:, 3:] *= 0.5\n jacs_expected.append(jac_expected)\n\n for jac_actual, jac_expected in zip(jacs_actual, jacs_expected):\n torch.testing.assert_close(\n actual=jac_actual, expected=jac_expected, atol=1e-6, rtol=1e-5\n )" }, { "id": 3327, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_vmap_for_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fun(angles):\n jac_b = jfk_b(angles)[0][0]\n return jac_b.sum(dim=(-1, -2)).unsqueeze(-1)\n\n def fun_vmap(angles):\n return fun(angles.unsqueeze(0)).squeeze(0)\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n sels = range(batch_size)\n grad = torch.autograd.functional.jacobian(fun, angles, vectorize=True)\n grad_vmap = torch.vmap(torch.func.jacrev(fun_vmap))(angles)\n\n torch.testing.assert_close(\n actual=grad[sels, :, sels], expected=grad_vmap, atol=1e-6, rtol=1e-5\n )", "probing input": "def test_vmap_for_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fun(angles):\n jac_b = jfk_b(angles)[0][0]\n return jac_b.sum(dim=(-1, -2)).unsqueeze(-1)\n\n def fun_vmap(angles):\n return fun(angles.unsqueeze(0)).squeeze(0)\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n sels = range(batch_size)\n grad = torch.autograd.functional.jacobian(fun, angles, vectorize=True)\n grad_vmap = torch.vmap(torch.func.jacrev(fun_vmap))(angles)\n", "probing input new": "def test_vmap_for_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fun(angles):\n jac_b = jfk_b(angles)[0][0]\n return jac_b.sum(dim=(-1, -2)).unsqueeze(-1)\n\n def fun_vmap(angles):\n return fun(angles.unsqueeze(0)).squeeze(0)\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n sels = range(batch_size)\n grad = torch.autograd.functional.jacobian(fun, angles, vectorize=True)\n grad_vmap = torch.vmap(torch.func.jacrev(fun_vmap))(angles)\n\n torch.testing.", "reference": "torch.testing.assert_close(actual=grad[sels,:,sels],expected=grad_vmap,atol=1e-6,rtol=1e-5)", "reference dict": { "rng": "torch.Generator" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(actual=grad[sels,:,sels],expected=grad_vmap,atol=1e-6,rtol=1e-5)", "y_neg": " torch.testing.assert_allclose(grad, grad_vmap, rtol=1e-2, atol=1e-2)", "retain": "def test_vmap_for_jacobian(batch_size: int, dtype: torch.dtype):\n robot = Robot.from_urdf_file(urdf_path, dtype)\n selected_links = [\"panda_virtual_ee_link\"]\n fk, jfk_b, _ = get_forward_kinematics_fns(robot, selected_links)\n\n def fun(angles):\n jac_b = jfk_b(angles)[0][0]\n return jac_b.sum(dim=(-1, -2)).unsqueeze(-1)\n\n def fun_vmap(angles):\n return fun(angles.unsqueeze(0)).squeeze(0)\n\n rng = torch.Generator()\n rng.manual_seed(0)\n angles = torch.rand(batch_size, robot.dof, generator=rng, dtype=dtype)\n\n sels = range(batch_size)\n grad = torch.autograd.functional.jacobian(fun, angles, vectorize=True)\n grad_vmap = torch.vmap(torch.func.jacrev(fun_vmap))(angles)\n\n torch.testing.assert_close(\n actual=grad[sels, :, sels], expected=grad_vmap, atol=1e-6, rtol=1e-5\n )" }, { "id": 3374, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_caffe2_pytorch_eq(self):\n ims_per_batch = 8\n post_nms_topk = 100\n detections_per_im = 10\n num_class = 80\n score_thresh = 0.05\n nms_thresh = 0.5\n\n image_shapes = [torch.Size([800, 800])] * ims_per_batch\n batch_splits = [post_nms_topk] * ims_per_batch\n\n # NOTE: There're still some unsure minor implementation differences\n # (eg. ordering when equal score across classes) causing some seeds\n # don't pass the test.\n # Thus set a fixed seed to make sure this test passes consistantly.\n rng = torch.Generator()\n rng.manual_seed(42)\n boxes = []\n for n in batch_splits:\n box = 1000.0 * 0.5 * torch.rand(n, num_class, 4, generator=rng) + 0.001\n box[:, :, -2:] += box[:, :, :2]\n box = box.view(n, num_class * 4)\n boxes.append(box)\n scores = [torch.rand(n, num_class + 1, generator=rng) for n in batch_splits]\n\n ref_results, ref_kept_indices = fast_rcnn_inference(\n boxes,\n scores,\n image_shapes,\n score_thresh=score_thresh,\n nms_thresh=nms_thresh,\n topk_per_image=detections_per_im,\n )\n for result, kept_index, score in zip(ref_results, ref_kept_indices, scores):\n torch.testing.assert_close(\n score[kept_index, result.pred_classes],\n result.scores,\n )\n\n # clip is done in BBoxTransformOp\n c2_boxes = []\n for box, image_shape in zip(boxes, image_shapes):\n num_bbox_reg_classes = box.shape[1] // 4\n clipped_box = Boxes(box.reshape(-1, 4))\n clipped_box.clip(image_shape)\n clipped_box = clipped_box.tensor.view(-1, num_bbox_reg_classes * 4)\n c2_boxes.append(clipped_box)\n\n c2_boxes = cat(c2_boxes)\n c2_scores = cat(scores)\n c2_batch_splits = torch.Tensor(batch_splits)\n\n nms_outputs = torch.ops._caffe2.BoxWithNMSLimit(\n c2_scores,\n c2_boxes,\n c2_batch_splits,\n score_thresh=float(score_thresh),\n nms=float(nms_thresh),\n detections_per_im=int(detections_per_im),\n soft_nms_enabled=False,\n soft_nms_method=\"linear\",\n soft_nms_sigma=0.5,\n soft_nms_min_score_thres=0.001,\n rotated=False,\n cls_agnostic_bbox_reg=False,\n input_boxes_include_bg_cls=False,\n output_classes_include_bg_cls=False,\n legacy_plus_one=False,\n )\n (\n roi_score_nms,\n roi_bbox_nms,\n roi_class_nms,\n roi_batch_splits_nms,\n roi_keeps_nms,\n roi_keeps_size_nms,\n ) = nms_outputs # noqa\n\n roi_score_nms = roi_score_nms.split(roi_batch_splits_nms.int().tolist())\n roi_bbox_nms = roi_bbox_nms.split(roi_batch_splits_nms.int().tolist())\n roi_class_nms = roi_class_nms.split(roi_batch_splits_nms.int().tolist())\n roi_keeps_nms = roi_keeps_nms.split(roi_batch_splits_nms.int().tolist())\n\n for _score_nms, _class_nms, _keeps_nms, _score in zip(\n roi_score_nms, roi_class_nms, roi_keeps_nms, scores\n ):\n torch.testing.assert_close(\n _score[_keeps_nms.to(torch.int64), _class_nms.to(torch.int64)],\n _score_nms,\n )\n\n for ref, s, b, c in zip(\n ref_results, roi_score_nms, roi_bbox_nms, roi_class_nms\n ):\n s1, i1 = s.sort()\n s2, i2 = ref.scores.sort()\n torch.testing.assert_close(s1, s2)\n torch.testing.assert_close(b[i1], ref.pred_boxes.tensor[i2])\n torch.testing.assert_close(c.to(torch.int64)[i1], ref.pred_classes[i2])\n\n for ref, k in zip(ref_kept_indices, roi_keeps_nms):\n # NOTE: order might be different due to implementation\n ref_set = set(ref.tolist())\n k_set = set(k.tolist())\n self.assertEqual(ref_set, k_set)", "probing input": " def test_caffe2_pytorch_eq(self):\n ims_per_batch = 8\n post_nms_topk = 100\n detections_per_im = 10\n num_class = 80\n score_thresh = 0.05\n nms_thresh = 0.5\n\n image_shapes = [torch.Size([800, 800])] * ims_per_batch\n batch_splits = [post_nms_topk] * ims_per_batch\n\n # NOTE: There're still some unsure minor implementation differences\n # (eg. ordering when equal score across classes) causing some seeds\n # don't pass the test.\n # Thus set a fixed seed to make sure this test passes consistantly.\n rng = torch.Generator()\n rng.manual_seed(42)\n boxes = []\n for n in batch_splits:\n box = 1000.0 * 0.5 * torch.rand(n, num_class, 4, generator=rng) + 0.001\n box[:, :, -2:] += box[:, :, :2]\n box = box.view(n, num_class * 4)\n boxes.append(box)\n scores = [torch.rand(n, num_class + 1, generator=rng) for n in batch_splits]\n\n ref_results, ref_kept_indices = fast_rcnn_inference(\n boxes,\n scores,\n image_shapes,\n score_thresh=score_thresh,\n nms_thresh=nms_thresh,\n topk_per_image=detections_per_im,\n )\n for result, kept_index, score in zip(ref_results, ref_kept_indices, scores):\n", "probing input new": " def test_caffe2_pytorch_eq(self):\n ims_per_batch = 8\n post_nms_topk = 100\n detections_per_im = 10\n num_class = 80\n score_thresh = 0.05\n nms_thresh = 0.5\n\n image_shapes = [torch.Size([800, 800])] * ims_per_batch\n batch_splits = [post_nms_topk] * ims_per_batch\n\n # NOTE: There're still some unsure minor implementation differences\n # (eg. ordering when equal score across classes) causing some seeds\n # don't pass the test.\n # Thus set a fixed seed to make sure this test passes consistantly.\n rng = torch.Generator()\n rng.manual_seed(42)\n boxes = []\n for n in batch_splits:\n box = 1000.0 * 0.5 * torch.rand(n, num_class, 4, generator=rng) + 0.001\n box[:, :, -2:] += box[:, :, :2]\n box = box.view(n, num_class * 4)\n boxes.append(box)\n scores = [torch.rand(n, num_class + 1, generator=rng) for n in batch_splits]\n\n ref_results, ref_kept_indices = fast_rcnn_inference(\n boxes,\n scores,\n image_shapes,\n score_thresh=score_thresh,\n nms_thresh=nms_thresh,\n topk_per_image=detections_per_im,\n )\n for result, kept_index, score in zip(ref_results, ref_kept_indices, scores):\n torch.testing.", "reference": "torch.testing.assert_close(score[kept_index,result.pred_classes],result.scores,)", "reference dict": { "rng": "torch.Generator", "c2_batch_splits": "torch.Tensor", "nms_outputs": "torch.ops._caffe2.BoxWithNMSLimit", "clipped_box": "Boxes" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(score[kept_index,result.pred_classes],result.scores,)", "y_neg": " torch.testing.assert_allclose(", "retain": " def test_caffe2_pytorch_eq(self):\n ims_per_batch = 8\n post_nms_topk = 100\n detections_per_im = 10\n num_class = 80\n score_thresh = 0.05\n nms_thresh = 0.5\n\n image_shapes = [torch.Size([800, 800])] * ims_per_batch\n batch_splits = [post_nms_topk] * ims_per_batch\n\n # NOTE: There're still some unsure minor implementation differences\n # (eg. ordering when equal score across classes) causing some seeds\n # don't pass the test.\n # Thus set a fixed seed to make sure this test passes consistantly.\n rng = torch.Generator()\n rng.manual_seed(42)\n boxes = []\n for n in batch_splits:\n box = 1000.0 * 0.5 * torch.rand(n, num_class, 4, generator=rng) + 0.001\n box[:, :, -2:] += box[:, :, :2]\n box = box.view(n, num_class * 4)\n boxes.append(box)\n scores = [torch.rand(n, num_class + 1, generator=rng) for n in batch_splits]\n\n ref_results, ref_kept_indices = fast_rcnn_inference(\n boxes,\n scores,\n image_shapes,\n score_thresh=score_thresh,\n nms_thresh=nms_thresh,\n topk_per_image=detections_per_im,\n )\n for result, kept_index, score in zip(ref_results, ref_kept_indices, scores):\n torch.testing.assert_close(\n score[kept_index, result.pred_classes],\n result.scores,\n )\n\n # clip is done in BBoxTransformOp\n c2_boxes = []\n for box, image_shape in zip(boxes, image_shapes):\n num_bbox_reg_classes = box.shape[1] // 4\n clipped_box = Boxes(box.reshape(-1, 4))\n clipped_box.clip(image_shape)\n clipped_box = clipped_box.tensor.view(-1, num_bbox_reg_classes * 4)\n c2_boxes.append(clipped_box)\n\n c2_boxes = cat(c2_boxes)\n c2_scores = cat(scores)\n c2_batch_splits = torch.Tensor(batch_splits)\n\n nms_outputs = torch.ops._caffe2.BoxWithNMSLimit(\n c2_scores,\n c2_boxes,\n c2_batch_splits,\n score_thresh=float(score_thresh),\n nms=float(nms_thresh),\n detections_per_im=int(detections_per_im),\n soft_nms_enabled=False,\n soft_nms_method=\"linear\",\n soft_nms_sigma=0.5,\n soft_nms_min_score_thres=0.001,\n rotated=False,\n cls_agnostic_bbox_reg=False,\n input_boxes_include_bg_cls=False,\n output_classes_include_bg_cls=False,\n legacy_plus_one=False,\n )\n (\n roi_score_nms,\n roi_bbox_nms,\n roi_class_nms,\n roi_batch_splits_nms,\n roi_keeps_nms,\n roi_keeps_size_nms,\n ) = nms_outputs # noqa\n\n roi_score_nms = roi_score_nms.split(roi_batch_splits_nms.int().tolist())\n roi_bbox_nms = roi_bbox_nms.split(roi_batch_splits_nms.int().tolist())\n roi_class_nms = roi_class_nms.split(roi_batch_splits_nms.int().tolist())\n roi_keeps_nms = roi_keeps_nms.split(roi_batch_splits_nms.int().tolist())\n\n for _score_nms, _class_nms, _keeps_nms, _score in zip(\n roi_score_nms, roi_class_nms, roi_keeps_nms, scores\n ):\n torch.testing.assert_close(\n _score[_keeps_nms.to(torch.int64), _class_nms.to(torch.int64)],\n _score_nms,\n )\n\n for ref, s, b, c in zip(\n ref_results, roi_score_nms, roi_bbox_nms, roi_class_nms\n ):\n s1, i1 = s.sort()\n s2, i2 = ref.scores.sort()\n torch.testing.assert_close(s1, s2)\n torch.testing.assert_close(b[i1], ref.pred_boxes.tensor[i2])\n torch.testing.assert_close(c.to(torch.int64)[i1], ref.pred_classes[i2])\n\n for ref, k in zip(ref_kept_indices, roi_keeps_nms):\n # NOTE: order might be different due to implementation\n ref_set = set(ref.tolist())\n k_set = set(k.tolist())\n self.assertEqual(ref_set, k_set)" }, { "id": 3431, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_tanh_atanh(use_vmap, scale):\n if use_vmap:\n try:\n from torch import vmap\n except ImportError:\n try:\n from functorch import vmap\n except ImportError:\n raise pytest.skip(\"functorch not found\")\n\n torch.manual_seed(0)\n x = (torch.randn(10, dtype=torch.double) * scale).requires_grad_(True)\n if not use_vmap:\n y = safetanh(x, 1e-6)\n else:\n y = vmap(safetanh, (0, None))(x, 1e-6)\n\n if not use_vmap:\n xp = safeatanh(y, 1e-6)\n else:\n xp = vmap(safeatanh, (0, None))(y, 1e-6)\n\n xp.sum().backward()\n torch.testing.assert_close(x.grad, torch.ones_like(x))", "probing input": "def test_tanh_atanh(use_vmap, scale):\n if use_vmap:\n try:\n from torch import vmap\n except ImportError:\n try:\n from functorch import vmap\n except ImportError:\n raise pytest.skip(\"functorch not found\")\n\n torch.manual_seed(0)\n x = (torch.randn(10, dtype=torch.double) * scale).requires_grad_(True)\n if not use_vmap:\n y = safetanh(x, 1e-6)\n else:\n y = vmap(safetanh, (0, None))(x, 1e-6)\n\n if not use_vmap:\n xp = safeatanh(y, 1e-6)\n else:\n xp = vmap(safeatanh, (0, None))(y, 1e-6)\n\n xp.sum().backward()\n", "probing input new": "def test_tanh_atanh(use_vmap, scale):\n if use_vmap:\n try:\n from torch import vmap\n except ImportError:\n try:\n from functorch import vmap\n except ImportError:\n raise pytest.skip(\"functorch not found\")\n\n torch.manual_seed(0)\n x = (torch.randn(10, dtype=torch.double) * scale).requires_grad_(True)\n if not use_vmap:\n y = safetanh(x, 1e-6)\n else:\n y = vmap(safetanh, (0, None))(x, 1e-6)\n\n if not use_vmap:\n xp = safeatanh(y, 1e-6)\n else:\n xp = vmap(safeatanh, (0, None))(y, 1e-6)\n\n xp.sum().backward()\n torch.testing.", "reference": "torch.testing.assert_close(x.grad,torch.ones_like(x))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(x.grad,torch.ones_like(x))", "y_neg": " torch.testing.assert_allclose(x.grad, xp.grad, atol=1e-6)", "retain": "def test_tanh_atanh(use_vmap, scale):\n if use_vmap:\n try:\n from torch import vmap\n except ImportError:\n try:\n from functorch import vmap\n except ImportError:\n raise pytest.skip(\"functorch not found\")\n\n torch.manual_seed(0)\n x = (torch.randn(10, dtype=torch.double) * scale).requires_grad_(True)\n if not use_vmap:\n y = safetanh(x, 1e-6)\n else:\n y = vmap(safetanh, (0, None))(x, 1e-6)\n\n if not use_vmap:\n xp = safeatanh(y, 1e-6)\n else:\n xp = vmap(safeatanh, (0, None))(y, 1e-6)\n\n xp.sum().backward()\n torch.testing.assert_close(x.grad, torch.ones_like(x))" }, { "id": 3451, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def assert_all_approx_close(a, b, atol=1e-8, rtol=1e-5, count=10):\n idx = torch.isclose(a, b, rtol=rtol, atol=atol)\n sumval = (idx == 0).sum().item()\n if sumval > count:\n print(f\"Too many values not close: assert {sumval} < {count}\")\n torch.testing.assert_close(a, b, rtol=rtol, atol=atol)", "probing input": "def assert_all_approx_close(a, b, atol=1e-8, rtol=1e-5, count=10):\n idx = torch.isclose(a, b, rtol=rtol, atol=atol)\n sumval = (idx == 0).sum().item()\n if sumval > count:\n print(f\"Too many values not close: assert {sumval} < {count}\")\n", "probing input new": "def assert_all_approx_close(a, b, atol=1e-8, rtol=1e-5, count=10):\n idx = torch.isclose(a, b, rtol=rtol, atol=atol)\n sumval = (idx == 0).sum().item()\n if sumval > count:\n print(f\"Too many values not close: assert {sumval} < {count}\")\n torch.testing.", "reference": "torch.testing.assert_close(a,b,rtol=rtol,atol=atol)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(a,b,rtol=rtol,atol=atol)", "y_neg": " torch.testing.assert_allclose(a, b, atol=atol, rtol=rtol)", "retain": "def assert_all_approx_close(a, b, atol=1e-8, rtol=1e-5, count=10):\n idx = torch.isclose(a, b, rtol=rtol, atol=atol)\n sumval = (idx == 0).sum().item()\n if sumval > count:\n print(f\"Too many values not close: assert {sumval} < {count}\")\n torch.testing.assert_close(a, b, rtol=rtol, atol=atol)" }, { "id": 3452, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_tanhtrsf_grad(dtype):\n torch.manual_seed(0)\n trsf = SafeTanhTransform()\n x = torch.randn(100, requires_grad=True)\n y1 = trsf(x)\n y2 = x.tanh()\n g1 = autograd.grad(y1.sum(), x, retain_graph=True)[0]\n g2 = autograd.grad(y2.sum(), x, retain_graph=True)[0]\n torch.testing.assert_close(g1, g2)", "probing input": "def test_tanhtrsf_grad(dtype):\n torch.manual_seed(0)\n trsf = SafeTanhTransform()\n x = torch.randn(100, requires_grad=True)\n y1 = trsf(x)\n y2 = x.tanh()\n g1 = autograd.grad(y1.sum(), x, retain_graph=True)[0]\n g2 = autograd.grad(y2.sum(), x, retain_graph=True)[0]\n", "probing input new": "def test_tanhtrsf_grad(dtype):\n torch.manual_seed(0)\n trsf = SafeTanhTransform()\n x = torch.randn(100, requires_grad=True)\n y1 = trsf(x)\n y2 = x.tanh()\n g1 = autograd.grad(y1.sum(), x, retain_graph=True)[0]\n g2 = autograd.grad(y2.sum(), x, retain_graph=True)[0]\n torch.testing.", "reference": "torch.testing.assert_close(g1,g2)", "reference dict": { "trsf": "SafeTanhTransform" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(g1,g2)", "y_neg": " torch.testing.assert_allclose(g1, g2, rtol=1e-6, atol=1e-6)", "retain": "def test_tanhtrsf_grad(dtype):\n torch.manual_seed(0)\n trsf = SafeTanhTransform()\n x = torch.randn(100, requires_grad=True)\n y1 = trsf(x)\n y2 = x.tanh()\n g1 = autograd.grad(y1.sum(), x, retain_graph=True)[0]\n g2 = autograd.grad(y2.sum(), x, retain_graph=True)[0]\n torch.testing.assert_close(g1, g2)" }, { "id": 3594, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def assert_allclose(\n actual: Any,\n expected: Any,\n rtol: Optional[float] = None,\n atol: Optional[float] = None,\n equal_nan: bool = True,\n msg: str = \"\",\n) -> None:\n if not isinstance(actual, torch.Tensor):\n actual = torch.tensor(actual)\n if not isinstance(expected, torch.Tensor):\n expected = torch.tensor(expected, dtype=actual.dtype)\n\n if rtol is None and atol is None:\n rtol, atol = _get_default_rtol_and_atol(actual, expected)\n\n torch.testing.assert_close(\n actual,\n expected,\n rtol=rtol,\n atol=atol,\n equal_nan=equal_nan,\n check_device=True,\n check_dtype=False,\n check_stride=False,\n msg=msg or None,\n )", "probing input": "def assert_allclose(\n actual: Any,\n expected: Any,\n rtol: Optional[float] = None,\n atol: Optional[float] = None,\n equal_nan: bool = True,\n msg: str = \"\",\n) -> None:\n if not isinstance(actual, torch.Tensor):\n actual = torch.tensor(actual)\n if not isinstance(expected, torch.Tensor):\n expected = torch.tensor(expected, dtype=actual.dtype)\n\n if rtol is None and atol is None:\n rtol, atol = _get_default_rtol_and_atol(actual, expected)\n", "probing input new": "def assert_allclose(\n actual: Any,\n expected: Any,\n rtol: Optional[float] = None,\n atol: Optional[float] = None,\n equal_nan: bool = True,\n msg: str = \"\",\n) -> None:\n if not isinstance(actual, torch.Tensor):\n actual = torch.tensor(actual)\n if not isinstance(expected, torch.Tensor):\n expected = torch.tensor(expected, dtype=actual.dtype)\n\n if rtol is None and atol is None:\n rtol, atol = _get_default_rtol_and_atol(actual, expected)\n\n torch.testing.", "reference": "torch.testing.assert_close(actual,expected,rtol=rtol,atol=atol,equal_nan=equal_nan,check_device=True,check_dtype=False,check_stride=False,msg=msgorNone,)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(actual,expected,rtol=rtol,atol=atol,equal_nan=equal_nan,check_device=True,check_dtype=False,check_stride=False,msg=msgorNone,)", "y_neg": " torch.testing.assert_allclose(", "retain": "def assert_allclose(\n actual: Any,\n expected: Any,\n rtol: Optional[float] = None,\n atol: Optional[float] = None,\n equal_nan: bool = True,\n msg: str = \"\",\n) -> None:\n if not isinstance(actual, torch.Tensor):\n actual = torch.tensor(actual)\n if not isinstance(expected, torch.Tensor):\n expected = torch.tensor(expected, dtype=actual.dtype)\n\n if rtol is None and atol is None:\n rtol, atol = _get_default_rtol_and_atol(actual, expected)\n\n torch.testing.assert_close(\n actual,\n expected,\n rtol=rtol,\n atol=atol,\n equal_nan=equal_nan,\n check_device=True,\n check_dtype=False,\n check_stride=False,\n msg=msg or None,\n )" }, { "id": 3596, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_default_comparer(\n rtol: float = 1e-04,\n atol: float = 0,\n equal_nan: bool = True,\n) -> _CompareFn:\n \"\"\"Creates default comparer function.\n\n The created function will compare the outputs by using\n `torch.testing.assert_allclose` with specified options.\n\n Args:\n rtol (float): Relative tolerance.\n atol (float): Absolute tolerance.\n equal_nan (bool): If ``True``, NaNs will be ignored.\n \"\"\"\n\n def compare_fn(\n backend1: str, backend2: str, name: str, val1: Any, val2: Any\n ) -> None:\n # TODO select the device where\n # the tensors will be compared?\n if isinstance(val1, torch.Tensor):\n val1 = val1.cpu().detach()\n if isinstance(val2, torch.Tensor):\n val2 = val2.cpu().detach()\n\n torch.testing.assert_close(\n val1, val2, rtol=rtol, atol=atol, equal_nan=equal_nan\n )\n\n return compare_fn", "probing input": "def get_default_comparer(\n rtol: float = 1e-04,\n atol: float = 0,\n equal_nan: bool = True,\n) -> _CompareFn:\n \"\"\"Creates default comparer function.\n\n The created function will compare the outputs by using\n `torch.testing.assert_allclose` with specified options.\n\n Args:\n rtol (float): Relative tolerance.\n atol (float): Absolute tolerance.\n equal_nan (bool): If ``True``, NaNs will be ignored.\n \"\"\"\n\n def compare_fn(\n backend1: str, backend2: str, name: str, val1: Any, val2: Any\n ) -> None:\n # TODO select the device where\n # the tensors will be compared?\n if isinstance(val1, torch.Tensor):\n val1 = val1.cpu().detach()\n if isinstance(val2, torch.Tensor):\n val2 = val2.cpu().detach()\n", "probing input new": "def get_default_comparer(\n rtol: float = 1e-04,\n atol: float = 0,\n equal_nan: bool = True,\n) -> _CompareFn:\n \"\"\"Creates default comparer function.\n\n The created function will compare the outputs by using\n `torch.testing.assert_allclose` with specified options.\n\n Args:\n rtol (float): Relative tolerance.\n atol (float): Absolute tolerance.\n equal_nan (bool): If ``True``, NaNs will be ignored.\n \"\"\"\n\n def compare_fn(\n backend1: str, backend2: str, name: str, val1: Any, val2: Any\n ) -> None:\n # TODO select the device where\n # the tensors will be compared?\n if isinstance(val1, torch.Tensor):\n val1 = val1.cpu().detach()\n if isinstance(val2, torch.Tensor):\n val2 = val2.cpu().detach()\n\n torch.testing.", "reference": "torch.testing.assert_close(val1,val2,rtol=rtol,atol=atol,equal_nan=equal_nan)", "reference dict": {}, "alias dict": { "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.testing.assert_close": "torch.testing.assert_close", "torch.testing.assert_allclose": "torch.testing.assert_allclose" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(val1,val2,rtol=rtol,atol=atol,equal_nan=equal_nan)", "y_neg": " torch.testing.assert_allclose(", "retain": "def get_default_comparer(\n rtol: float = 1e-04,\n atol: float = 0,\n equal_nan: bool = True,\n) -> _CompareFn:\n \"\"\"Creates default comparer function.\n\n The created function will compare the outputs by using\n `torch.testing.assert_allclose` with specified options.\n\n Args:\n rtol (float): Relative tolerance.\n atol (float): Absolute tolerance.\n equal_nan (bool): If ``True``, NaNs will be ignored.\n \"\"\"\n\n def compare_fn(\n backend1: str, backend2: str, name: str, val1: Any, val2: Any\n ) -> None:\n # TODO select the device where\n # the tensors will be compared?\n if isinstance(val1, torch.Tensor):\n val1 = val1.cpu().detach()\n if isinstance(val2, torch.Tensor):\n val2 = val2.cpu().detach()\n\n torch.testing.assert_close(\n val1, val2, rtol=rtol, atol=atol, equal_nan=equal_nan\n )\n\n return compare_fn" }, { "id": 3666, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_scale(self):\n boxes = torch.tensor([\n [0, 0, 1, 1],\n [0, 10, 10, 20],\n ])\n dtype = boxes.dtype\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 1, 1\n boxlist.scale(yscale, xscale)\n torch.testing.assert_close(boxlist.boxes, boxes)\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 5, 3\n boxlist.scale(yscale, xscale)\n x_expected = (boxes[:, [0, 2]] * xscale).to(dtype=dtype)\n y_expected = (boxes[:, [1, 3]] * yscale).to(dtype=dtype)\n torch.testing.assert_close(boxlist.boxes[:, [0, 2]], x_expected)\n torch.testing.assert_close(boxlist.boxes[:, [1, 3]], y_expected)\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 0.5, 0.3\n boxlist.scale(yscale, xscale)\n x_expected = (boxes[:, [0, 2]] * xscale).to(dtype=dtype)\n y_expected = (boxes[:, [1, 3]] * yscale).to(dtype=dtype)\n torch.testing.assert_close(boxlist.boxes[:, [0, 2]], x_expected)\n torch.testing.assert_close(boxlist.boxes[:, [1, 3]], y_expected)", "probing input": " def test_scale(self):\n boxes = torch.tensor([\n [0, 0, 1, 1],\n [0, 10, 10, 20],\n ])\n dtype = boxes.dtype\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 1, 1\n boxlist.scale(yscale, xscale)\n", "probing input new": " def test_scale(self):\n boxes = torch.tensor([\n [0, 0, 1, 1],\n [0, 10, 10, 20],\n ])\n dtype = boxes.dtype\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 1, 1\n boxlist.scale(yscale, xscale)\n torch.testing.", "reference": "torch.testing.assert_close(boxlist.boxes,boxes)", "reference dict": { "boxlist": "BoxList" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(boxlist.boxes,boxes)", "y_neg": " torch.testing.assert_allclose(boxlist.boxes.clone(), torch.tensor([", "retain": " def test_scale(self):\n boxes = torch.tensor([\n [0, 0, 1, 1],\n [0, 10, 10, 20],\n ])\n dtype = boxes.dtype\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 1, 1\n boxlist.scale(yscale, xscale)\n torch.testing.assert_close(boxlist.boxes, boxes)\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 5, 3\n boxlist.scale(yscale, xscale)\n x_expected = (boxes[:, [0, 2]] * xscale).to(dtype=dtype)\n y_expected = (boxes[:, [1, 3]] * yscale).to(dtype=dtype)\n torch.testing.assert_close(boxlist.boxes[:, [0, 2]], x_expected)\n torch.testing.assert_close(boxlist.boxes[:, [1, 3]], y_expected)\n\n boxlist = BoxList(boxes.clone())\n yscale, xscale = 0.5, 0.3\n boxlist.scale(yscale, xscale)\n x_expected = (boxes[:, [0, 2]] * xscale).to(dtype=dtype)\n y_expected = (boxes[:, [1, 3]] * yscale).to(dtype=dtype)\n torch.testing.assert_close(boxlist.boxes[:, [0, 2]], x_expected)\n torch.testing.assert_close(boxlist.boxes[:, [1, 3]], y_expected)" }, { "id": 3781, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_different_quant_descriptors_are_piped(self):\n from super_gradients.training.utils.quantization import SelectiveQuantizer\n from pytorch_quantization.calib import HistogramCalibrator\n from pytorch_quantization.calib import MaxCalibrator\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n from pytorch_quantization.nn import QuantConv2d\n\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, 8, 32, 32))\n self.assertTrue(isinstance(module.conv1, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(type(module.conv1._input_quantizer._calibrator) == MaxCalibrator)\n self.assertTrue(type(module.conv1._weight_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._input_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._weight_quantizer._calibrator) == MaxCalibrator)", "probing input": " def test_different_quant_descriptors_are_piped(self):\n from super_gradients.training.utils.quantization import SelectiveQuantizer\n from pytorch_quantization.calib import HistogramCalibrator\n from pytorch_quantization.calib import MaxCalibrator\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n from pytorch_quantization.nn import QuantConv2d\n\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n", "probing input new": " def test_different_quant_descriptors_are_piped(self):\n from super_gradients.training.utils.quantization import SelectiveQuantizer\n from pytorch_quantization.calib import HistogramCalibrator\n from pytorch_quantization.calib import MaxCalibrator\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n from pytorch_quantization.nn import QuantConv2d\n\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.", "reference": "torch.testing.assert_close(y.size(),(1,8,32,32))", "reference dict": { "module": "MyModel", "q_util": "SelectiveQuantizer", "self.conv1": "nn.Conv2d", "self.conv2": "nn.Conv2d" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(y.size(),(1,8,32,32))", "y_neg": " torch.testing.assert_allclose(x, y, atol=1e-3)", "retain": " def test_different_quant_descriptors_are_piped(self):\n from super_gradients.training.utils.quantization import SelectiveQuantizer\n from pytorch_quantization.calib import HistogramCalibrator\n from pytorch_quantization.calib import MaxCalibrator\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n # ARRANGE\n class MyModel(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)\n self.conv2 = nn.Conv2d(8, 8, kernel_size=3, padding=1)\n\n def forward(self, x):\n return self.conv2(self.conv1(x))\n\n module = MyModel()\n\n # TEST\n q_util = SelectiveQuantizer()\n from pytorch_quantization.nn import QuantConv2d\n\n q_util.register_quantization_mapping(\n layer_names={\"conv1\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n )\n from pytorch_quantization.tensor_quant import QuantDescriptor\n\n q_util.register_quantization_mapping(\n layer_names={\"conv2\"},\n quantized_target_class=QuantConv2d,\n input_quant_descriptor=QuantDescriptor(calib_method=\"histogram\"),\n weights_quant_descriptor=QuantDescriptor(calib_method=\"max\"),\n )\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, 32, 32)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, 8, 32, 32))\n self.assertTrue(isinstance(module.conv1, SelectiveQuantizer.mapping_instructions[nn.Conv2d].quantized_target_class))\n self.assertTrue(type(module.conv1._input_quantizer._calibrator) == MaxCalibrator)\n self.assertTrue(type(module.conv1._weight_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._input_quantizer._calibrator) == HistogramCalibrator)\n self.assertTrue(type(module.conv2._weight_quantizer._calibrator) == MaxCalibrator)" }, { "id": 3842, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_seed():\n torch.manual_seed(0)\n env1 = GymEnv(PENDULUM_VERSIONED())\n env1.set_seed(0)\n state0_1 = env1.reset()\n state1_1 = env1.step(state0_1.set(\"action\", env1.action_spec.rand()))\n\n torch.manual_seed(0)\n env2 = GymEnv(PENDULUM_VERSIONED())\n env2.set_seed(0)\n state0_2 = env2.reset()\n state1_2 = env2.step(state0_2.set(\"action\", env2.action_spec.rand()))\n\n assert_allclose_td(state0_1, state0_2)\n assert_allclose_td(state1_1, state1_2)\n\n env1.set_seed(0)\n torch.manual_seed(0)\n rollout1 = env1.rollout(max_steps=30)\n\n env2.set_seed(0)\n torch.manual_seed(0)\n rollout2 = env2.rollout(max_steps=30)\n\n torch.testing.assert_close(\n rollout1[\"observation\"][1:], rollout1[(\"next\", \"observation\")][:-1]\n )\n torch.testing.assert_close(\n rollout2[\"observation\"][1:], rollout2[(\"next\", \"observation\")][:-1]\n )\n torch.testing.assert_close(rollout1[\"observation\"], rollout2[\"observation\"])", "probing input": "def test_seed():\n torch.manual_seed(0)\n env1 = GymEnv(PENDULUM_VERSIONED())\n env1.set_seed(0)\n state0_1 = env1.reset()\n state1_1 = env1.step(state0_1.set(\"action\", env1.action_spec.rand()))\n\n torch.manual_seed(0)\n env2 = GymEnv(PENDULUM_VERSIONED())\n env2.set_seed(0)\n state0_2 = env2.reset()\n state1_2 = env2.step(state0_2.set(\"action\", env2.action_spec.rand()))\n\n assert_allclose_td(state0_1, state0_2)\n assert_allclose_td(state1_1, state1_2)\n\n env1.set_seed(0)\n torch.manual_seed(0)\n rollout1 = env1.rollout(max_steps=30)\n\n env2.set_seed(0)\n torch.manual_seed(0)\n rollout2 = env2.rollout(max_steps=30)\n", "probing input new": "def test_seed():\n torch.manual_seed(0)\n env1 = GymEnv(PENDULUM_VERSIONED())\n env1.set_seed(0)\n state0_1 = env1.reset()\n state1_1 = env1.step(state0_1.set(\"action\", env1.action_spec.rand()))\n\n torch.manual_seed(0)\n env2 = GymEnv(PENDULUM_VERSIONED())\n env2.set_seed(0)\n state0_2 = env2.reset()\n state1_2 = env2.step(state0_2.set(\"action\", env2.action_spec.rand()))\n\n assert_allclose_td(state0_1, state0_2)\n assert_allclose_td(state1_1, state1_2)\n\n env1.set_seed(0)\n torch.manual_seed(0)\n rollout1 = env1.rollout(max_steps=30)\n\n env2.set_seed(0)\n torch.manual_seed(0)\n rollout2 = env2.rollout(max_steps=30)\n\n torch.testing.", "reference": "torch.testing.assert_close(rollout1[\"observation\"][1:],rollout1[(\"next\",\"observation\")][:-1])", "reference dict": { "env1": "GymEnv", "env2": "GymEnv" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(rollout1[\"observation\"][1:],rollout1[(\"next\",\"observation\")][:-1])", "y_neg": " torch.testing.assert_allclose(rollout1.returns, rollout2.returns)", "retain": "def test_seed():\n torch.manual_seed(0)\n env1 = GymEnv(PENDULUM_VERSIONED())\n env1.set_seed(0)\n state0_1 = env1.reset()\n state1_1 = env1.step(state0_1.set(\"action\", env1.action_spec.rand()))\n\n torch.manual_seed(0)\n env2 = GymEnv(PENDULUM_VERSIONED())\n env2.set_seed(0)\n state0_2 = env2.reset()\n state1_2 = env2.step(state0_2.set(\"action\", env2.action_spec.rand()))\n\n assert_allclose_td(state0_1, state0_2)\n assert_allclose_td(state1_1, state1_2)\n\n env1.set_seed(0)\n torch.manual_seed(0)\n rollout1 = env1.rollout(max_steps=30)\n\n env2.set_seed(0)\n torch.manual_seed(0)\n rollout2 = env2.rollout(max_steps=30)\n\n torch.testing.assert_close(\n rollout1[\"observation\"][1:], rollout1[(\"next\", \"observation\")][:-1]\n )\n torch.testing.assert_close(\n rollout2[\"observation\"][1:], rollout2[(\"next\", \"observation\")][:-1]\n )\n torch.testing.assert_close(rollout1[\"observation\"], rollout2[\"observation\"])" }, { "id": 3873, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_multistep(n, key, device, T=11):\n torch.manual_seed(0)\n\n # mock data\n b = 5\n\n done = torch.zeros(b, T, 1, dtype=torch.bool, device=device)\n done[0, -1] = True\n done[1, -2] = True\n done[2, -3] = True\n done[3, -4] = True\n\n terminal = done.clone()\n terminal[:, -1] = done.sum(1) != 1\n\n mask = done.clone().cumsum(1).cumsum(1) >= 2\n mask = ~mask\n\n total_obs = torch.randn(1, T + 1, 1, device=device).expand(b, T + 1, 1)\n tensordict = TensorDict(\n source={\n key: total_obs[:, :T] * mask.to(torch.float),\n \"done\": done,\n \"next\": {\n key: total_obs[:, 1:] * mask.to(torch.float),\n \"done\": done,\n \"reward\": torch.randn(1, T, 1, device=device).expand(b, T, 1)\n * mask.to(torch.float),\n },\n \"collector\": {\"mask\": mask},\n },\n batch_size=(b, T),\n ).to(device)\n\n ms = MultiStep(\n 0.9,\n n,\n ).to(device)\n ms_tensordict = ms(tensordict.clone())\n\n assert ms_tensordict.get(\"done\").max() == 1\n\n if n == 1:\n assert_allclose_td(\n tensordict, ms_tensordict.select(*list(tensordict.keys(True, True)))\n )\n\n # assert that done at last step is similar to unterminated traj\n torch.testing.assert_close(\n ms_tensordict.get(\"gamma\")[4], ms_tensordict.get(\"gamma\")[0]\n )\n torch.testing.assert_close(\n ms_tensordict.get((\"next\", key))[4], ms_tensordict.get((\"next\", key))[0]\n )\n torch.testing.assert_close(\n ms_tensordict.get(\"steps_to_next_obs\")[4],\n ms_tensordict.get(\"steps_to_next_obs\")[0],\n )\n\n # check that next obs is properly replaced, or that it is terminated\n next_obs = ms_tensordict.get(key)[:, (ms.n_steps) :]\n true_next_obs = ms_tensordict.get((\"next\", key))[:, : -(ms.n_steps)]\n terminated = ~ms_tensordict.get(\"nonterminal\")\n assert ((next_obs == true_next_obs).all(-1) | terminated[:, (ms.n_steps) :]).all()\n\n # test gamma computation\n torch.testing.assert_close(\n ms_tensordict.get(\"gamma\"), ms.gamma ** ms_tensordict.get(\"steps_to_next_obs\")\n )\n\n # test reward\n if n > 1:\n assert (\n ms_tensordict.get((\"next\", \"reward\"))\n != ms_tensordict.get((\"next\", \"original_reward\"))\n ).any()\n else:\n torch.testing.assert_close(\n ms_tensordict.get((\"next\", \"reward\")),\n ms_tensordict.get((\"next\", \"original_reward\")),\n )", "probing input": "def test_multistep(n, key, device, T=11):\n torch.manual_seed(0)\n\n # mock data\n b = 5\n\n done = torch.zeros(b, T, 1, dtype=torch.bool, device=device)\n done[0, -1] = True\n done[1, -2] = True\n done[2, -3] = True\n done[3, -4] = True\n\n terminal = done.clone()\n terminal[:, -1] = done.sum(1) != 1\n\n mask = done.clone().cumsum(1).cumsum(1) >= 2\n mask = ~mask\n\n total_obs = torch.randn(1, T + 1, 1, device=device).expand(b, T + 1, 1)\n tensordict = TensorDict(\n source={\n key: total_obs[:, :T] * mask.to(torch.float),\n \"done\": done,\n \"next\": {\n key: total_obs[:, 1:] * mask.to(torch.float),\n \"done\": done,\n \"reward\": torch.randn(1, T, 1, device=device).expand(b, T, 1)\n * mask.to(torch.float),\n },\n \"collector\": {\"mask\": mask},\n },\n batch_size=(b, T),\n ).to(device)\n\n ms = MultiStep(\n 0.9,\n n,\n ).to(device)\n ms_tensordict = ms(tensordict.clone())\n\n assert ms_tensordict.get(\"done\").max() == 1\n\n if n == 1:\n assert_allclose_td(\n tensordict, ms_tensordict.select(*list(tensordict.keys(True, True)))\n )\n\n # assert that done at last step is similar to unterminated traj\n", "probing input new": "def test_multistep(n, key, device, T=11):\n torch.manual_seed(0)\n\n # mock data\n b = 5\n\n done = torch.zeros(b, T, 1, dtype=torch.bool, device=device)\n done[0, -1] = True\n done[1, -2] = True\n done[2, -3] = True\n done[3, -4] = True\n\n terminal = done.clone()\n terminal[:, -1] = done.sum(1) != 1\n\n mask = done.clone().cumsum(1).cumsum(1) >= 2\n mask = ~mask\n\n total_obs = torch.randn(1, T + 1, 1, device=device).expand(b, T + 1, 1)\n tensordict = TensorDict(\n source={\n key: total_obs[:, :T] * mask.to(torch.float),\n \"done\": done,\n \"next\": {\n key: total_obs[:, 1:] * mask.to(torch.float),\n \"done\": done,\n \"reward\": torch.randn(1, T, 1, device=device).expand(b, T, 1)\n * mask.to(torch.float),\n },\n \"collector\": {\"mask\": mask},\n },\n batch_size=(b, T),\n ).to(device)\n\n ms = MultiStep(\n 0.9,\n n,\n ).to(device)\n ms_tensordict = ms(tensordict.clone())\n\n assert ms_tensordict.get(\"done\").max() == 1\n\n if n == 1:\n assert_allclose_td(\n tensordict, ms_tensordict.select(*list(tensordict.keys(True, True)))\n )\n\n # assert that done at last step is similar to unterminated traj\n torch.testing.", "reference": "torch.testing.assert_close(ms_tensordict.get(\"gamma\")[4],ms_tensordict.get(\"gamma\")[0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(ms_tensordict.get(\"gamma\")[4],ms_tensordict.get(\"gamma\")[0])", "y_neg": " torch.testing.assert_allclose(", "retain": "def test_multistep(n, key, device, T=11):\n torch.manual_seed(0)\n\n # mock data\n b = 5\n\n done = torch.zeros(b, T, 1, dtype=torch.bool, device=device)\n done[0, -1] = True\n done[1, -2] = True\n done[2, -3] = True\n done[3, -4] = True\n\n terminal = done.clone()\n terminal[:, -1] = done.sum(1) != 1\n\n mask = done.clone().cumsum(1).cumsum(1) >= 2\n mask = ~mask\n\n total_obs = torch.randn(1, T + 1, 1, device=device).expand(b, T + 1, 1)\n tensordict = TensorDict(\n source={\n key: total_obs[:, :T] * mask.to(torch.float),\n \"done\": done,\n \"next\": {\n key: total_obs[:, 1:] * mask.to(torch.float),\n \"done\": done,\n \"reward\": torch.randn(1, T, 1, device=device).expand(b, T, 1)\n * mask.to(torch.float),\n },\n \"collector\": {\"mask\": mask},\n },\n batch_size=(b, T),\n ).to(device)\n\n ms = MultiStep(\n 0.9,\n n,\n ).to(device)\n ms_tensordict = ms(tensordict.clone())\n\n assert ms_tensordict.get(\"done\").max() == 1\n\n if n == 1:\n assert_allclose_td(\n tensordict, ms_tensordict.select(*list(tensordict.keys(True, True)))\n )\n\n # assert that done at last step is similar to unterminated traj\n torch.testing.assert_close(\n ms_tensordict.get(\"gamma\")[4], ms_tensordict.get(\"gamma\")[0]\n )\n torch.testing.assert_close(\n ms_tensordict.get((\"next\", key))[4], ms_tensordict.get((\"next\", key))[0]\n )\n torch.testing.assert_close(\n ms_tensordict.get(\"steps_to_next_obs\")[4],\n ms_tensordict.get(\"steps_to_next_obs\")[0],\n )\n\n # check that next obs is properly replaced, or that it is terminated\n next_obs = ms_tensordict.get(key)[:, (ms.n_steps) :]\n true_next_obs = ms_tensordict.get((\"next\", key))[:, : -(ms.n_steps)]\n terminated = ~ms_tensordict.get(\"nonterminal\")\n assert ((next_obs == true_next_obs).all(-1) | terminated[:, (ms.n_steps) :]).all()\n\n # test gamma computation\n torch.testing.assert_close(\n ms_tensordict.get(\"gamma\"), ms.gamma ** ms_tensordict.get(\"steps_to_next_obs\")\n )\n\n # test reward\n if n > 1:\n assert (\n ms_tensordict.get((\"next\", \"reward\"))\n != ms_tensordict.get((\"next\", \"original_reward\"))\n ).any()\n else:\n torch.testing.assert_close(\n ms_tensordict.get((\"next\", \"reward\")),\n ms_tensordict.get((\"next\", \"original_reward\")),\n )" }, { "id": 3945, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_rosen():\n \"\"\"Test Rosenbrock problem with constraints.\"\"\"\n\n x0 = torch.tensor([1., 8.])\n res = minimize(\n rosen, x0,\n method='l-bfgs',\n options=dict(line_search='strong-wolfe'),\n max_iter=50,\n disp=0\n )\n\n\n # Test inactive constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n torch.testing.assert_close(\n res.x, res_constrained_sum.x, rtol=1e-2, atol=1e-2)\n\n res_constrained_norm = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.square().sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n torch.testing.assert_close(\n res.x, res_constrained_norm.x, rtol=1e-2, atol=1e-2)\n\n\n # Test active constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=1.),\n max_iter=50,\n disp=0\n )\n assert res_constrained_sum.x.sum() <= 1.\n res_constrained_norm = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.square().sum(), ub=1.),\n max_iter=50,\n disp=0\n )\n assert res_constrained_norm.x.square().sum() <= 1.", "probing input": "def test_rosen():\n \"\"\"Test Rosenbrock problem with constraints.\"\"\"\n\n x0 = torch.tensor([1., 8.])\n res = minimize(\n rosen, x0,\n method='l-bfgs',\n options=dict(line_search='strong-wolfe'),\n max_iter=50,\n disp=0\n )\n\n\n # Test inactive constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n", "probing input new": "def test_rosen():\n \"\"\"Test Rosenbrock problem with constraints.\"\"\"\n\n x0 = torch.tensor([1., 8.])\n res = minimize(\n rosen, x0,\n method='l-bfgs',\n options=dict(line_search='strong-wolfe'),\n max_iter=50,\n disp=0\n )\n\n\n # Test inactive constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n torch.testing.", "reference": "torch.testing.assert_close(res.x,res_constrained_sum.x,rtol=1e-2,atol=1e-2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(res.x,res_constrained_sum.x,rtol=1e-2,atol=1e-2)", "y_neg": " torch.testing.assert_allclose(res_constrained_sum.x, torch.tensor([1., 8.]))", "retain": "def test_rosen():\n \"\"\"Test Rosenbrock problem with constraints.\"\"\"\n\n x0 = torch.tensor([1., 8.])\n res = minimize(\n rosen, x0,\n method='l-bfgs',\n options=dict(line_search='strong-wolfe'),\n max_iter=50,\n disp=0\n )\n\n\n # Test inactive constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n torch.testing.assert_close(\n res.x, res_constrained_sum.x, rtol=1e-2, atol=1e-2)\n\n res_constrained_norm = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.square().sum(), ub=10.),\n max_iter=50,\n disp=0\n )\n torch.testing.assert_close(\n res.x, res_constrained_norm.x, rtol=1e-2, atol=1e-2)\n\n\n # Test active constraints\n\n res_constrained_sum = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.sum(), ub=1.),\n max_iter=50,\n disp=0\n )\n assert res_constrained_sum.x.sum() <= 1.\n res_constrained_norm = minimize_constr(\n rosen, x0,\n constr=dict(fun=lambda x: x.square().sum(), ub=1.),\n max_iter=50,\n disp=0\n )\n assert res_constrained_norm.x.square().sum() <= 1." }, { "id": 3991, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_linear_forward_backward(\n self,\n feature_vector: torch.Tensor,\n in_features: int,\n out_features: int,\n bias: bool,\n seed: int,\n ) -> None:\n # generate linear layers and initialize\n original_linear = nn.Linear(in_features, out_features, bias=bias)\n combined_linear = CombinedLinear(in_features, out_features, bias=bias)\n\n self._init_weights(original_linear, seed)\n self._init_weights(combined_linear, seed)\n\n # confirm weights are initialized equally\n if bias:\n assert torch.equal(\n original_linear.weight, combined_linear.combined_weight[:, :-1]\n )\n assert torch.equal(\n original_linear.bias, combined_linear.combined_weight[:, -1]\n )\n else:\n assert torch.equal(original_linear.weight, combined_linear.combined_weight)\n\n # perform forward pass\n original_output = original_linear(feature_vector)\n combined_output = combined_linear(feature_vector)\n\n # compute backward of sum of output\n torch.sum(original_output).backward()\n torch.sum(combined_output).backward()\n\n # check values are equal\n with self.subTest(\"Test forward\"):\n torch.testing.assert_close(original_output, combined_output)\n\n with self.subTest(\"Test backward\"):\n if bias:\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.weight.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad)[:, :-1],\n )\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.bias.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad)[:, -1],\n )\n else:\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.weight.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad),\n )", "probing input": " def _test_linear_forward_backward(\n self,\n feature_vector: torch.Tensor,\n in_features: int,\n out_features: int,\n bias: bool,\n seed: int,\n ) -> None:\n # generate linear layers and initialize\n original_linear = nn.Linear(in_features, out_features, bias=bias)\n combined_linear = CombinedLinear(in_features, out_features, bias=bias)\n\n self._init_weights(original_linear, seed)\n self._init_weights(combined_linear, seed)\n\n # confirm weights are initialized equally\n if bias:\n assert torch.equal(\n original_linear.weight, combined_linear.combined_weight[:, :-1]\n )\n assert torch.equal(\n original_linear.bias, combined_linear.combined_weight[:, -1]\n )\n else:\n assert torch.equal(original_linear.weight, combined_linear.combined_weight)\n\n # perform forward pass\n original_output = original_linear(feature_vector)\n combined_output = combined_linear(feature_vector)\n\n # compute backward of sum of output\n torch.sum(original_output).backward()\n torch.sum(combined_output).backward()\n\n # check values are equal\n with self.subTest(\"Test forward\"):\n", "probing input new": " def _test_linear_forward_backward(\n self,\n feature_vector: torch.Tensor,\n in_features: int,\n out_features: int,\n bias: bool,\n seed: int,\n ) -> None:\n # generate linear layers and initialize\n original_linear = nn.Linear(in_features, out_features, bias=bias)\n combined_linear = CombinedLinear(in_features, out_features, bias=bias)\n\n self._init_weights(original_linear, seed)\n self._init_weights(combined_linear, seed)\n\n # confirm weights are initialized equally\n if bias:\n assert torch.equal(\n original_linear.weight, combined_linear.combined_weight[:, :-1]\n )\n assert torch.equal(\n original_linear.bias, combined_linear.combined_weight[:, -1]\n )\n else:\n assert torch.equal(original_linear.weight, combined_linear.combined_weight)\n\n # perform forward pass\n original_output = original_linear(feature_vector)\n combined_output = combined_linear(feature_vector)\n\n # compute backward of sum of output\n torch.sum(original_output).backward()\n torch.sum(combined_output).backward()\n\n # check values are equal\n with self.subTest(\"Test forward\"):\n torch.testing.", "reference": "torch.testing.assert_close(original_output,combined_output)", "reference dict": { "original_linear": "nn.Linear", "combined_linear": "CombinedLinear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(original_output,combined_output)", "y_neg": " torch.testing.assert_allclose(", "retain": " def _test_linear_forward_backward(\n self,\n feature_vector: torch.Tensor,\n in_features: int,\n out_features: int,\n bias: bool,\n seed: int,\n ) -> None:\n # generate linear layers and initialize\n original_linear = nn.Linear(in_features, out_features, bias=bias)\n combined_linear = CombinedLinear(in_features, out_features, bias=bias)\n\n self._init_weights(original_linear, seed)\n self._init_weights(combined_linear, seed)\n\n # confirm weights are initialized equally\n if bias:\n assert torch.equal(\n original_linear.weight, combined_linear.combined_weight[:, :-1]\n )\n assert torch.equal(\n original_linear.bias, combined_linear.combined_weight[:, -1]\n )\n else:\n assert torch.equal(original_linear.weight, combined_linear.combined_weight)\n\n # perform forward pass\n original_output = original_linear(feature_vector)\n combined_output = combined_linear(feature_vector)\n\n # compute backward of sum of output\n torch.sum(original_output).backward()\n torch.sum(combined_output).backward()\n\n # check values are equal\n with self.subTest(\"Test forward\"):\n torch.testing.assert_close(original_output, combined_output)\n\n with self.subTest(\"Test backward\"):\n if bias:\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.weight.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad)[:, :-1],\n )\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.bias.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad)[:, -1],\n )\n else:\n torch.testing.assert_close(\n cast(torch.Tensor, original_linear.weight.grad),\n cast(torch.Tensor, combined_linear.combined_weight.grad),\n )" }, { "id": 4004, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_relabeltargetinbatch(self):\n \"\"\"Check target is relabed using teacher\"\"\"\n teacher = DivideInputDictBy2()\n teacher.eval()\n teacher.device = torch.device(\"cpu\")\n relabeler = RelabelTargetInBatch(teacher=teacher)\n batched_inputs = _get_input_data(n=2, use_input_target=True)\n gt = [{\"input\": d[\"input\"], \"target\": d[\"input\"] / 2.0} for d in batched_inputs]\n outputs = relabeler.label(batched_inputs)\n torch.testing.assert_close(outputs, gt)", "probing input": " def test_relabeltargetinbatch(self):\n \"\"\"Check target is relabed using teacher\"\"\"\n teacher = DivideInputDictBy2()\n teacher.eval()\n teacher.device = torch.device(\"cpu\")\n relabeler = RelabelTargetInBatch(teacher=teacher)\n batched_inputs = _get_input_data(n=2, use_input_target=True)\n gt = [{\"input\": d[\"input\"], \"target\": d[\"input\"] / 2.0} for d in batched_inputs]\n outputs = relabeler.label(batched_inputs)\n", "probing input new": " def test_relabeltargetinbatch(self):\n \"\"\"Check target is relabed using teacher\"\"\"\n teacher = DivideInputDictBy2()\n teacher.eval()\n teacher.device = torch.device(\"cpu\")\n relabeler = RelabelTargetInBatch(teacher=teacher)\n batched_inputs = _get_input_data(n=2, use_input_target=True)\n gt = [{\"input\": d[\"input\"], \"target\": d[\"input\"] / 2.0} for d in batched_inputs]\n outputs = relabeler.label(batched_inputs)\n torch.testing.", "reference": "torch.testing.assert_close(outputs,gt)", "reference dict": { "teacher": "DivideInputDictBy2", "relabeler": "RelabelTargetInBatch" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(outputs,gt)", "y_neg": " torch.testing.assert_allclose(outputs[\"target\"], gt)", "retain": " def test_relabeltargetinbatch(self):\n \"\"\"Check target is relabed using teacher\"\"\"\n teacher = DivideInputDictBy2()\n teacher.eval()\n teacher.device = torch.device(\"cpu\")\n relabeler = RelabelTargetInBatch(teacher=teacher)\n batched_inputs = _get_input_data(n=2, use_input_target=True)\n gt = [{\"input\": d[\"input\"], \"target\": d[\"input\"] / 2.0} for d in batched_inputs]\n outputs = relabeler.label(batched_inputs)\n torch.testing.assert_close(outputs, gt)" }, { "id": 4064, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _make_model_unit_test(\n self,\n model,\n *args,\n input_shape=None,\n enable_allclose=False,\n **kwargs,\n ):\n \"\"\"\n Test that the model can be traced correctly and is producing correct\n result.\n \"\"\"\n if input_shape is None:\n input_shape = [1, 3, 224, 224]\n input = torch.randn(input_shape)\n traced = acc_tracer.trace(model, [input])\n if enable_allclose:\n torch.testing.assert_close(model(input), traced(input))\n else:\n self.assertTrue(torch.equal(model(input), traced(input)))\n traced_again = acc_tracer.trace(traced, [input])\n if enable_allclose:\n torch.testing.assert_close(model(input), traced_again(input))\n else:\n self.assertTrue(torch.equal(model(input), traced_again(input)))", "probing input": " def _make_model_unit_test(\n self,\n model,\n *args,\n input_shape=None,\n enable_allclose=False,\n **kwargs,\n ):\n \"\"\"\n Test that the model can be traced correctly and is producing correct\n result.\n \"\"\"\n if input_shape is None:\n input_shape = [1, 3, 224, 224]\n input = torch.randn(input_shape)\n traced = acc_tracer.trace(model, [input])\n if enable_allclose:\n", "probing input new": " def _make_model_unit_test(\n self,\n model,\n *args,\n input_shape=None,\n enable_allclose=False,\n **kwargs,\n ):\n \"\"\"\n Test that the model can be traced correctly and is producing correct\n result.\n \"\"\"\n if input_shape is None:\n input_shape = [1, 3, 224, 224]\n input = torch.randn(input_shape)\n traced = acc_tracer.trace(model, [input])\n if enable_allclose:\n torch.testing.", "reference": "torch.testing.assert_close(model(input),traced(input))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(model(input),traced(input))", "y_neg": " torch.testing.assert_allclose(", "retain": " def _make_model_unit_test(\n self,\n model,\n *args,\n input_shape=None,\n enable_allclose=False,\n **kwargs,\n ):\n \"\"\"\n Test that the model can be traced correctly and is producing correct\n result.\n \"\"\"\n if input_shape is None:\n input_shape = [1, 3, 224, 224]\n input = torch.randn(input_shape)\n traced = acc_tracer.trace(model, [input])\n if enable_allclose:\n torch.testing.assert_close(model(input), traced(input))\n else:\n self.assertTrue(torch.equal(model(input), traced(input)))\n traced_again = acc_tracer.trace(traced, [input])\n if enable_allclose:\n torch.testing.assert_close(model(input), traced_again(input))\n else:\n self.assertTrue(torch.equal(model(input), traced_again(input)))" }, { "id": 4102, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_opt_with_module(\n self,\n module: torch.nn.Module,\n inputs: List,\n opt: Callable,\n should_change_graph: bool,\n deleted_ops: Dict = None,\n created_ops: Dict = None,\n rtol: float = None,\n atol: float = None,\n ):\n assert should_change_graph or not bool(deleted_ops or created_ops)\n deleted_ops = deleted_ops or {}\n created_ops = created_ops or {}\n module.eval()\n\n # Before Opt\n before_results = module(*inputs)\n mod_traced = acc_tracer.trace(module, inputs)\n before_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model before opt.\")\n debug_print_graph_module(mod_traced)\n\n # Apply Opt\n graph_changed = bool(opt(mod_traced))\n\n # After Opt\n after_results = mod_traced(*inputs)\n after_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model after opt.\")\n mod_traced.recompile()\n debug_print_graph_module(mod_traced)\n\n # Tests\n # * Numerics\n tol_args = {}\n if rtol is not None:\n tol_args[\"rtol\"] = rtol\n if atol is not None:\n tol_args[\"atol\"] = atol\n torch.testing.assert_close(before_results, after_results, **tol_args)\n\n # * opt changes graph\n self.assertEqual(graph_changed, before_node_list != after_node_list)\n self.assertEqual(should_change_graph, graph_changed)\n\n # * modified nodes\n before_node_set = set(before_node_list)\n after_node_set = set(after_node_list)\n self.assertEqual(\n dict(Counter([node.target for node in before_node_set - after_node_set])),\n deleted_ops,\n )\n self.assertEqual(\n dict(Counter([node.target for node in after_node_set - before_node_set])),\n created_ops,\n )\n\n return mod_traced", "probing input": " def _test_opt_with_module(\n self,\n module: torch.nn.Module,\n inputs: List,\n opt: Callable,\n should_change_graph: bool,\n deleted_ops: Dict = None,\n created_ops: Dict = None,\n rtol: float = None,\n atol: float = None,\n ):\n assert should_change_graph or not bool(deleted_ops or created_ops)\n deleted_ops = deleted_ops or {}\n created_ops = created_ops or {}\n module.eval()\n\n # Before Opt\n before_results = module(*inputs)\n mod_traced = acc_tracer.trace(module, inputs)\n before_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model before opt.\")\n debug_print_graph_module(mod_traced)\n\n # Apply Opt\n graph_changed = bool(opt(mod_traced))\n\n # After Opt\n after_results = mod_traced(*inputs)\n after_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model after opt.\")\n mod_traced.recompile()\n debug_print_graph_module(mod_traced)\n\n # Tests\n # * Numerics\n tol_args = {}\n if rtol is not None:\n tol_args[\"rtol\"] = rtol\n if atol is not None:\n tol_args[\"atol\"] = atol\n", "probing input new": " def _test_opt_with_module(\n self,\n module: torch.nn.Module,\n inputs: List,\n opt: Callable,\n should_change_graph: bool,\n deleted_ops: Dict = None,\n created_ops: Dict = None,\n rtol: float = None,\n atol: float = None,\n ):\n assert should_change_graph or not bool(deleted_ops or created_ops)\n deleted_ops = deleted_ops or {}\n created_ops = created_ops or {}\n module.eval()\n\n # Before Opt\n before_results = module(*inputs)\n mod_traced = acc_tracer.trace(module, inputs)\n before_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model before opt.\")\n debug_print_graph_module(mod_traced)\n\n # Apply Opt\n graph_changed = bool(opt(mod_traced))\n\n # After Opt\n after_results = mod_traced(*inputs)\n after_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model after opt.\")\n mod_traced.recompile()\n debug_print_graph_module(mod_traced)\n\n # Tests\n # * Numerics\n tol_args = {}\n if rtol is not None:\n tol_args[\"rtol\"] = rtol\n if atol is not None:\n tol_args[\"atol\"] = atol\n torch.testing.", "reference": "torch.testing.assert_close(before_results,after_results,**tol_args)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(before_results,after_results,**tol_args)", "y_neg": " torch.testing.assert_allclose(before_results, after_results, **tol_args)", "retain": " def _test_opt_with_module(\n self,\n module: torch.nn.Module,\n inputs: List,\n opt: Callable,\n should_change_graph: bool,\n deleted_ops: Dict = None,\n created_ops: Dict = None,\n rtol: float = None,\n atol: float = None,\n ):\n assert should_change_graph or not bool(deleted_ops or created_ops)\n deleted_ops = deleted_ops or {}\n created_ops = created_ops or {}\n module.eval()\n\n # Before Opt\n before_results = module(*inputs)\n mod_traced = acc_tracer.trace(module, inputs)\n before_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model before opt.\")\n debug_print_graph_module(mod_traced)\n\n # Apply Opt\n graph_changed = bool(opt(mod_traced))\n\n # After Opt\n after_results = mod_traced(*inputs)\n after_node_list = list(mod_traced.graph.nodes)\n _LOGGER.info(\"Model after opt.\")\n mod_traced.recompile()\n debug_print_graph_module(mod_traced)\n\n # Tests\n # * Numerics\n tol_args = {}\n if rtol is not None:\n tol_args[\"rtol\"] = rtol\n if atol is not None:\n tol_args[\"atol\"] = atol\n torch.testing.assert_close(before_results, after_results, **tol_args)\n\n # * opt changes graph\n self.assertEqual(graph_changed, before_node_list != after_node_list)\n self.assertEqual(should_change_graph, graph_changed)\n\n # * modified nodes\n before_node_set = set(before_node_list)\n after_node_set = set(after_node_list)\n self.assertEqual(\n dict(Counter([node.target for node in before_node_set - after_node_set])),\n deleted_ops,\n )\n self.assertEqual(\n dict(Counter([node.target for node in after_node_set - before_node_set])),\n created_ops,\n )\n\n return mod_traced" }, { "id": 4273, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "if MAIN:\n\tprint(gpt2_small.to_str_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_string([50256, 70, 457, 17]))\n\n# %%\n\n\nif MAIN:\n\tlogits: Tensor = gpt2_small(model_description_text, return_type=\"logits\")\n\tprediction = logits.argmax(dim=-1).squeeze()[:-1]\n\t# FLAT SOLUTION\n\t# YOUR CODE HERE - get the model's prediction on the text\n\ttrue_tokens = gpt2_small.to_tokens(model_description_text).squeeze()[1:]\n\tis_correct = (prediction == true_tokens)\n\t\n\tprint(f\"Model accuracy: {is_correct.sum()}/{len(true_tokens)}\")\n\tprint(f\"Correct words: {gpt2_small.to_str_tokens(prediction[is_correct])}\")\n\n# %%\n\n\nif MAIN:\n\tgpt2_text = \"Natural language processing tasks, such as question answering, machine translation, reading comprehension, and summarization, are typically approached with supervised learning on taskspecific datasets.\"\n\tgpt2_tokens = gpt2_small.to_tokens(gpt2_text)\n\tgpt2_logits, gpt2_cache = gpt2_small.run_with_cache(gpt2_tokens, remove_batch_dim=True)\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0 = gpt2_cache[\"pattern\", 0]\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0_copy = gpt2_cache[\"blocks.0.attn.hook_pattern\"]\n\t\n\tt.testing.assert_close(attn_patterns_layer_0, attn_patterns_layer_0_copy)", "probing input": "if MAIN:\n\tprint(gpt2_small.to_str_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_string([50256, 70, 457, 17]))\n\n# %%\n\n\nif MAIN:\n\tlogits: Tensor = gpt2_small(model_description_text, return_type=\"logits\")\n\tprediction = logits.argmax(dim=-1).squeeze()[:-1]\n\t# FLAT SOLUTION\n\t# YOUR CODE HERE - get the model's prediction on the text\n\ttrue_tokens = gpt2_small.to_tokens(model_description_text).squeeze()[1:]\n\tis_correct = (prediction == true_tokens)\n\t\n\tprint(f\"Model accuracy: {is_correct.sum()}/{len(true_tokens)}\")\n\tprint(f\"Correct words: {gpt2_small.to_str_tokens(prediction[is_correct])}\")\n\n# %%\n\n\nif MAIN:\n\tgpt2_text = \"Natural language processing tasks, such as question answering, machine translation, reading comprehension, and summarization, are typically approached with supervised learning on taskspecific datasets.\"\n\tgpt2_tokens = gpt2_small.to_tokens(gpt2_text)\n\tgpt2_logits, gpt2_cache = gpt2_small.run_with_cache(gpt2_tokens, remove_batch_dim=True)\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0 = gpt2_cache[\"pattern\", 0]\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0_copy = gpt2_cache[\"blocks.0.attn.hook_pattern\"]\n", "probing input new": "if MAIN:\n\tprint(gpt2_small.to_str_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_string([50256, 70, 457, 17]))\n\n# %%\n\n\nif MAIN:\n\tlogits: Tensor = gpt2_small(model_description_text, return_type=\"logits\")\n\tprediction = logits.argmax(dim=-1).squeeze()[:-1]\n\t# FLAT SOLUTION\n\t# YOUR CODE HERE - get the model's prediction on the text\n\ttrue_tokens = gpt2_small.to_tokens(model_description_text).squeeze()[1:]\n\tis_correct = (prediction == true_tokens)\n\t\n\tprint(f\"Model accuracy: {is_correct.sum()}/{len(true_tokens)}\")\n\tprint(f\"Correct words: {gpt2_small.to_str_tokens(prediction[is_correct])}\")\n\n# %%\n\n\nif MAIN:\n\tgpt2_text = \"Natural language processing tasks, such as question answering, machine translation, reading comprehension, and summarization, are typically approached with supervised learning on taskspecific datasets.\"\n\tgpt2_tokens = gpt2_small.to_tokens(gpt2_text)\n\tgpt2_logits, gpt2_cache = gpt2_small.run_with_cache(gpt2_tokens, remove_batch_dim=True)\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0 = gpt2_cache[\"pattern\", 0]\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0_copy = gpt2_cache[\"blocks.0.attn.hook_pattern\"]\n\t\n\tt.testing.", "reference": "t.testing.assert_close(attn_patterns_layer_0,attn_patterns_layer_0_copy)", "reference dict": {}, "alias dict": { "t.potri": "torch.potri", "t.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "t.potrs": "torch.potrs", "t.qr": "torch.qr", "t.lu_solve": "torch.lu_solve", "t.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "t.symeig": "torch.symeig", "t.func.functional_call": "torch.func.functional_call", "t.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "t.solve": "torch.solve", "t.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "t.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "t.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "t.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "t.lu_unpack": "torch.lu_unpack", "t.btrisolve": "torch.btrisolve", "t.linalg.lu_factor": "torch.linalg.lu_factor", "t.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "t.linalg.matrix_rank": "torch.linalg.matrix_rank", "t.norm": "torch.norm", "t.cholesky_solve": "torch.cholesky_solve", "t.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "t.testing.assert_allclose": "torch.testing.assert_allclose", "t.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "t.gels": "torch.gels", "t.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "t.chain_matmul": "torch.chain_matmul", "t.lu": "torch.lu", "t.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "t.pstrf": "torch.pstrf", "t.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "t.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "t.linalg.eigh": "torch.linalg.eigh", "t.btrifact": "torch.btrifact", "t.linalg.lu_solve": "torch.linalg.lu_solve", "t.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "t.linalg.multi_dot": "torch.linalg.multi_dot", "t.gesv": "torch.gesv", "t.btrifact_with_info": "torch.btrifact_with_info", "t.linalg.solve": "torch.linalg.solve", "t.linalg.eig": "torch.linalg.eig", "t.linalg.cholesky": "torch.linalg.cholesky", "t.trtrs": "torch.trtrs", "t.linalg.solve_triangular": "torch.linalg.solve_triangular", "t.matrix_rank": "torch.matrix_rank", "t.triangular_solve": "torch.triangular_solve", "t.linalg.qr": "torch.linalg.qr", "t.svd": "torch.svd", "t.lstsq": "torch.lstsq", "t.nn.functional.interpolate": "torch.nn.functional.interpolate", "t.potrf": "torch.potrf", "t.linalg.svd": "torch.linalg.svd", "t.btriunpack": "torch.btriunpack", "t.eig": "torch.eig", "t.cholesky_inverse": "torch.cholesky_inverse", "t.testing.assert_close": "torch.testing.assert_close", "t.cholesky": "torch.cholesky", "t.nn.functional.upsample": "torch.nn.functional.upsample", "t.linalg.norm": "torch.linalg.norm", "t.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "t.testing.assert_close", "y_pos": "t.testing.assert_close(attn_patterns_layer_0,attn_patterns_layer_0_copy)", "y_neg": "\tt.testing.assert_allclose(attn_patterns_layer_0, attn_patterns_layer_0_copy)", "retain": "if MAIN:\n\tprint(gpt2_small.to_str_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_tokens(\"gpt2\"))\n\tprint(gpt2_small.to_string([50256, 70, 457, 17]))\n\n# %%\n\n\nif MAIN:\n\tlogits: Tensor = gpt2_small(model_description_text, return_type=\"logits\")\n\tprediction = logits.argmax(dim=-1).squeeze()[:-1]\n\t# FLAT SOLUTION\n\t# YOUR CODE HERE - get the model's prediction on the text\n\ttrue_tokens = gpt2_small.to_tokens(model_description_text).squeeze()[1:]\n\tis_correct = (prediction == true_tokens)\n\t\n\tprint(f\"Model accuracy: {is_correct.sum()}/{len(true_tokens)}\")\n\tprint(f\"Correct words: {gpt2_small.to_str_tokens(prediction[is_correct])}\")\n\n# %%\n\n\nif MAIN:\n\tgpt2_text = \"Natural language processing tasks, such as question answering, machine translation, reading comprehension, and summarization, are typically approached with supervised learning on taskspecific datasets.\"\n\tgpt2_tokens = gpt2_small.to_tokens(gpt2_text)\n\tgpt2_logits, gpt2_cache = gpt2_small.run_with_cache(gpt2_tokens, remove_batch_dim=True)\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0 = gpt2_cache[\"pattern\", 0]\n\n# %%\n\n\nif MAIN:\n\tattn_patterns_layer_0_copy = gpt2_cache[\"blocks.0.attn.hook_pattern\"]\n\t\n\tt.testing.assert_close(attn_patterns_layer_0, attn_patterns_layer_0_copy)" }, { "id": 4407, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_robust_cost_grad_form(batch_size, loss_cls):\n generator = torch.Generator()\n generator.manual_seed(0)\n for _ in range(10):\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n generator,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n cf = robust_cf.cost_function\n jacs, e = cf.weighted_jacobians_error()\n cf_grad = _grad(jacs[0], e)\n e_norm = (e * e).sum(1, keepdim=True)\n rho_prime = _loss_linearize(robust_cf, loss_cls, e_norm)\n # `weighted_jacobians_error()` is written so that it results in a\n # gradient equal to drho_de2 * J^T * e, which in the code is\n # `rho_prime * cf_grad`.\n expected_grad = rho_prime.view(-1, 1, 1) * cf_grad\n rescaled_jac, rescaled_e = robust_cf.weighted_jacobians_error()\n grad = _grad(rescaled_jac[0], rescaled_e)\n torch.testing.assert_close(grad, expected_grad, atol=1e-6, rtol=1e-6)", "probing input": "def test_robust_cost_grad_form(batch_size, loss_cls):\n generator = torch.Generator()\n generator.manual_seed(0)\n for _ in range(10):\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n generator,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n cf = robust_cf.cost_function\n jacs, e = cf.weighted_jacobians_error()\n cf_grad = _grad(jacs[0], e)\n e_norm = (e * e).sum(1, keepdim=True)\n rho_prime = _loss_linearize(robust_cf, loss_cls, e_norm)\n # `weighted_jacobians_error()` is written so that it results in a\n # gradient equal to drho_de2 * J^T * e, which in the code is\n # `rho_prime * cf_grad`.\n expected_grad = rho_prime.view(-1, 1, 1) * cf_grad\n rescaled_jac, rescaled_e = robust_cf.weighted_jacobians_error()\n grad = _grad(rescaled_jac[0], rescaled_e)\n", "probing input new": "def test_robust_cost_grad_form(batch_size, loss_cls):\n generator = torch.Generator()\n generator.manual_seed(0)\n for _ in range(10):\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n generator,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n cf = robust_cf.cost_function\n jacs, e = cf.weighted_jacobians_error()\n cf_grad = _grad(jacs[0], e)\n e_norm = (e * e).sum(1, keepdim=True)\n rho_prime = _loss_linearize(robust_cf, loss_cls, e_norm)\n # `weighted_jacobians_error()` is written so that it results in a\n # gradient equal to drho_de2 * J^T * e, which in the code is\n # `rho_prime * cf_grad`.\n expected_grad = rho_prime.view(-1, 1, 1) * cf_grad\n rescaled_jac, rescaled_e = robust_cf.weighted_jacobians_error()\n grad = _grad(rescaled_jac[0], rescaled_e)\n torch.testing.", "reference": "torch.testing.assert_close(grad,expected_grad,atol=1e-6,rtol=1e-6)", "reference dict": { "generator": "torch.Generator" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(grad,expected_grad,atol=1e-6,rtol=1e-6)", "y_neg": " torch.testing.assert_allclose(grad, expected_grad, rtol=1e-5)", "retain": "def test_robust_cost_grad_form(batch_size, loss_cls):\n generator = torch.Generator()\n generator.manual_seed(0)\n for _ in range(10):\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n generator,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n cf = robust_cf.cost_function\n jacs, e = cf.weighted_jacobians_error()\n cf_grad = _grad(jacs[0], e)\n e_norm = (e * e).sum(1, keepdim=True)\n rho_prime = _loss_linearize(robust_cf, loss_cls, e_norm)\n # `weighted_jacobians_error()` is written so that it results in a\n # gradient equal to drho_de2 * J^T * e, which in the code is\n # `rho_prime * cf_grad`.\n expected_grad = rho_prime.view(-1, 1, 1) * cf_grad\n rescaled_jac, rescaled_e = robust_cf.weighted_jacobians_error()\n grad = _grad(rescaled_jac[0], rescaled_e)\n torch.testing.assert_close(grad, expected_grad, atol=1e-6, rtol=1e-6)" }, { "id": 4408, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_mask_jacobians(loss_cls):\n batch_size = 512\n rng = torch.Generator()\n rng.manual_seed(0)\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n rng,\n masked_weight=True,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n jac_expected, err_expected = robust_cf.weighted_jacobians_error()\n robust_cf._supports_masking = True\n jac, err = robust_cf.weighted_jacobians_error()\n torch.testing.assert_close(err, err_expected)\n for j1, j2 in zip(jac, jac_expected):\n torch.testing.assert_close(j1, j2)", "probing input": "def test_mask_jacobians(loss_cls):\n batch_size = 512\n rng = torch.Generator()\n rng.manual_seed(0)\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n rng,\n masked_weight=True,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n jac_expected, err_expected = robust_cf.weighted_jacobians_error()\n robust_cf._supports_masking = True\n jac, err = robust_cf.weighted_jacobians_error()\n", "probing input new": "def test_mask_jacobians(loss_cls):\n batch_size = 512\n rng = torch.Generator()\n rng.manual_seed(0)\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n rng,\n masked_weight=True,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n jac_expected, err_expected = robust_cf.weighted_jacobians_error()\n robust_cf._supports_masking = True\n jac, err = robust_cf.weighted_jacobians_error()\n torch.testing.", "reference": "torch.testing.assert_close(err,err_expected)", "reference dict": { "rng": "torch.Generator" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(err,err_expected)", "y_neg": " torch.testing.assert_allclose(jac, jac_expected, rtol=1e-5)", "retain": "def test_mask_jacobians(loss_cls):\n batch_size = 512\n rng = torch.Generator()\n rng.manual_seed(0)\n robust_cf = _new_robust_cf(\n batch_size,\n loss_cls,\n rng,\n masked_weight=True,\n gnc_cost=issubclass(loss_cls, th.GemanMcClureLoss),\n )\n jac_expected, err_expected = robust_cf.weighted_jacobians_error()\n robust_cf._supports_masking = True\n jac, err = robust_cf.weighted_jacobians_error()\n torch.testing.assert_close(err, err_expected)\n for j1, j2 in zip(jac, jac_expected):\n torch.testing.assert_close(j1, j2)" }, { "id": 4480, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def register_quantization_mapping_with_decorator_example():\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n print(module)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, n_clss))", "probing input": "def register_quantization_mapping_with_decorator_example():\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n print(module)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n", "probing input new": "def register_quantization_mapping_with_decorator_example():\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n print(module)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.", "reference": "torch.testing.assert_close(y.size(),(1,n_clss))", "reference dict": { "module": "MyModel", "q_util": "SelectiveQuantizer", "self.flatten": "nn.Flatten", "self.linear": "quant_nn.QuantLinear", "self.conv": "nn.Conv2d", "self.my_block": "MyBlock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(y.size(),(1,n_clss))", "y_neg": " torch.testing.assert_allclose(y, module(x))", "retain": "def register_quantization_mapping_with_decorator_example():\n # ARRANGE\n class MyBlock(nn.Module):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.in_feats = in_feats\n self.out_feats = out_feats\n self.flatten = nn.Flatten()\n self.linear = nn.Linear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n @register_quantized_module(float_source=MyBlock)\n class MyQuantizedBlock(SGQuantMixin):\n def __init__(self, in_feats, out_feats) -> None:\n super().__init__()\n self.flatten = nn.Flatten()\n self.linear = quant_nn.QuantLinear(in_feats, out_feats)\n\n def forward(self, x):\n return self.linear(self.flatten(x))\n\n class MyModel(nn.Module):\n def __init__(self, res, n_classes) -> None:\n super().__init__()\n self.conv = nn.Conv2d(3, 4, kernel_size=3, padding=1)\n self.my_block = MyBlock(4 * (res**2), n_classes)\n\n def forward(self, x):\n y = self.conv(x)\n return self.my_block(y)\n\n res = 32\n n_clss = 10\n module = MyModel(res, n_clss)\n\n # TEST\n q_util = SelectiveQuantizer()\n q_util.quantize_module(module)\n\n x = torch.rand(1, 3, res, res)\n\n print(module)\n\n # ASSERT\n with torch.no_grad():\n y = module(x)\n torch.testing.assert_close(y.size(), (1, n_clss))" }, { "id": 4526, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_pad(self, fill):\n height = random.randint(10, 32) * 2\n width = random.randint(10, 32) * 2\n img = torch.ones(3, height, width, dtype=torch.uint8)\n padding = random.randint(1, 20)\n result = transforms.Compose(\n [\n transforms.ToPILImage(),\n transforms.Pad(padding, fill=fill),\n transforms.PILToTensor(),\n ]\n )(img)\n assert result.size(1) == height + 2 * padding\n assert result.size(2) == width + 2 * padding\n # check that all elements in the padded region correspond\n # to the pad value\n h_padded = result[:, :padding, :]\n w_padded = result[:, :, :padding]\n torch.testing.assert_close(h_padded, torch.full_like(h_padded, fill_value=fill), rtol=0.0, atol=0.0)\n torch.testing.assert_close(w_padded, torch.full_like(w_padded, fill_value=fill), rtol=0.0, atol=0.0)\n pytest.raises(ValueError, transforms.Pad(padding, fill=(1, 2)), transforms.ToPILImage()(img))", "probing input": " def test_pad(self, fill):\n height = random.randint(10, 32) * 2\n width = random.randint(10, 32) * 2\n img = torch.ones(3, height, width, dtype=torch.uint8)\n padding = random.randint(1, 20)\n result = transforms.Compose(\n [\n transforms.ToPILImage(),\n transforms.Pad(padding, fill=fill),\n transforms.PILToTensor(),\n ]\n )(img)\n assert result.size(1) == height + 2 * padding\n assert result.size(2) == width + 2 * padding\n # check that all elements in the padded region correspond\n # to the pad value\n h_padded = result[:, :padding, :]\n w_padded = result[:, :, :padding]\n", "probing input new": " def test_pad(self, fill):\n height = random.randint(10, 32) * 2\n width = random.randint(10, 32) * 2\n img = torch.ones(3, height, width, dtype=torch.uint8)\n padding = random.randint(1, 20)\n result = transforms.Compose(\n [\n transforms.ToPILImage(),\n transforms.Pad(padding, fill=fill),\n transforms.PILToTensor(),\n ]\n )(img)\n assert result.size(1) == height + 2 * padding\n assert result.size(2) == width + 2 * padding\n # check that all elements in the padded region correspond\n # to the pad value\n h_padded = result[:, :padding, :]\n w_padded = result[:, :, :padding]\n torch.testing.", "reference": "torch.testing.assert_close(h_padded,torch.full_like(h_padded,fill_value=fill),rtol=0.0,atol=0.0)", "reference dict": { "result": "transforms.Compose(\n [\n transforms.ToPILImage(),\n transforms.Pad(padding, fill=fill),\n transforms.PILToTensor(),\n ]\n )" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(h_padded,torch.full_like(h_padded,fill_value=fill),rtol=0.0,atol=0.0)", "y_neg": " torch.testing.assert_allclose(h_padded, fill)", "retain": " def test_pad(self, fill):\n height = random.randint(10, 32) * 2\n width = random.randint(10, 32) * 2\n img = torch.ones(3, height, width, dtype=torch.uint8)\n padding = random.randint(1, 20)\n result = transforms.Compose(\n [\n transforms.ToPILImage(),\n transforms.Pad(padding, fill=fill),\n transforms.PILToTensor(),\n ]\n )(img)\n assert result.size(1) == height + 2 * padding\n assert result.size(2) == width + 2 * padding\n # check that all elements in the padded region correspond\n # to the pad value\n h_padded = result[:, :padding, :]\n w_padded = result[:, :, :padding]\n torch.testing.assert_close(h_padded, torch.full_like(h_padded, fill_value=fill), rtol=0.0, atol=0.0)\n torch.testing.assert_close(w_padded, torch.full_like(w_padded, fill_value=fill), rtol=0.0, atol=0.0)\n pytest.raises(ValueError, transforms.Pad(padding, fill=(1, 2)), transforms.ToPILImage()(img))" }, { "id": 4531, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_2_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 2).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"LA\" # default should assume LA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(2):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))", "probing input": " def test_2_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 2).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"LA\" # default should assume LA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(2):\n", "probing input new": " def test_2_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 2).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"LA\" # default should assume LA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(2):\n torch.testing.", "reference": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "reference dict": { "img": "transforms.ToPILImage(mode=expected_mode)" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "y_neg": " torch.testing.assert_allclose(", "retain": " def test_2_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 2).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"LA\" # default should assume LA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(2):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))" }, { "id": 4535, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_3_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 3).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGB\" # default should assume RGB\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(3):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))", "probing input": " def test_3_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 3).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGB\" # default should assume RGB\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(3):\n", "probing input new": " def test_3_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 3).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGB\" # default should assume RGB\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(3):\n torch.testing.", "reference": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "reference dict": { "img": "transforms.ToPILImage(mode=expected_mode)" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "y_neg": " torch.testing.assert_allclose(", "retain": " def test_3_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 3).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGB\" # default should assume RGB\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(3):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))" }, { "id": 4537, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_4_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 4).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGBA\" # default should assume RGBA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(4):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))", "probing input": " def test_4_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 4).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGBA\" # default should assume RGBA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(4):\n", "probing input new": " def test_4_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 4).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGBA\" # default should assume RGBA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(4):\n torch.testing.", "reference": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "reference dict": { "img": "transforms.ToPILImage(mode=expected_mode)" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(img_data[:,:,i],np.asarray(split[i]))", "y_neg": " torch.testing.assert_allclose(", "retain": " def test_4_channel_ndarray_to_pil_image(self, expected_mode):\n img_data = torch.ByteTensor(4, 4, 4).random_(0, 255).numpy()\n\n if expected_mode is None:\n img = transforms.ToPILImage()(img_data)\n assert img.mode == \"RGBA\" # default should assume RGBA\n else:\n img = transforms.ToPILImage(mode=expected_mode)(img_data)\n assert img.mode == expected_mode\n split = img.split()\n for i in range(4):\n torch.testing.assert_close(img_data[:, :, i], np.asarray(split[i]))" }, { "id": 4578, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_max_value_writer_serialize(\n self, size, batch_size, reward_ranges, device, tmpdir\n ):\n rb = TensorDictReplayBuffer(\n storage=LazyTensorStorage(size, device=device),\n sampler=SamplerWithoutReplacement(),\n batch_size=batch_size,\n writer=TensorDictMaxValueWriter(rank_key=\"key\"),\n )\n\n max_reward1, max_reward2, max_reward3 = reward_ranges\n\n td = TensorDict(\n {\n \"key\": torch.clamp_max(torch.rand(size), max=max_reward1),\n \"obs\": torch.rand(size),\n },\n batch_size=size,\n device=device,\n )\n rb.extend(td)\n rb._writer.dumps(tmpdir)\n # check we can dump twice\n rb._writer.dumps(tmpdir)\n other = TensorDictMaxValueWriter(rank_key=\"key\")\n other.loads(tmpdir)\n assert len(rb._writer._current_top_values) == len(other._current_top_values)\n torch.testing.assert_close(\n torch.tensor(rb._writer._current_top_values),\n torch.tensor(other._current_top_values),\n )", "probing input": " def test_max_value_writer_serialize(\n self, size, batch_size, reward_ranges, device, tmpdir\n ):\n rb = TensorDictReplayBuffer(\n storage=LazyTensorStorage(size, device=device),\n sampler=SamplerWithoutReplacement(),\n batch_size=batch_size,\n writer=TensorDictMaxValueWriter(rank_key=\"key\"),\n )\n\n max_reward1, max_reward2, max_reward3 = reward_ranges\n\n td = TensorDict(\n {\n \"key\": torch.clamp_max(torch.rand(size), max=max_reward1),\n \"obs\": torch.rand(size),\n },\n batch_size=size,\n device=device,\n )\n rb.extend(td)\n rb._writer.dumps(tmpdir)\n # check we can dump twice\n rb._writer.dumps(tmpdir)\n other = TensorDictMaxValueWriter(rank_key=\"key\")\n other.loads(tmpdir)\n assert len(rb._writer._current_top_values) == len(other._current_top_values)\n", "probing input new": " def test_max_value_writer_serialize(\n self, size, batch_size, reward_ranges, device, tmpdir\n ):\n rb = TensorDictReplayBuffer(\n storage=LazyTensorStorage(size, device=device),\n sampler=SamplerWithoutReplacement(),\n batch_size=batch_size,\n writer=TensorDictMaxValueWriter(rank_key=\"key\"),\n )\n\n max_reward1, max_reward2, max_reward3 = reward_ranges\n\n td = TensorDict(\n {\n \"key\": torch.clamp_max(torch.rand(size), max=max_reward1),\n \"obs\": torch.rand(size),\n },\n batch_size=size,\n device=device,\n )\n rb.extend(td)\n rb._writer.dumps(tmpdir)\n # check we can dump twice\n rb._writer.dumps(tmpdir)\n other = TensorDictMaxValueWriter(rank_key=\"key\")\n other.loads(tmpdir)\n assert len(rb._writer._current_top_values) == len(other._current_top_values)\n torch.testing.", "reference": "torch.testing.assert_close(torch.tensor(rb._writer._current_top_values),torch.tensor(other._current_top_values),)", "reference dict": { "rb": "TensorDictReplayBuffer", "td": "TensorDict", "other": "TensorDictMaxValueWriter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(torch.tensor(rb._writer._current_top_values),torch.tensor(other._current_top_values),)", "y_neg": " torch.testing.assert_allclose(", "retain": " def test_max_value_writer_serialize(\n self, size, batch_size, reward_ranges, device, tmpdir\n ):\n rb = TensorDictReplayBuffer(\n storage=LazyTensorStorage(size, device=device),\n sampler=SamplerWithoutReplacement(),\n batch_size=batch_size,\n writer=TensorDictMaxValueWriter(rank_key=\"key\"),\n )\n\n max_reward1, max_reward2, max_reward3 = reward_ranges\n\n td = TensorDict(\n {\n \"key\": torch.clamp_max(torch.rand(size), max=max_reward1),\n \"obs\": torch.rand(size),\n },\n batch_size=size,\n device=device,\n )\n rb.extend(td)\n rb._writer.dumps(tmpdir)\n # check we can dump twice\n rb._writer.dumps(tmpdir)\n other = TensorDictMaxValueWriter(rank_key=\"key\")\n other.loads(tmpdir)\n assert len(rb._writer._current_top_values) == len(other._current_top_values)\n torch.testing.assert_close(\n torch.tensor(rb._writer._current_top_values),\n torch.tensor(other._current_top_values),\n )" }, { "id": 4598, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_autocast_fused_layer_norm(self, dtype, elementwise_affine, memory_efficient):\n bf16_fwd_thresholds = dict(rtol=1.6e-2, atol=3e-4)\n bf16_bwd_thresholds = dict(rtol=1.6e-2, atol=3e-3)\n batch_size = 16\n normalized_shape = [32, 16]\n native = torch.nn.LayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine\n ).to(device=\"cuda\", dtype=dtype)\n fused = FusedLayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine, memory_efficient=memory_efficient\n ).cuda()\n native_x, fused_x = _prep_inputs(batch_size, normalized_shape, dtype)\n\n expected = native(native_x)\n with torch.cuda.amp.autocast(dtype=dtype):\n actual = fused(fused_x)\n tols = {'rtol': None, 'atol': None} if dtype == torch.half else bf16_fwd_thresholds\n # original tests used torch.testing.assert_allclose, which disables dtype checking by default. \n # link to issue here: https://github.com/pytorch/pytorch/issues/61844\n torch.testing.assert_close(actual, expected, **tols, check_dtype=False) \n\n g_native = torch.rand_like(expected)\n with torch.no_grad():\n g_fused = g_native.clone()\n expected.backward(g_native)\n actual.backward(g_fused)\n\n if dtype != torch.half:\n tols = bf16_bwd_thresholds\n elif memory_efficient:\n tols = {'rtol': 1e-3, 'atol': 1e-4}\n else:\n tols = {'rtol': None, 'atol': None}\n torch.testing.assert_close(native_x.grad, fused_x.grad, **tols, check_dtype=False)", "probing input": " def test_autocast_fused_layer_norm(self, dtype, elementwise_affine, memory_efficient):\n bf16_fwd_thresholds = dict(rtol=1.6e-2, atol=3e-4)\n bf16_bwd_thresholds = dict(rtol=1.6e-2, atol=3e-3)\n batch_size = 16\n normalized_shape = [32, 16]\n native = torch.nn.LayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine\n ).to(device=\"cuda\", dtype=dtype)\n fused = FusedLayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine, memory_efficient=memory_efficient\n ).cuda()\n native_x, fused_x = _prep_inputs(batch_size, normalized_shape, dtype)\n\n expected = native(native_x)\n with torch.cuda.amp.autocast(dtype=dtype):\n actual = fused(fused_x)\n tols = {'rtol': None, 'atol': None} if dtype == torch.half else bf16_fwd_thresholds\n # original tests used torch.testing.assert_allclose, which disables dtype checking by default. \n # link to issue here: https://github.com/pytorch/pytorch/issues/61844\n", "probing input new": " def test_autocast_fused_layer_norm(self, dtype, elementwise_affine, memory_efficient):\n bf16_fwd_thresholds = dict(rtol=1.6e-2, atol=3e-4)\n bf16_bwd_thresholds = dict(rtol=1.6e-2, atol=3e-3)\n batch_size = 16\n normalized_shape = [32, 16]\n native = torch.nn.LayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine\n ).to(device=\"cuda\", dtype=dtype)\n fused = FusedLayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine, memory_efficient=memory_efficient\n ).cuda()\n native_x, fused_x = _prep_inputs(batch_size, normalized_shape, dtype)\n\n expected = native(native_x)\n with torch.cuda.amp.autocast(dtype=dtype):\n actual = fused(fused_x)\n tols = {'rtol': None, 'atol': None} if dtype == torch.half else bf16_fwd_thresholds\n # original tests used torch.testing.assert_allclose, which disables dtype checking by default. \n # link to issue here: https://github.com/pytorch/pytorch/issues/61844\n torch.testing.", "reference": "torch.testing.assert_close(actual,expected,**tols,check_dtype=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.testing.assert_allclose" ], "replacement api": "torch.testing.assert_close", "expected call": "torch.testing.assert_close", "y_pos": "torch.testing.assert_close(actual,expected,**tols,check_dtype=False)", "y_neg": " torch.testing.assert_allclose(actual, expected, **tols)", "retain": " def test_autocast_fused_layer_norm(self, dtype, elementwise_affine, memory_efficient):\n bf16_fwd_thresholds = dict(rtol=1.6e-2, atol=3e-4)\n bf16_bwd_thresholds = dict(rtol=1.6e-2, atol=3e-3)\n batch_size = 16\n normalized_shape = [32, 16]\n native = torch.nn.LayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine\n ).to(device=\"cuda\", dtype=dtype)\n fused = FusedLayerNorm(\n normalized_shape=normalized_shape, elementwise_affine=elementwise_affine, memory_efficient=memory_efficient\n ).cuda()\n native_x, fused_x = _prep_inputs(batch_size, normalized_shape, dtype)\n\n expected = native(native_x)\n with torch.cuda.amp.autocast(dtype=dtype):\n actual = fused(fused_x)\n tols = {'rtol': None, 'atol': None} if dtype == torch.half else bf16_fwd_thresholds\n # original tests used torch.testing.assert_allclose, which disables dtype checking by default. \n # link to issue here: https://github.com/pytorch/pytorch/issues/61844\n torch.testing.assert_close(actual, expected, **tols, check_dtype=False) \n\n g_native = torch.rand_like(expected)\n with torch.no_grad():\n g_fused = g_native.clone()\n expected.backward(g_native)\n actual.backward(g_fused)\n\n if dtype != torch.half:\n tols = bf16_bwd_thresholds\n elif memory_efficient:\n tols = {'rtol': 1e-3, 'atol': 1e-4}\n else:\n tols = {'rtol': None, 'atol': None}\n torch.testing.assert_close(native_x.grad, fused_x.grad, **tols, check_dtype=False)" }, { "id": 4643, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def Grassmann_distance(P1, P2):\n proj = P1.T@P2\n if type(P1) == type(P2) == torch.Tensor:\n _, s, _ = torch.linalg.svd(proj)\n s[s > 1] = 1\n s = torch.arccos(s)\n return torch.linalg.norm(s)\n if type(P1) == type(P2) == np.ndarray:\n _, s, _ = np.linalg.svd(proj)\n s[s > 1] = 1\n s = np.arccos(s)\n return np.linalg.norm(s)\n return TypeError('Error: should be np.ndarray or torch.Tensor...')", "probing input": "def Grassmann_distance(P1, P2):\n proj = P1.T@P2\n if type(P1) == type(P2) == torch.Tensor:\n", "probing input new": "def Grassmann_distance(P1, P2):\n proj = P1.T@P2\n if type(P1) == type(P2) == torch.Tensor:\n _, s, _ = torch.", "reference": "_,s,_=torch.linalg.svd(proj)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,s,_=torch.linalg.svd(proj)", "y_neg": " _, s, _ = torch.svd(proj)", "retain": "def Grassmann_distance(P1, P2):\n proj = P1.T@P2\n if type(P1) == type(P2) == torch.Tensor:\n _, s, _ = torch.linalg.svd(proj)\n s[s > 1] = 1\n s = torch.arccos(s)\n return torch.linalg.norm(s)\n if type(P1) == type(P2) == np.ndarray:\n _, s, _ = np.linalg.svd(proj)\n s[s > 1] = 1\n s = np.arccos(s)\n return np.linalg.norm(s)\n return TypeError('Error: should be np.ndarray or torch.Tensor...')" }, { "id": 4649, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def kabsch_rotation(P, Q):\n \"\"\"\n Calculate the best rotation that minimises the RMSD between P and Q.\n\n The optimal rotation matrix was calculated using Kabsch algorithm:\n https://en.wikipedia.org/wiki/Kabsch_algorithm\n\n Args:\n P: [N * 3] Nres is the number of atoms and each row corresponds to the atom's x,y,z coordinates\n Q: [N * 3] the same dimension as P\n\n return:\n A 3*3 rotation matrix\n \"\"\"\n assert P.shape == torch.Size([Q.shape[0], Q.shape[1]])\n\n # Firstly, compute SVD of P.T * Q\n u, _, vt = torch.linalg.svd(torch.matmul(P.to(torch.float32).T,\n Q.to(torch.float32)))\n # Then construct s matrix\n s = torch.eye(P.shape[1], device=P.device)\n # correct the rotation matrix to ensure a right-handed coordinate\n s[-1, -1] = torch.sign(torch.linalg.det(torch.matmul(u, vt)))\n # finally compute the rotation matrix\n r_opt = torch.matmul(torch.matmul(u, s), vt)\n assert r_opt.shape == torch.Size([3,3])\n return r_opt.to(device=P.device, dtype=P.dtype)", "probing input": "def kabsch_rotation(P, Q):\n \"\"\"\n Calculate the best rotation that minimises the RMSD between P and Q.\n\n The optimal rotation matrix was calculated using Kabsch algorithm:\n https://en.wikipedia.org/wiki/Kabsch_algorithm\n\n Args:\n P: [N * 3] Nres is the number of atoms and each row corresponds to the atom's x,y,z coordinates\n Q: [N * 3] the same dimension as P\n\n return:\n A 3*3 rotation matrix\n \"\"\"\n assert P.shape == torch.Size([Q.shape[0], Q.shape[1]])\n\n # Firstly, compute SVD of P.T * Q\n", "probing input new": "def kabsch_rotation(P, Q):\n \"\"\"\n Calculate the best rotation that minimises the RMSD between P and Q.\n\n The optimal rotation matrix was calculated using Kabsch algorithm:\n https://en.wikipedia.org/wiki/Kabsch_algorithm\n\n Args:\n P: [N * 3] Nres is the number of atoms and each row corresponds to the atom's x,y,z coordinates\n Q: [N * 3] the same dimension as P\n\n return:\n A 3*3 rotation matrix\n \"\"\"\n assert P.shape == torch.Size([Q.shape[0], Q.shape[1]])\n\n # Firstly, compute SVD of P.T * Q\n u, _, vt = torch.", "reference": "u,_,vt=torch.linalg.svd(torch.matmul(P.to(torch.float32).T,Q.to(torch.float32)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,vt=torch.linalg.svd(torch.matmul(P.to(torch.float32).T,Q.to(torch.float32)))", "y_neg": " u, _, vt = torch.svd(P.t())", "retain": "def kabsch_rotation(P, Q):\n \"\"\"\n Calculate the best rotation that minimises the RMSD between P and Q.\n\n The optimal rotation matrix was calculated using Kabsch algorithm:\n https://en.wikipedia.org/wiki/Kabsch_algorithm\n\n Args:\n P: [N * 3] Nres is the number of atoms and each row corresponds to the atom's x,y,z coordinates\n Q: [N * 3] the same dimension as P\n\n return:\n A 3*3 rotation matrix\n \"\"\"\n assert P.shape == torch.Size([Q.shape[0], Q.shape[1]])\n\n # Firstly, compute SVD of P.T * Q\n u, _, vt = torch.linalg.svd(torch.matmul(P.to(torch.float32).T,\n Q.to(torch.float32)))\n # Then construct s matrix\n s = torch.eye(P.shape[1], device=P.device)\n # correct the rotation matrix to ensure a right-handed coordinate\n s[-1, -1] = torch.sign(torch.linalg.det(torch.matmul(u, vt)))\n # finally compute the rotation matrix\n r_opt = torch.matmul(torch.matmul(u, s), vt)\n assert r_opt.shape == torch.Size([3,3])\n return r_opt.to(device=P.device, dtype=P.dtype)" }, { "id": 4661, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert img.ndim == 4, ('Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).')\n\n # crop image\n b, c, h, w = img.shape\n img = img.double()\n img_pyr = get_guass_pyramid(img / 255.)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, 'distinct')\n _, s, _ = torch.linalg.svd(col, full_matrices=False)\n f3.append(s)\n f3 = torch.cat(f3, dim=1)\n\n # Random forest regression. Currently not differentiable and only support CPU\n preds = torch.ones(b, 1)\n for feat, rf in zip([f1, f2, f3], rf_param):\n tmp_pred = random_forest_regression(feat, *rf)\n preds = torch.cat((preds, tmp_pred), dim=1)\n quality = preds @ torch.tensor(linear_param)\n\n return quality.squeeze()", "probing input": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert img.ndim == 4, ('Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).')\n\n # crop image\n b, c, h, w = img.shape\n img = img.double()\n img_pyr = get_guass_pyramid(img / 255.)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, 'distinct')\n", "probing input new": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert img.ndim == 4, ('Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).')\n\n # crop image\n b, c, h, w = img.shape\n img = img.double()\n img_pyr = get_guass_pyramid(img / 255.)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, 'distinct')\n _, s, _ = torch.", "reference": "_,s,_=torch.linalg.svd(col,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,s,_=torch.linalg.svd(col,full_matrices=False)", "y_neg": " _, s, _ = torch.svd(col)", "retain": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert img.ndim == 4, ('Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).')\n\n # crop image\n b, c, h, w = img.shape\n img = img.double()\n img_pyr = get_guass_pyramid(img / 255.)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, 'distinct')\n _, s, _ = torch.linalg.svd(col, full_matrices=False)\n f3.append(s)\n f3 = torch.cat(f3, dim=1)\n\n # Random forest regression. Currently not differentiable and only support CPU\n preds = torch.ones(b, 1)\n for feat, rf in zip([f1, f2, f3], rf_param):\n tmp_pred = random_forest_regression(feat, *rf)\n preds = torch.cat((preds, tmp_pred), dim=1)\n quality = preds @ torch.tensor(linear_param)\n\n return quality.squeeze()" }, { "id": 4665, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat = feat - power_iteration(feat, iter=20)\n feat = model.norm(feat)\n logits = model.head(feat[:, 0])\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n", "probing input new": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.", "reference": "u,s,v=torch.linalg.svd(feat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat)", "y_neg": " u, s, v = torch.svd(feat)", "retain": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat = feat - power_iteration(feat, iter=20)\n feat = model.norm(feat)\n logits = model.head(feat[:, 0])\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4666, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.blocks[-1].mlp.fc2.weight.data\n B, C = weight.size()\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n model.blocks[-1].mlp.fc2.weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat = feat - power_iteration(feat, iter=20)\n feat = model.norm(feat)\n logits = model.head(feat[:, 0])\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.blocks[-1].mlp.fc2.weight.data\n B, C = weight.size()\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n model.blocks[-1].mlp.fc2.weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n", "probing input new": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.blocks[-1].mlp.fc2.weight.data\n B, C = weight.size()\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n model.blocks[-1].mlp.fc2.weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.", "reference": "u,s,v=torch.linalg.svd(feat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat)", "y_neg": " u, s, v = torch.svd(feat)", "retain": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.blocks[-1].mlp.fc2.weight.data\n B, C = weight.size()\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n model.blocks[-1].mlp.fc2.weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n feat = model.forward_features(x)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat = feat - power_iteration(feat, iter=20)\n feat = model.norm(feat)\n logits = model.head(feat[:, 0])\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4669, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_svd_feature_reduction():\n assert str(SVDFeatureReduction(10)) == 'SVDFeatureReduction(10)'\n\n x = torch.randn(4, 16)\n U, S, _ = torch.linalg.svd(x)\n data = Data(x=x)\n data = SVDFeatureReduction(10)(data)\n assert torch.allclose(data.x, torch.mm(U[:, :10], torch.diag(S[:10])))\n\n x = torch.randn(4, 8)\n data.x = x\n data = SVDFeatureReduction(10)(Data(x=x))\n assert torch.allclose(data.x, x)", "probing input": "def test_svd_feature_reduction():\n assert str(SVDFeatureReduction(10)) == 'SVDFeatureReduction(10)'\n\n x = torch.randn(4, 16)\n", "probing input new": "def test_svd_feature_reduction():\n assert str(SVDFeatureReduction(10)) == 'SVDFeatureReduction(10)'\n\n x = torch.randn(4, 16)\n U, S, _ = torch.", "reference": "U,S,_=torch.linalg.svd(x)", "reference dict": { "data": "SVDFeatureReduction(10)" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,_=torch.linalg.svd(x)", "y_neg": " U, S, _ = torch.svd(x)", "retain": "def test_svd_feature_reduction():\n assert str(SVDFeatureReduction(10)) == 'SVDFeatureReduction(10)'\n\n x = torch.randn(4, 16)\n U, S, _ = torch.linalg.svd(x)\n data = Data(x=x)\n data = SVDFeatureReduction(10)(data)\n assert torch.allclose(data.x, torch.mm(U[:, :10], torch.diag(S[:10])))\n\n x = torch.randn(4, 8)\n data.x = x\n data = SVDFeatureReduction(10)(Data(x=x))\n assert torch.allclose(data.x, x)" }, { "id": 4718, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _dim_reduce(x, p):\n # PCA to truncate -- project onto top p principal axes (no rescaling)\n with torch.no_grad():\n _, _, vT = torch.linalg.svd(x, full_matrices=False)\n # svd returns v.T, so the principal axes are in the *rows*. The following einsum is equivalent to x @ vT.T[:, :p]\n # but a bit faster because the transpose is not actually performed.\n return torch.einsum(\"mn,pn->mp\", x, vT[:p, :])", "probing input": "def _dim_reduce(x, p):\n # PCA to truncate -- project onto top p principal axes (no rescaling)\n with torch.no_grad():\n", "probing input new": "def _dim_reduce(x, p):\n # PCA to truncate -- project onto top p principal axes (no rescaling)\n with torch.no_grad():\n _, _, vT = torch.", "reference": "_,_,vT=torch.linalg.svd(x,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "norm": "torch.linalg.norm", "eigh": "torch.linalg.eigh" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,_,vT=torch.linalg.svd(x,full_matrices=False)", "y_neg": " _, _, vT = torch.svd(x)", "retain": "def _dim_reduce(x, p):\n # PCA to truncate -- project onto top p principal axes (no rescaling)\n with torch.no_grad():\n _, _, vT = torch.linalg.svd(x, full_matrices=False)\n # svd returns v.T, so the principal axes are in the *rows*. The following einsum is equivalent to x @ vT.T[:, :p]\n # but a bit faster because the transpose is not actually performed.\n return torch.einsum(\"mn,pn->mp\", x, vT[:p, :])" }, { "id": 4737, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def SVD(mat):\n \"\"\"\n Computes the SVD of a matrix\n\n Args:\n mat (torch.tensor): the matrix\n\n Returns:\n U, S, V: the SVD factors.\n \"\"\"\n if mat.shape[0] < 10*mat.shape[1]:\n try:\n u, s, v = tn.linalg.svd(mat,full_matrices=False)\n s = s.to(v.dtype)\n return u, s, v\n except:\n u, s, v = np.linalg.svd(mat.numpy(),full_matrices=False)\n return tn.tensor(u, dtype = mat.dtype, device = mat.device), tn.tensor(s, dtype = mat.dtype, device = mat.device), tn.tensor(v, dtype = mat.dtype, device = mat.device)\n else:\n try: \n u, s, v = tn.linalg.svd(mat.t(),full_matrices=False)\n s = s.to(v.dtype)\n return v.t(), s, u.t()\n except:\n u, s, v = np.linalg.svd((mat.t()).numpy(),full_matrices=False)\n return tn.tensor(v.t(), dtype = mat.dtype, device = mat.device), tn.tensor(s, dtype = mat.dtype, device = mat.device), tn.tensor(u.t(), dtype = mat.dtype, device = mat.device)", "probing input": "def SVD(mat):\n \"\"\"\n Computes the SVD of a matrix\n\n Args:\n mat (torch.tensor): the matrix\n\n Returns:\n U, S, V: the SVD factors.\n \"\"\"\n if mat.shape[0] < 10*mat.shape[1]:\n try:\n", "probing input new": "def SVD(mat):\n \"\"\"\n Computes the SVD of a matrix\n\n Args:\n mat (torch.tensor): the matrix\n\n Returns:\n U, S, V: the SVD factors.\n \"\"\"\n if mat.shape[0] < 10*mat.shape[1]:\n try:\n u, s, v = tn.", "reference": "u,s,v=tn.linalg.svd(mat,full_matrices=False)", "reference dict": {}, "alias dict": { "tn.potri": "torch.potri", "tn.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "tn.potrs": "torch.potrs", "tn.qr": "torch.qr", "tn.lu_solve": "torch.lu_solve", "tn.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "tn.symeig": "torch.symeig", "tn.func.functional_call": "torch.func.functional_call", "tn.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "tn.solve": "torch.solve", "tn.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "tn.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "tn.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "tn.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "tn.lu_unpack": "torch.lu_unpack", "tn.btrisolve": "torch.btrisolve", "tn.linalg.lu_factor": "torch.linalg.lu_factor", "tn.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "tn.linalg.matrix_rank": "torch.linalg.matrix_rank", "tn.norm": "torch.norm", "tn.cholesky_solve": "torch.cholesky_solve", "tn.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "tn.testing.assert_allclose": "torch.testing.assert_allclose", "tn.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "tn.gels": "torch.gels", "tn.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "tn.chain_matmul": "torch.chain_matmul", "tn.lu": "torch.lu", "tn.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "tn.pstrf": "torch.pstrf", "tn.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "tn.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "tn.linalg.eigh": "torch.linalg.eigh", "tn.btrifact": "torch.btrifact", "tn.linalg.lu_solve": "torch.linalg.lu_solve", "tn.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "tn.linalg.multi_dot": "torch.linalg.multi_dot", "tn.gesv": "torch.gesv", "tn.btrifact_with_info": "torch.btrifact_with_info", "tn.linalg.solve": "torch.linalg.solve", "tn.linalg.eig": "torch.linalg.eig", "tn.linalg.cholesky": "torch.linalg.cholesky", "tn.trtrs": "torch.trtrs", "tn.linalg.solve_triangular": "torch.linalg.solve_triangular", "tn.matrix_rank": "torch.matrix_rank", "tn.triangular_solve": "torch.triangular_solve", "tn.linalg.qr": "torch.linalg.qr", "tn.svd": "torch.svd", "tn.lstsq": "torch.lstsq", "tn.nn.functional.interpolate": "torch.nn.functional.interpolate", "tn.potrf": "torch.potrf", "tn.linalg.svd": "torch.linalg.svd", "tn.btriunpack": "torch.btriunpack", "tn.eig": "torch.eig", "tn.cholesky_inverse": "torch.cholesky_inverse", "tn.testing.assert_close": "torch.testing.assert_close", "tn.cholesky": "torch.cholesky", "tn.nn.functional.upsample": "torch.nn.functional.upsample", "tn.linalg.norm": "torch.linalg.norm", "tn.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "tn.linalg.svd", "y_pos": "u,s,v=tn.linalg.svd(mat,full_matrices=False)", "y_neg": " u, s, v = tn.svd(mat)", "retain": "def SVD(mat):\n \"\"\"\n Computes the SVD of a matrix\n\n Args:\n mat (torch.tensor): the matrix\n\n Returns:\n U, S, V: the SVD factors.\n \"\"\"\n if mat.shape[0] < 10*mat.shape[1]:\n try:\n u, s, v = tn.linalg.svd(mat,full_matrices=False)\n s = s.to(v.dtype)\n return u, s, v\n except:\n u, s, v = np.linalg.svd(mat.numpy(),full_matrices=False)\n return tn.tensor(u, dtype = mat.dtype, device = mat.device), tn.tensor(s, dtype = mat.dtype, device = mat.device), tn.tensor(v, dtype = mat.dtype, device = mat.device)\n else:\n try: \n u, s, v = tn.linalg.svd(mat.t(),full_matrices=False)\n s = s.to(v.dtype)\n return v.t(), s, u.t()\n except:\n u, s, v = np.linalg.svd((mat.t()).numpy(),full_matrices=False)\n return tn.tensor(v.t(), dtype = mat.dtype, device = mat.device), tn.tensor(s, dtype = mat.dtype, device = mat.device), tn.tensor(u.t(), dtype = mat.dtype, device = mat.device)" }, { "id": 4739, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot9d_to_rotmat(x):\n \"\"\"Convert 9D rotation representation to 3x3 rotation matrix.\n Based on Levinson et al., \"An Analysis of SVD for Deep Rotation Estimation\"\n Input:\n (B,9) or (B,J*9) Batch of 9D rotation (interpreted as 3x3 est rotmat)\n Output:\n (B,3,3) or (B*J,3,3) Batch of corresponding rotation matrices\n \"\"\"\n x = x.view(-1,3,3)\n u, _, vh = torch.linalg.svd(x)\n\n sig = torch.eye(3).expand(len(x), 3, 3).clone()\n sig = sig.to(x.device)\n sig[:, -1, -1] = (u @ vh).det()\n\n R = u @ sig @ vh\n\n return R", "probing input": "def rot9d_to_rotmat(x):\n \"\"\"Convert 9D rotation representation to 3x3 rotation matrix.\n Based on Levinson et al., \"An Analysis of SVD for Deep Rotation Estimation\"\n Input:\n (B,9) or (B,J*9) Batch of 9D rotation (interpreted as 3x3 est rotmat)\n Output:\n (B,3,3) or (B*J,3,3) Batch of corresponding rotation matrices\n \"\"\"\n x = x.view(-1,3,3)\n", "probing input new": "def rot9d_to_rotmat(x):\n \"\"\"Convert 9D rotation representation to 3x3 rotation matrix.\n Based on Levinson et al., \"An Analysis of SVD for Deep Rotation Estimation\"\n Input:\n (B,9) or (B,J*9) Batch of 9D rotation (interpreted as 3x3 est rotmat)\n Output:\n (B,3,3) or (B*J,3,3) Batch of corresponding rotation matrices\n \"\"\"\n x = x.view(-1,3,3)\n u, _, vh = torch.", "reference": "u,_,vh=torch.linalg.svd(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,vh=torch.linalg.svd(x)", "y_neg": " u, _, vh = torch.svd(x)", "retain": "def rot9d_to_rotmat(x):\n \"\"\"Convert 9D rotation representation to 3x3 rotation matrix.\n Based on Levinson et al., \"An Analysis of SVD for Deep Rotation Estimation\"\n Input:\n (B,9) or (B,J*9) Batch of 9D rotation (interpreted as 3x3 est rotmat)\n Output:\n (B,3,3) or (B*J,3,3) Batch of corresponding rotation matrices\n \"\"\"\n x = x.view(-1,3,3)\n u, _, vh = torch.linalg.svd(x)\n\n sig = torch.eye(3).expand(len(x), 3, 3).clone()\n sig = sig.to(x.device)\n sig[:, -1, -1] = (u @ vh).det()\n\n R = u @ sig @ vh\n\n return R" }, { "id": 4770, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_kabsch_RMSD(T_true, T_pred, weight, unit=10.0, dclamp=10.0, eps = 1e-4, reduction='mean'):\n # T_true, T_pred is (N_batch, N_max_len_of_batch, 3)\n # weight is the mask of size (N_batch, N_max_len_of_batch)\n\n # First center with mean coordinate of meaningful tokens, which involves scaling up the mean coordinates w.r.t mean of weight.\n # And then we zero the non-meaningful ones - zero coordinates in SVD will not affect the rotation matrix\n\n weight = weight.type(T_true.dtype)\n\n T_true_cm = (T_true * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n T_pred_cm = (T_pred * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n\n T_true_cen = T_true - T_true_cm\n T_pred_cen = T_pred - T_pred_cm\n\n # Kabsch method\n C = torch.matmul(torch.transpose(T_pred_cen * weight[:, :, None], -2, -1), T_true_cen * weight[:, :, None])\n with torch.autocast('cuda',enabled=False):\n # svd doesn't support fp16/bf16 on AMD\n V, S, W = torch.linalg.svd(C.float())\n V_prime = V * torch.tensor([1, 1, -1], device=V.device, dtype=V.dtype)[None, :, None] # Alternate version of V if d < 0\n d = (torch.linalg.det(V) * torch.linalg.det(W)) < 0.0\n\n V = torch.where(d[:, None, None], V_prime, V) # We have to broadcast d to select the right V's\n # Create Rotation matrix U\n U = torch.matmul(V, W)\n T_pred_align = torch.matmul(T_pred_cen, U) # Rotate P\n diff = T_pred_align - T_true_cen\n dist = torch.sqrt((diff**2).sum(-1) + eps) # (N_batch, N_max_len_of_batch)\n\n if dclamp is not None:\n dist = torch.clamp(dist, max=dclamp)\n dist = weight*dist\n\n loss = torch.sum(dist, dim=-1) / weight.sum(dim=-1) / unit\n\n # mini-batch reduction\n if reduction == 'mean':\n loss = torch.mean(loss)\n elif reduction == 'gmean':\n loss = torch.exp(torch.mean(torch.log(loss)))\n else:\n raise ValueError\n\n return loss", "probing input": "def compute_kabsch_RMSD(T_true, T_pred, weight, unit=10.0, dclamp=10.0, eps = 1e-4, reduction='mean'):\n # T_true, T_pred is (N_batch, N_max_len_of_batch, 3)\n # weight is the mask of size (N_batch, N_max_len_of_batch)\n\n # First center with mean coordinate of meaningful tokens, which involves scaling up the mean coordinates w.r.t mean of weight.\n # And then we zero the non-meaningful ones - zero coordinates in SVD will not affect the rotation matrix\n\n weight = weight.type(T_true.dtype)\n\n T_true_cm = (T_true * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n T_pred_cm = (T_pred * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n\n T_true_cen = T_true - T_true_cm\n T_pred_cen = T_pred - T_pred_cm\n\n # Kabsch method\n C = torch.matmul(torch.transpose(T_pred_cen * weight[:, :, None], -2, -1), T_true_cen * weight[:, :, None])\n with torch.autocast('cuda',enabled=False):\n # svd doesn't support fp16/bf16 on AMD\n", "probing input new": "def compute_kabsch_RMSD(T_true, T_pred, weight, unit=10.0, dclamp=10.0, eps = 1e-4, reduction='mean'):\n # T_true, T_pred is (N_batch, N_max_len_of_batch, 3)\n # weight is the mask of size (N_batch, N_max_len_of_batch)\n\n # First center with mean coordinate of meaningful tokens, which involves scaling up the mean coordinates w.r.t mean of weight.\n # And then we zero the non-meaningful ones - zero coordinates in SVD will not affect the rotation matrix\n\n weight = weight.type(T_true.dtype)\n\n T_true_cm = (T_true * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n T_pred_cm = (T_pred * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n\n T_true_cen = T_true - T_true_cm\n T_pred_cen = T_pred - T_pred_cm\n\n # Kabsch method\n C = torch.matmul(torch.transpose(T_pred_cen * weight[:, :, None], -2, -1), T_true_cen * weight[:, :, None])\n with torch.autocast('cuda',enabled=False):\n # svd doesn't support fp16/bf16 on AMD\n V, S, W = torch.", "reference": "V,S,W=torch.linalg.svd(C.float())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "V,S,W=torch.linalg.svd(C.float())", "y_neg": " V, S, W = torch.svd(C)", "retain": "def compute_kabsch_RMSD(T_true, T_pred, weight, unit=10.0, dclamp=10.0, eps = 1e-4, reduction='mean'):\n # T_true, T_pred is (N_batch, N_max_len_of_batch, 3)\n # weight is the mask of size (N_batch, N_max_len_of_batch)\n\n # First center with mean coordinate of meaningful tokens, which involves scaling up the mean coordinates w.r.t mean of weight.\n # And then we zero the non-meaningful ones - zero coordinates in SVD will not affect the rotation matrix\n\n weight = weight.type(T_true.dtype)\n\n T_true_cm = (T_true * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n T_pred_cm = (T_pred * weight[:, :, None]).mean(axis=1)[:,None,:] / (weight.mean(1)[:, None, None])\n\n T_true_cen = T_true - T_true_cm\n T_pred_cen = T_pred - T_pred_cm\n\n # Kabsch method\n C = torch.matmul(torch.transpose(T_pred_cen * weight[:, :, None], -2, -1), T_true_cen * weight[:, :, None])\n with torch.autocast('cuda',enabled=False):\n # svd doesn't support fp16/bf16 on AMD\n V, S, W = torch.linalg.svd(C.float())\n V_prime = V * torch.tensor([1, 1, -1], device=V.device, dtype=V.dtype)[None, :, None] # Alternate version of V if d < 0\n d = (torch.linalg.det(V) * torch.linalg.det(W)) < 0.0\n\n V = torch.where(d[:, None, None], V_prime, V) # We have to broadcast d to select the right V's\n # Create Rotation matrix U\n U = torch.matmul(V, W)\n T_pred_align = torch.matmul(T_pred_cen, U) # Rotate P\n diff = T_pred_align - T_true_cen\n dist = torch.sqrt((diff**2).sum(-1) + eps) # (N_batch, N_max_len_of_batch)\n\n if dclamp is not None:\n dist = torch.clamp(dist, max=dclamp)\n dist = weight*dist\n\n loss = torch.sum(dist, dim=-1) / weight.sum(dim=-1) / unit\n\n # mini-batch reduction\n if reduction == 'mean':\n loss = torch.mean(loss)\n elif reduction == 'gmean':\n loss = torch.exp(torch.mean(torch.log(loss)))\n else:\n raise ValueError\n\n return loss" }, { "id": 4776, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n query_feat,\n support_feat,\n way_num,\n shot_num,\n normalize=True,\n discriminative=False,\n ):\n e, ws, d = support_feat.size()\n\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n # add way dim\n query_feat = query_feat.unsqueeze(1)\n\n try:\n # faster but need pytorch>=1.8.0\n UU, _, _ = torch.linalg.svd(\n support_feat.permute(0, 1, 3, 2).double()\n ) # [episode_size, way_num, dim, dim]\n except AttributeError:\n UU, _, _ = torch.svd(\n support_feat.permute(0, 1, 3, 2).double()\n ) # [episode_size, way_num, dim, dim]\n UU = UU.float()\n subspace = UU[:, :, :, : shot_num - 1].permute(\n 0, 1, 3, 2\n ) # [episode_size, way_num, subspace_dim, dim]\n\n projection = (\n subspace.permute(0, 1, 3, 2)\n .matmul(subspace.matmul(query_feat.permute(0, 1, 3, 2)))\n .permute(0, 1, 3, 2)\n ) # [episode_size, way_num, shot_num, dim]\n\n dist = torch.sum((query_feat - projection) ** 2, dim=-1).permute(0, 2, 1)\n\n logits = -dist\n if normalize:\n logits /= d\n\n disc_loss = 0\n if discriminative:\n # P is [dim, subspace_dim] while subspace here is [subspace_dim, dim]\n subspace_metric = torch.norm(\n torch.matmul(\n subspace.unsqueeze(1), subspace.unsqueeze(2).transpose(-2, -1)\n ),\n p=\"fro\",\n dim=[-2, -1],\n ) # [episode_size, way_num, way_num]\n mask = torch.eye(way_num).bool()\n subspace_metric = subspace_metric[:, ~mask]\n disc_loss = torch.sum(subspace_metric**2)\n\n return logits, disc_loss", "probing input": " def forward(\n self,\n query_feat,\n support_feat,\n way_num,\n shot_num,\n normalize=True,\n discriminative=False,\n ):\n e, ws, d = support_feat.size()\n\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n # add way dim\n query_feat = query_feat.unsqueeze(1)\n\n try:\n # faster but need pytorch>=1.8.0\n", "probing input new": " def forward(\n self,\n query_feat,\n support_feat,\n way_num,\n shot_num,\n normalize=True,\n discriminative=False,\n ):\n e, ws, d = support_feat.size()\n\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n # add way dim\n query_feat = query_feat.unsqueeze(1)\n\n try:\n # faster but need pytorch>=1.8.0\n UU, _, _ = torch.", "reference": "UU,_,_=torch.linalg.svd(support_feat.permute(0,1,3,2).double())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "UU,_,_=torch.linalg.svd(support_feat.permute(0,1,3,2).double())", "y_neg": " UU, _, _ = torch.svd(query_feat)", "retain": " def forward(\n self,\n query_feat,\n support_feat,\n way_num,\n shot_num,\n normalize=True,\n discriminative=False,\n ):\n e, ws, d = support_feat.size()\n\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n # add way dim\n query_feat = query_feat.unsqueeze(1)\n\n try:\n # faster but need pytorch>=1.8.0\n UU, _, _ = torch.linalg.svd(\n support_feat.permute(0, 1, 3, 2).double()\n ) # [episode_size, way_num, dim, dim]\n except AttributeError:\n UU, _, _ = torch.svd(\n support_feat.permute(0, 1, 3, 2).double()\n ) # [episode_size, way_num, dim, dim]\n UU = UU.float()\n subspace = UU[:, :, :, : shot_num - 1].permute(\n 0, 1, 3, 2\n ) # [episode_size, way_num, subspace_dim, dim]\n\n projection = (\n subspace.permute(0, 1, 3, 2)\n .matmul(subspace.matmul(query_feat.permute(0, 1, 3, 2)))\n .permute(0, 1, 3, 2)\n ) # [episode_size, way_num, shot_num, dim]\n\n dist = torch.sum((query_feat - projection) ** 2, dim=-1).permute(0, 2, 1)\n\n logits = -dist\n if normalize:\n logits /= d\n\n disc_loss = 0\n if discriminative:\n # P is [dim, subspace_dim] while subspace here is [subspace_dim, dim]\n subspace_metric = torch.norm(\n torch.matmul(\n subspace.unsqueeze(1), subspace.unsqueeze(2).transpose(-2, -1)\n ),\n p=\"fro\",\n dim=[-2, -1],\n ) # [episode_size, way_num, way_num]\n mask = torch.eye(way_num).bool()\n subspace_metric = subspace_metric[:, ~mask]\n disc_loss = torch.sum(subspace_metric**2)\n\n return logits, disc_loss" }, { "id": 4778, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.features[5][17].mlp[3].weight.data\n B, C = weight.size()\n weight_sub = power_iteration_plus(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = model.features[5][17].mlp[3].weight.data = weight\n \n m = torch.nn.Softmax(dim=-1).cuda()\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n with torch.no_grad():\n \n for i in range(6):\n x = model.features[i](x)\n feat = x\n B, window_size, window_size, feat_dim = feat.size()\n feat = feat.view(B, window_size*window_size, feat_dim)\n\n u, s, v = torch.linalg.svd(feat1)\n feat1 = feat1 - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration_plus(feat, iter=20)\n\n feat = feat.view(B, window_size, window_size, feat_dim)\n \n feat = model.features[6](feat)\n feat = model.features[7](feat)\n\n feat = model.norm(feat)\n feat = model.permute(feat)\n feat = model.avgpool(feat)\n feat = model.flatten(feat)\n logits = model.head(feat)\n\n # conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n conf, _ = torch.max(m(logits), dim=-1)\n\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.features[5][17].mlp[3].weight.data\n B, C = weight.size()\n weight_sub = power_iteration_plus(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = model.features[5][17].mlp[3].weight.data = weight\n \n m = torch.nn.Softmax(dim=-1).cuda()\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n with torch.no_grad():\n \n for i in range(6):\n x = model.features[i](x)\n feat = x\n B, window_size, window_size, feat_dim = feat.size()\n feat = feat.view(B, window_size*window_size, feat_dim)\n\n", "probing input new": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.features[5][17].mlp[3].weight.data\n B, C = weight.size()\n weight_sub = power_iteration_plus(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = model.features[5][17].mlp[3].weight.data = weight\n \n m = torch.nn.Softmax(dim=-1).cuda()\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n with torch.no_grad():\n \n for i in range(6):\n x = model.features[i](x)\n feat = x\n B, window_size, window_size, feat_dim = feat.size()\n feat = feat.view(B, window_size*window_size, feat_dim)\n\n u, s, v = torch.", "reference": "u,s,v=torch.linalg.svd(feat1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat1)", "y_neg": " u, s, v = torch.svd(feat)", "retain": "def iterate_data_rankfeatweight(data_loader, model, temperature):\n confs = []\n \n weight = model.features[5][17].mlp[3].weight.data\n B, C = weight.size()\n weight_sub = power_iteration_plus(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = model.features[5][17].mlp[3].weight.data = weight\n \n m = torch.nn.Softmax(dim=-1).cuda()\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n x = x.cuda()\n\n with torch.no_grad():\n \n for i in range(6):\n x = model.features[i](x)\n feat = x\n B, window_size, window_size, feat_dim = feat.size()\n feat = feat.view(B, window_size*window_size, feat_dim)\n\n u, s, v = torch.linalg.svd(feat1)\n feat1 = feat1 - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration_plus(feat, iter=20)\n\n feat = feat.view(B, window_size, window_size, feat_dim)\n \n feat = model.features[6](feat)\n feat = model.features[7](feat)\n\n feat = model.norm(feat)\n feat = model.permute(feat)\n feat = model.avgpool(feat)\n feat = model.flatten(feat)\n logits = model.head(feat)\n\n # conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n conf, _ = torch.max(m(logits), dim=-1)\n\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4786, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def dist(self, x, y):\n \"\"\"from https://pymanopt.org/docs/latest/_modules/pymanopt/manifolds/grassmann.html\"\"\"\n _, s, _ = torch.linalg.svd(torch.bmm(torch.transpose(x, dim0=-2, dim1=-1), y))\n s[s > 1] = 1\n s = torch.arccos(s)\n return torch.linalg.norm(s, dim=1)", "probing input": " def dist(self, x, y):\n \"\"\"from https://pymanopt.org/docs/latest/_modules/pymanopt/manifolds/grassmann.html\"\"\"\n", "probing input new": " def dist(self, x, y):\n \"\"\"from https://pymanopt.org/docs/latest/_modules/pymanopt/manifolds/grassmann.html\"\"\"\n _, s, _ = torch.", "reference": "_,s,_=torch.linalg.svd(torch.bmm(torch.transpose(x,dim0=-2,dim1=-1),y))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,s,_=torch.linalg.svd(torch.bmm(torch.transpose(x,dim0=-2,dim1=-1),y))", "y_neg": " _, s, _ = torch.svd(torch.cat([x, y], dim=-1))", "retain": " def dist(self, x, y):\n \"\"\"from https://pymanopt.org/docs/latest/_modules/pymanopt/manifolds/grassmann.html\"\"\"\n _, s, _ = torch.linalg.svd(torch.bmm(torch.transpose(x, dim0=-2, dim1=-1), y))\n s[s > 1] = 1\n s = torch.arccos(s)\n return torch.linalg.norm(s, dim=1)" }, { "id": 4790, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Logit of Block 4 feature\n feat1 = model.module.intermediate_forward(inputs,layer_index=4)\n B, C, H, W = feat1.size()\n feat1 = feat1.view(B, C, H * W)\n u,s,v = torch.linalg.svd(feat1,full_matrices=False)\n feat1 = feat1 - s[:,0:1].unsqueeze(2)*u[:,:,0:1].bmm(v[:,0:1,:])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat1 = feat1 - power_iteration(feat1, iter=20)\n feat1 = feat1.view(B,C,H,W)\n logits1 = model.module.head(model.module.before_head(feat1))\n\n # Logit of Block 4 feature\n feat2 = model.module.intermediate_forward(inputs, layer_index=3)\n B, C, H, W = feat2.size()\n feat2 = feat2.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat2,full_matrices=False)\n feat2 = feat2 - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat2 = feat2 - power_iteration(feat2, iter=20)\n feat2 = feat2.view(B, C, H, W)\n feat2 = model.module.body.block4(feat2)\n logits2 = model.module.head(model.module.before_head(feat2))\n\n #Fusion at the logit space\n logits = (logits1+logits2) / 2\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Logit of Block 4 feature\n feat1 = model.module.intermediate_forward(inputs,layer_index=4)\n B, C, H, W = feat1.size()\n feat1 = feat1.view(B, C, H * W)\n", "probing input new": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Logit of Block 4 feature\n feat1 = model.module.intermediate_forward(inputs,layer_index=4)\n B, C, H, W = feat1.size()\n feat1 = feat1.view(B, C, H * W)\n u,s,v = torch.", "reference": "u,s,v=torch.linalg.svd(feat1,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat1,full_matrices=False)", "y_neg": " u,s,v = torch.svd(feat1)", "retain": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Logit of Block 4 feature\n feat1 = model.module.intermediate_forward(inputs,layer_index=4)\n B, C, H, W = feat1.size()\n feat1 = feat1.view(B, C, H * W)\n u,s,v = torch.linalg.svd(feat1,full_matrices=False)\n feat1 = feat1 - s[:,0:1].unsqueeze(2)*u[:,:,0:1].bmm(v[:,0:1,:])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat1 = feat1 - power_iteration(feat1, iter=20)\n feat1 = feat1.view(B,C,H,W)\n logits1 = model.module.head(model.module.before_head(feat1))\n\n # Logit of Block 4 feature\n feat2 = model.module.intermediate_forward(inputs, layer_index=3)\n B, C, H, W = feat2.size()\n feat2 = feat2.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat2,full_matrices=False)\n feat2 = feat2 - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n #if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n #feat2 = feat2 - power_iteration(feat2, iter=20)\n feat2 = feat2.view(B, C, H, W)\n feat2 = model.module.body.block4(feat2)\n logits2 = model.module.head(model.module.before_head(feat2))\n\n #Fusion at the logit space\n logits = (logits1+logits2) / 2\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4810, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_svd(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Perform forward pass\n U_unsorted, S_unsorted, Vt_unsorted = torch.linalg.svd(linear_op)\n U_unsorted, V_unsorted = U_unsorted.to_dense(), Vt_unsorted.to_dense()\n\n # since LinearOperator.svd does not sort the singular values, we do this here for the check\n S, idxr = torch.sort(S_unsorted, dim=-1, descending=True)\n idxr = idxr.unsqueeze(-2).expand(U_unsorted.shape)\n U = torch.gather(U_unsorted, dim=-1, index=idxr)\n Vt = torch.gather(V_unsorted, dim=-2, index=idxr.mT)\n\n # compute expected result from full tensor\n U_actual, S_actual, Vt_actual = torch.linalg.svd(evaluated.double())\n U_actual = U_actual.to(dtype=evaluated.dtype)\n S_actual = S_actual.to(dtype=evaluated.dtype)\n Vt_actual = Vt_actual.to(dtype=evaluated.dtype)\n\n # Check forward pass\n self.assertAllClose(S, S_actual, **self.tolerances[\"svd\"])\n lt_from_svd = U @ torch.diag_embed(S) @ Vt\n self.assertAllClose(lt_from_svd, evaluated, **self.tolerances[\"svd\"])\n\n # if there are repeated singular values, we'll skip checking the singular vectors\n U_abs, U_actual_abs = U.abs(), U_actual.abs()\n Vt_abs, Vt_actual_abs = Vt.abs(), Vt_actual.abs()\n any_svals_repeated = False\n for idx in product(*[range(b) for b in S_actual.shape[:-1]]):\n Si = S_actual[idx]\n if torch.unique(Si.detach()).shape[-1] == Si.shape[-1]: # detach to avoid pytorch/pytorch#41389\n self.assertAllClose(U_abs[idx], U_actual_abs[idx], **self.tolerances[\"svd\"])\n self.assertAllClose(Vt_abs[idx], Vt_actual_abs[idx], **self.tolerances[\"svd\"])\n else:\n any_svals_repeated = True\n\n # Perform backward pass\n svd_grad = torch.randn_like(S)\n ((S * svd_grad).sum()).backward()\n ((S_actual * svd_grad).sum()).backward()\n\n # Check grads if there were no repeated singular values\n if not any_svals_repeated:\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"svd\"])", "probing input": " def test_svd(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Perform forward pass\n", "probing input new": " def test_svd(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Perform forward pass\n U_unsorted, S_unsorted, Vt_unsorted = torch.", "reference": "U_unsorted,S_unsorted,Vt_unsorted=torch.linalg.svd(linear_op)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U_unsorted,S_unsorted,Vt_unsorted=torch.linalg.svd(linear_op)", "y_neg": " U_unsorted, S_unsorted, Vt_unsorted = torch.svd(linear_op)", "retain": " def test_svd(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Perform forward pass\n U_unsorted, S_unsorted, Vt_unsorted = torch.linalg.svd(linear_op)\n U_unsorted, V_unsorted = U_unsorted.to_dense(), Vt_unsorted.to_dense()\n\n # since LinearOperator.svd does not sort the singular values, we do this here for the check\n S, idxr = torch.sort(S_unsorted, dim=-1, descending=True)\n idxr = idxr.unsqueeze(-2).expand(U_unsorted.shape)\n U = torch.gather(U_unsorted, dim=-1, index=idxr)\n Vt = torch.gather(V_unsorted, dim=-2, index=idxr.mT)\n\n # compute expected result from full tensor\n U_actual, S_actual, Vt_actual = torch.linalg.svd(evaluated.double())\n U_actual = U_actual.to(dtype=evaluated.dtype)\n S_actual = S_actual.to(dtype=evaluated.dtype)\n Vt_actual = Vt_actual.to(dtype=evaluated.dtype)\n\n # Check forward pass\n self.assertAllClose(S, S_actual, **self.tolerances[\"svd\"])\n lt_from_svd = U @ torch.diag_embed(S) @ Vt\n self.assertAllClose(lt_from_svd, evaluated, **self.tolerances[\"svd\"])\n\n # if there are repeated singular values, we'll skip checking the singular vectors\n U_abs, U_actual_abs = U.abs(), U_actual.abs()\n Vt_abs, Vt_actual_abs = Vt.abs(), Vt_actual.abs()\n any_svals_repeated = False\n for idx in product(*[range(b) for b in S_actual.shape[:-1]]):\n Si = S_actual[idx]\n if torch.unique(Si.detach()).shape[-1] == Si.shape[-1]: # detach to avoid pytorch/pytorch#41389\n self.assertAllClose(U_abs[idx], U_actual_abs[idx], **self.tolerances[\"svd\"])\n self.assertAllClose(Vt_abs[idx], Vt_actual_abs[idx], **self.tolerances[\"svd\"])\n else:\n any_svals_repeated = True\n\n # Perform backward pass\n svd_grad = torch.randn_like(S)\n ((S * svd_grad).sum()).backward()\n ((S_actual * svd_grad).sum()).backward()\n\n # Check grads if there were no repeated singular values\n if not any_svals_repeated:\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"svd\"])" }, { "id": 4817, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthonormal(inp: typing.Union[torch.Tensor, torch.nn.Parameter, typing.List[int]], gain: float):\n original_input = inp\n if isinstance(inp, list):\n inp = torch.zeros(inp)\n if isinstance(inp, torch.nn.Parameter):\n inp = inp.data\n flat_shape = (inp.shape[0], np.prod(inp.shape[1:]))\n a = torch.rand(flat_shape)\n u, _, v = torch.linalg.svd(a, full_matrices=False)\n inp.copy_((u if u.shape == flat_shape else v).reshape(inp.shape).mul(gain).to(device=inp.device, dtype=inp.dtype))\n if isinstance(original_input, list):\n return torch.nn.Parameter(inp)\n return original_input", "probing input": "def orthonormal(inp: typing.Union[torch.Tensor, torch.nn.Parameter, typing.List[int]], gain: float):\n original_input = inp\n if isinstance(inp, list):\n inp = torch.zeros(inp)\n if isinstance(inp, torch.nn.Parameter):\n inp = inp.data\n flat_shape = (inp.shape[0], np.prod(inp.shape[1:]))\n a = torch.rand(flat_shape)\n", "probing input new": "def orthonormal(inp: typing.Union[torch.Tensor, torch.nn.Parameter, typing.List[int]], gain: float):\n original_input = inp\n if isinstance(inp, list):\n inp = torch.zeros(inp)\n if isinstance(inp, torch.nn.Parameter):\n inp = inp.data\n flat_shape = (inp.shape[0], np.prod(inp.shape[1:]))\n a = torch.rand(flat_shape)\n u, _, v = torch.", "reference": "u,_,v=torch.linalg.svd(a,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,v=torch.linalg.svd(a,full_matrices=False)", "y_neg": " u, _, v = torch.svd(a)", "retain": "def orthonormal(inp: typing.Union[torch.Tensor, torch.nn.Parameter, typing.List[int]], gain: float):\n original_input = inp\n if isinstance(inp, list):\n inp = torch.zeros(inp)\n if isinstance(inp, torch.nn.Parameter):\n inp = inp.data\n flat_shape = (inp.shape[0], np.prod(inp.shape[1:]))\n a = torch.rand(flat_shape)\n u, _, v = torch.linalg.svd(a, full_matrices=False)\n inp.copy_((u if u.shape == flat_shape else v).reshape(inp.shape).mul(gain).to(device=inp.device, dtype=inp.dtype))\n if isinstance(original_input, list):\n return torch.nn.Parameter(inp)\n return original_input" }, { "id": 4818, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, dataset: Tensor) -> None:\n \"\"\"Fit a Gaussian model to dataset X.\n\n Covariance matrix is not calculated directly using:\n ``C = X.X^T``\n Instead, it is represented in terms of the Singular Value Decomposition of X:\n ``X = U.S.V^T``\n Hence,\n ``C = U.S^2.U^T``\n This simplifies the calculation of the log-likelihood without requiring full matrix inversion.\n\n Args:\n dataset (Tensor): Input dataset to fit the model.\n \"\"\"\n\n num_samples = dataset.shape[1]\n self.mean_vec = torch.mean(dataset, dim=1)\n data_centered = (dataset - self.mean_vec.reshape(-1, 1)) / math.sqrt(num_samples)\n self.u_mat, self.sigma_mat, _ = torch.linalg.svd(data_centered, full_matrices=False)", "probing input": " def fit(self, dataset: Tensor) -> None:\n \"\"\"Fit a Gaussian model to dataset X.\n\n Covariance matrix is not calculated directly using:\n ``C = X.X^T``\n Instead, it is represented in terms of the Singular Value Decomposition of X:\n ``X = U.S.V^T``\n Hence,\n ``C = U.S^2.U^T``\n This simplifies the calculation of the log-likelihood without requiring full matrix inversion.\n\n Args:\n dataset (Tensor): Input dataset to fit the model.\n \"\"\"\n\n num_samples = dataset.shape[1]\n self.mean_vec = torch.mean(dataset, dim=1)\n data_centered = (dataset - self.mean_vec.reshape(-1, 1)) / math.sqrt(num_samples)\n", "probing input new": " def fit(self, dataset: Tensor) -> None:\n \"\"\"Fit a Gaussian model to dataset X.\n\n Covariance matrix is not calculated directly using:\n ``C = X.X^T``\n Instead, it is represented in terms of the Singular Value Decomposition of X:\n ``X = U.S.V^T``\n Hence,\n ``C = U.S^2.U^T``\n This simplifies the calculation of the log-likelihood without requiring full matrix inversion.\n\n Args:\n dataset (Tensor): Input dataset to fit the model.\n \"\"\"\n\n num_samples = dataset.shape[1]\n self.mean_vec = torch.mean(dataset, dim=1)\n data_centered = (dataset - self.mean_vec.reshape(-1, 1)) / math.sqrt(num_samples)\n self.u_mat, self.sigma_mat, _ = torch.", "reference": "self.u_mat,self.sigma_mat,_=torch.linalg.svd(data_centered,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "self.u_mat,self.sigma_mat,_=torch.linalg.svd(data_centered,full_matrices=False)", "y_neg": " self.u_mat, self.sigma_mat, _ = torch.svd(data_centered)", "retain": " def fit(self, dataset: Tensor) -> None:\n \"\"\"Fit a Gaussian model to dataset X.\n\n Covariance matrix is not calculated directly using:\n ``C = X.X^T``\n Instead, it is represented in terms of the Singular Value Decomposition of X:\n ``X = U.S.V^T``\n Hence,\n ``C = U.S^2.U^T``\n This simplifies the calculation of the log-likelihood without requiring full matrix inversion.\n\n Args:\n dataset (Tensor): Input dataset to fit the model.\n \"\"\"\n\n num_samples = dataset.shape[1]\n self.mean_vec = torch.mean(dataset, dim=1)\n data_centered = (dataset - self.mean_vec.reshape(-1, 1)) / math.sqrt(num_samples)\n self.u_mat, self.sigma_mat, _ = torch.linalg.svd(data_centered, full_matrices=False)" }, { "id": 4827, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _torch_svd_cast(input: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.linalg.svd(input.to(dtype))\n if torch_version_ge(1, 11):\n out3 = out3H.mH\n else:\n out3 = out3H.transpose(-1, -2)\n return (out1.to(input.dtype), out2.to(input.dtype), out3.to(input.dtype))", "probing input": "def _torch_svd_cast(input: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n", "probing input new": "def _torch_svd_cast(input: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.", "reference": "out1,out2,out3H=torch.linalg.svd(input.to(dtype))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "out1,out2,out3H=torch.linalg.svd(input.to(dtype))", "y_neg": " out1, out2, out3H = torch.svd(input)", "retain": "def _torch_svd_cast(input: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.linalg.svd(input.to(dtype))\n if torch_version_ge(1, 11):\n out3 = out3H.mH\n else:\n out3 = out3H.transpose(-1, -2)\n return (out1.to(input.dtype), out2.to(input.dtype), out3.to(input.dtype))" }, { "id": 4834, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def incremental_svd(\n A: Float[Tensor, \"d r\"],\n a: Float[Tensor, \"batch d\"],\n dtype: t.dtype = t.float64,\n n_kfac: int | None = None,\n) -> Float[Tensor, \"d n_kfac\"]:\n \"\"\"Calculate a low-rank estimate of a big [d, d] tensor, without\n materialising this full matrix.\n\n Args:\n A: The accumulated low-rank factor\n a: a new batch of points\n dtype: the datatype to use for the svd\n n_kfac: (optional) specify the rank of the resulting factor. If\n omitted, we use `r` from the `A` argument.\n You may choose to set this higher than the final rank during the\n accumulation.\n \"\"\"\n if n_kfac is None:\n n_kfac = A.size(-1)\n a = a.to(dtype=dtype)\n A_prime = t.hstack((A, a.T)) # [d, r+batch]\n U, S, _ = t.linalg.svd(A_prime, full_matrices=False)\n return U[:, :n_kfac] @ t.diag(S[:n_kfac])", "probing input": "def incremental_svd(\n A: Float[Tensor, \"d r\"],\n a: Float[Tensor, \"batch d\"],\n dtype: t.dtype = t.float64,\n n_kfac: int | None = None,\n) -> Float[Tensor, \"d n_kfac\"]:\n \"\"\"Calculate a low-rank estimate of a big [d, d] tensor, without\n materialising this full matrix.\n\n Args:\n A: The accumulated low-rank factor\n a: a new batch of points\n dtype: the datatype to use for the svd\n n_kfac: (optional) specify the rank of the resulting factor. If\n omitted, we use `r` from the `A` argument.\n You may choose to set this higher than the final rank during the\n accumulation.\n \"\"\"\n if n_kfac is None:\n n_kfac = A.size(-1)\n a = a.to(dtype=dtype)\n A_prime = t.hstack((A, a.T)) # [d, r+batch]\n", "probing input new": "def incremental_svd(\n A: Float[Tensor, \"d r\"],\n a: Float[Tensor, \"batch d\"],\n dtype: t.dtype = t.float64,\n n_kfac: int | None = None,\n) -> Float[Tensor, \"d n_kfac\"]:\n \"\"\"Calculate a low-rank estimate of a big [d, d] tensor, without\n materialising this full matrix.\n\n Args:\n A: The accumulated low-rank factor\n a: a new batch of points\n dtype: the datatype to use for the svd\n n_kfac: (optional) specify the rank of the resulting factor. If\n omitted, we use `r` from the `A` argument.\n You may choose to set this higher than the final rank during the\n accumulation.\n \"\"\"\n if n_kfac is None:\n n_kfac = A.size(-1)\n a = a.to(dtype=dtype)\n A_prime = t.hstack((A, a.T)) # [d, r+batch]\n U, S, _ = t.", "reference": "U,S,_=t.linalg.svd(A_prime,full_matrices=False)", "reference dict": {}, "alias dict": { "t.potri": "torch.potri", "t.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "t.potrs": "torch.potrs", "t.qr": "torch.qr", "t.lu_solve": "torch.lu_solve", "t.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "t.symeig": "torch.symeig", "t.func.functional_call": "torch.func.functional_call", "t.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "t.solve": "torch.solve", "t.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "t.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "t.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "t.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "t.lu_unpack": "torch.lu_unpack", "t.btrisolve": "torch.btrisolve", "t.linalg.lu_factor": "torch.linalg.lu_factor", "t.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "t.linalg.matrix_rank": "torch.linalg.matrix_rank", "t.norm": "torch.norm", "t.cholesky_solve": "torch.cholesky_solve", "t.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "t.testing.assert_allclose": "torch.testing.assert_allclose", "t.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "t.gels": "torch.gels", "t.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "t.chain_matmul": "torch.chain_matmul", "t.lu": "torch.lu", "t.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "t.pstrf": "torch.pstrf", "t.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "t.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "t.linalg.eigh": "torch.linalg.eigh", "t.btrifact": "torch.btrifact", "t.linalg.lu_solve": "torch.linalg.lu_solve", "t.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "t.linalg.multi_dot": "torch.linalg.multi_dot", "t.gesv": "torch.gesv", "t.btrifact_with_info": "torch.btrifact_with_info", "t.linalg.solve": "torch.linalg.solve", "t.linalg.eig": "torch.linalg.eig", "t.linalg.cholesky": "torch.linalg.cholesky", "t.trtrs": "torch.trtrs", "t.linalg.solve_triangular": "torch.linalg.solve_triangular", "t.matrix_rank": "torch.matrix_rank", "t.triangular_solve": "torch.triangular_solve", "t.linalg.qr": "torch.linalg.qr", "t.svd": "torch.svd", "t.lstsq": "torch.lstsq", "t.nn.functional.interpolate": "torch.nn.functional.interpolate", "t.potrf": "torch.potrf", "t.linalg.svd": "torch.linalg.svd", "t.btriunpack": "torch.btriunpack", "t.eig": "torch.eig", "t.cholesky_inverse": "torch.cholesky_inverse", "t.testing.assert_close": "torch.testing.assert_close", "t.cholesky": "torch.cholesky", "t.nn.functional.upsample": "torch.nn.functional.upsample", "t.linalg.norm": "torch.linalg.norm", "t.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "t.linalg.svd", "y_pos": "U,S,_=t.linalg.svd(A_prime,full_matrices=False)", "y_neg": " U, S, _ = t.svd(A_prime) # [d, r+batch, r]", "retain": "def incremental_svd(\n A: Float[Tensor, \"d r\"],\n a: Float[Tensor, \"batch d\"],\n dtype: t.dtype = t.float64,\n n_kfac: int | None = None,\n) -> Float[Tensor, \"d n_kfac\"]:\n \"\"\"Calculate a low-rank estimate of a big [d, d] tensor, without\n materialising this full matrix.\n\n Args:\n A: The accumulated low-rank factor\n a: a new batch of points\n dtype: the datatype to use for the svd\n n_kfac: (optional) specify the rank of the resulting factor. If\n omitted, we use `r` from the `A` argument.\n You may choose to set this higher than the final rank during the\n accumulation.\n \"\"\"\n if n_kfac is None:\n n_kfac = A.size(-1)\n a = a.to(dtype=dtype)\n A_prime = t.hstack((A, a.T)) # [d, r+batch]\n U, S, _ = t.linalg.svd(A_prime, full_matrices=False)\n return U[:, :n_kfac] @ t.diag(S[:n_kfac])" }, { "id": 4835, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n weight: torch.Tensor,\n ):\n super().__init__()\n self.weight = weight\n with torch.no_grad():\n _, s, vh = torch.linalg.svd(self.weight, full_matrices=False)\n\n self.register_buffer(\"u\", vh[0])\n self.register_buffer(\"spectral_norm\", s[0] * torch.ones(1))", "probing input": " def __init__(\n self,\n weight: torch.Tensor,\n ):\n super().__init__()\n self.weight = weight\n with torch.no_grad():\n", "probing input new": " def __init__(\n self,\n weight: torch.Tensor,\n ):\n super().__init__()\n self.weight = weight\n with torch.no_grad():\n _, s, vh = torch.", "reference": "_,s,vh=torch.linalg.svd(self.weight,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,s,vh=torch.linalg.svd(self.weight,full_matrices=False)", "y_neg": " _, s, vh = torch.svd(weight)", "retain": " def __init__(\n self,\n weight: torch.Tensor,\n ):\n super().__init__()\n self.weight = weight\n with torch.no_grad():\n _, s, vh = torch.linalg.svd(self.weight, full_matrices=False)\n\n self.register_buffer(\"u\", vh[0])\n self.register_buffer(\"spectral_norm\", s[0] * torch.ones(1))" }, { "id": 4853, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False, mode='svd') -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function\n ensure_symmetric : bool = False (optional)\n if ensure_symmetric=True, then M is symmetrized\n ensure_psd : bool = False (optional)\n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0\n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n if mode=='svd':\n U, s, _ = torch.linalg.svd(M)\n elif mode=='eigh':\n s, U = torch.linalg.eigh(M)\n\n if ensure_psd:\n s = s.clamp(min=EPS[s.dtype])\n\n # modify the eigenvalues\n smod = fun(s, fun_param)\n X = U @ torch.diag_embed(smod) @ U.transpose(-1,-2)\n\n return X, s, smod, U", "probing input": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False, mode='svd') -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function\n ensure_symmetric : bool = False (optional)\n if ensure_symmetric=True, then M is symmetrized\n ensure_psd : bool = False (optional)\n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0\n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n if mode=='svd':\n", "probing input new": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False, mode='svd') -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function\n ensure_symmetric : bool = False (optional)\n if ensure_symmetric=True, then M is symmetrized\n ensure_psd : bool = False (optional)\n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0\n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n if mode=='svd':\n U, s, _ = torch.", "reference": "U,s,_=torch.linalg.svd(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,s,_=torch.linalg.svd(M)", "y_neg": " U, s, _ = torch.svd(M)", "retain": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False, mode='svd') -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function\n ensure_symmetric : bool = False (optional)\n if ensure_symmetric=True, then M is symmetrized\n ensure_psd : bool = False (optional)\n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0\n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n if mode=='svd':\n U, s, _ = torch.linalg.svd(M)\n elif mode=='eigh':\n s, U = torch.linalg.eigh(M)\n\n if ensure_psd:\n s = s.clamp(min=EPS[s.dtype])\n\n # modify the eigenvalues\n smod = fun(s, fun_param)\n X = U @ torch.diag_embed(smod) @ U.transpose(-1,-2)\n\n return X, s, smod, U" }, { "id": 4859, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up.weight, self.down.weight)\n # torch.svd\n U, s, Vt = torch.linalg.svd(new_weight, full_matrices=False)\n\n # Select the first r singular values\n r = self.rank\n Ur = U[:, :r]\n sr = s[:r]\n Vtr = Vt[:r, :]\n\n # set the weights of down and up matrix\n up = Ur * sr\n down = Vtr\n\n if not up.is_contiguous():\n up = up.contiguous()\n if not down.is_contiguous():\n down = down.contiguous()\n down = nn.Parameter(down)\n up = nn.Parameter(up)\n\n # Remove abandoned layers and variables\n del self.down, self.up\n\n # Redefine down and up layers\n self.down = nn.Linear(self.in_features, r, bias=False)\n self.down.weight = down\n self.up = nn.Linear(r, self.out_features, bias=False)\n self.up.weight = nn.Parameter(up)", "probing input": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up.weight, self.down.weight)\n # torch.svd\n", "probing input new": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up.weight, self.down.weight)\n # torch.svd\n U, s, Vt = torch.", "reference": "U,s,Vt=torch.linalg.svd(new_weight,full_matrices=False)", "reference dict": { "down": "nn.Parameter", "up": "nn.Parameter", "self.down": "nn.Linear", "self.up": "nn.Linear", "self.up.weight": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,s,Vt=torch.linalg.svd(new_weight,full_matrices=False)", "y_neg": " U, s, Vt = torch.svd(new_weight)", "retain": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up.weight, self.down.weight)\n # torch.svd\n U, s, Vt = torch.linalg.svd(new_weight, full_matrices=False)\n\n # Select the first r singular values\n r = self.rank\n Ur = U[:, :r]\n sr = s[:r]\n Vtr = Vt[:r, :]\n\n # set the weights of down and up matrix\n up = Ur * sr\n down = Vtr\n\n if not up.is_contiguous():\n up = up.contiguous()\n if not down.is_contiguous():\n down = down.contiguous()\n down = nn.Parameter(down)\n up = nn.Parameter(up)\n\n # Remove abandoned layers and variables\n del self.down, self.up\n\n # Redefine down and up layers\n self.down = nn.Linear(self.in_features, r, bias=False)\n self.down.weight = down\n self.up = nn.Linear(r, self.out_features, bias=False)\n self.up.weight = nn.Parameter(up)" }, { "id": 4869, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def WNNM(self,input,nsigma=100/255,c=1.41):\n U,S,Vh,= torch.linalg.svd(input,full_matrices=False)\n patch_num = self.sim_num\n C0 = c*torch.sqrt(torch.tensor([patch_num]))*2*torch.square(nsigma)\n C0 = C0.to(input.device)\n e =torch.tensor([0.00001]).to(input.device)\n Delta = torch.square(S+e)-4*C0 \n S[Delta<0] = 0\n Delta[Delta<0] = 0\n Sx = S-e+torch.sqrt(Delta)/2\n Sx[Sx<0]=0\n out = U@torch.diag_embed(Sx)@Vh\n return out", "probing input": " def WNNM(self,input,nsigma=100/255,c=1.41):\n", "probing input new": " def WNNM(self,input,nsigma=100/255,c=1.41):\n U,S,Vh,= torch.", "reference": "U,S,Vh,=torch.linalg.svd(input,full_matrices=False)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vh,=torch.linalg.svd(input,full_matrices=False)", "y_neg": " U,S,Vh,= torch.svd(input)", "retain": " def WNNM(self,input,nsigma=100/255,c=1.41):\n U,S,Vh,= torch.linalg.svd(input,full_matrices=False)\n patch_num = self.sim_num\n C0 = c*torch.sqrt(torch.tensor([patch_num]))*2*torch.square(nsigma)\n C0 = C0.to(input.device)\n e =torch.tensor([0.00001]).to(input.device)\n Delta = torch.square(S+e)-4*C0 \n S[Delta<0] = 0\n Delta[Delta<0] = 0\n Sx = S-e+torch.sqrt(Delta)/2\n Sx[Sx<0]=0\n out = U@torch.diag_embed(Sx)@Vh\n return out" }, { "id": 4873, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Block 3\n feat = model.module.features[:-2](inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u,s,v = torch.linalg.svd(feat)\n feat = feat - s[:,0:1].unsqueeze(2)*u[:,:,0:1].bmm(v[:,0:1,:])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B,C,H,W)\n feat = model.module.features[-2:](feat)\n logits1 = model.module.classifier(feat)\n\n # Block 4\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B, C, H, W)\n logits2 = model.module.classifier(feat)\n\n # Fusion at the logit space\n logits = (logits1 + logits2)/2\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Block 3\n feat = model.module.features[:-2](inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n", "probing input new": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Block 3\n feat = model.module.features[:-2](inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u,s,v = torch.", "reference": "u,s,v=torch.linalg.svd(feat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat)", "y_neg": " u,s,v = torch.svd(feat)", "retain": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n #Block 3\n feat = model.module.features[:-2](inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u,s,v = torch.linalg.svd(feat)\n feat = feat - s[:,0:1].unsqueeze(2)*u[:,:,0:1].bmm(v[:,0:1,:])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B,C,H,W)\n feat = model.module.features[-2:](feat)\n logits1 = model.module.classifier(feat)\n\n # Block 4\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B, C, H, W)\n logits2 = model.module.classifier(feat)\n\n # Fusion at the logit space\n logits = (logits1 + logits2)/2\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4874, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n\n weight = model.module.classifier[1].weight.data\n B, C, H, W = weight.size()\n weight = weight.view(B, C * H * W)\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = weight.view(B, C, H, W)\n model.module.classifier[1].weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B, C, H, W)\n logits = model.module.classifier(feat)\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)", "probing input": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n\n weight = model.module.classifier[1].weight.data\n B, C, H, W = weight.size()\n weight = weight.view(B, C * H * W)\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = weight.view(B, C, H, W)\n model.module.classifier[1].weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n", "probing input new": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n\n weight = model.module.classifier[1].weight.data\n B, C, H, W = weight.size()\n weight = weight.view(B, C * H * W)\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = weight.view(B, C, H, W)\n model.module.classifier[1].weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u, s, v = torch.", "reference": "u,s,v=torch.linalg.svd(feat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,v=torch.linalg.svd(feat)", "y_neg": " u, s, v = torch.svd(feat)", "retain": "def iterate_data_rankfeat(data_loader, model, temperature):\n confs = []\n\n weight = model.module.classifier[1].weight.data\n B, C, H, W = weight.size()\n weight = weight.view(B, C * H * W)\n weight_sub = power_iteration(weight.unsqueeze(0), iter=100)\n weight = weight - weight_sub.squeeze()\n weight = weight.view(B, C, H, W)\n model.module.classifier[1].weight.data = weight\n \n for b, (x, y) in enumerate(data_loader):\n if b % 100 == 0:\n print('{} batches processed'.format(b))\n inputs = x.cuda()\n\n feat = model.module.features(inputs)\n B, C, H, W = feat.size()\n feat = feat.view(B, C, H * W)\n u, s, v = torch.linalg.svd(feat)\n feat = feat - s[:, 0:1].unsqueeze(2) * u[:, :, 0:1].bmm(v[:, 0:1, :])\n # if you want to use PI for acceleration, comment the above 2 lines and uncomment the line below\n # feat = feat - power_iteration(feat, iter=20)\n feat = feat.view(B, C, H, W)\n logits = model.module.classifier(feat)\n\n conf = temperature * torch.logsumexp(logits / temperature, dim=1)\n confs.extend(conf.data.cpu().numpy())\n\n return np.array(confs)" }, { "id": 4875, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def initialize(self, V, k: int) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n 'NNDSVD-A' initialization, as in sklearn.\n\n For nonnegative SVD initialization see https://www.cb.uu.se/~milan/histo/before2011august/Boutsidis.pdf\n\n NNDSVD-A first computes NNDSVD as above, then fills any zeros in W or H with the mean of V.\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n U, S, Vh = torch.linalg.svd(V, full_matrices=False)\n\n d = U.shape[1] # factors are identified up to sign. make sure they're positive\n for dd in range(d):\n if torch.any(U[:, dd] < 0):\n U[:, dd] *= -1\n Vh[dd, :] *= -1\n\n k = int(k)\n\n f, n = V.shape\n\n W = torch.zeros((f, k))\n H = torch.zeros((k, n))\n\n W[:, 0] = torch.sqrt(S[0]) * U[:, 0]\n H[0, :] = torch.sqrt(S[0]) * Vh[0, :]\n\n for j in range(1, k):\n xp = torch.nn.functional.relu(U[:, j])\n xn = torch.nn.functional.relu(-U[:, j])\n yp = torch.nn.functional.relu(Vh[j, :])\n yn = torch.nn.functional.relu(-Vh[j, :])\n\n mp = torch.norm(xp) * torch.norm(yp)\n mn = torch.norm(xn) * torch.norm(yn)\n if mp > mn:\n u = xp / torch.norm(xp)\n v = yp / torch.norm(yp)\n sig = mp\n else:\n u = xn / torch.norm(xn)\n v = yn / torch.norm(yn)\n sig = mn\n\n W[:, j] = torch.sqrt(S[j] * sig) * u\n H[j, :] = torch.sqrt(S[j] * sig) * v\n\n W[W == 0] = V.mean()\n H[H == 0] = V.mean()\n\n return W, H", "probing input": " def initialize(self, V, k: int) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n 'NNDSVD-A' initialization, as in sklearn.\n\n For nonnegative SVD initialization see https://www.cb.uu.se/~milan/histo/before2011august/Boutsidis.pdf\n\n NNDSVD-A first computes NNDSVD as above, then fills any zeros in W or H with the mean of V.\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n", "probing input new": " def initialize(self, V, k: int) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n 'NNDSVD-A' initialization, as in sklearn.\n\n For nonnegative SVD initialization see https://www.cb.uu.se/~milan/histo/before2011august/Boutsidis.pdf\n\n NNDSVD-A first computes NNDSVD as above, then fills any zeros in W or H with the mean of V.\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n U, S, Vh = torch.", "reference": "U,S,Vh=torch.linalg.svd(V,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vh=torch.linalg.svd(V,full_matrices=False)", "y_neg": " U, S, Vh = torch.svd(V)", "retain": " def initialize(self, V, k: int) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n 'NNDSVD-A' initialization, as in sklearn.\n\n For nonnegative SVD initialization see https://www.cb.uu.se/~milan/histo/before2011august/Boutsidis.pdf\n\n NNDSVD-A first computes NNDSVD as above, then fills any zeros in W or H with the mean of V.\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n U, S, Vh = torch.linalg.svd(V, full_matrices=False)\n\n d = U.shape[1] # factors are identified up to sign. make sure they're positive\n for dd in range(d):\n if torch.any(U[:, dd] < 0):\n U[:, dd] *= -1\n Vh[dd, :] *= -1\n\n k = int(k)\n\n f, n = V.shape\n\n W = torch.zeros((f, k))\n H = torch.zeros((k, n))\n\n W[:, 0] = torch.sqrt(S[0]) * U[:, 0]\n H[0, :] = torch.sqrt(S[0]) * Vh[0, :]\n\n for j in range(1, k):\n xp = torch.nn.functional.relu(U[:, j])\n xn = torch.nn.functional.relu(-U[:, j])\n yp = torch.nn.functional.relu(Vh[j, :])\n yn = torch.nn.functional.relu(-Vh[j, :])\n\n mp = torch.norm(xp) * torch.norm(yp)\n mn = torch.norm(xn) * torch.norm(yn)\n if mp > mn:\n u = xp / torch.norm(xp)\n v = yp / torch.norm(yp)\n sig = mp\n else:\n u = xn / torch.norm(xn)\n v = yn / torch.norm(yn)\n sig = mn\n\n W[:, j] = torch.sqrt(S[j] * sig) * u\n H[j, :] = torch.sqrt(S[j] * sig) * v\n\n W[W == 0] = V.mean()\n H[H == 0] = V.mean()\n\n return W, H" }, { "id": 4881, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, X: Tensor, center_data: bool) -> Tuple[Tensor, Tensor]:\n \"\"\"\n Perform PCA on the data matrix X by computing its SVD.\n\n Args:\n X (Tensor): Data matrix.\n center_data (bool): If true, then the data mean will be subtracted\n from all data points prior to performing PCA. If center_data is false,\n it is expected that the data has already been centered and an exception\n will be thrown if it is not.\n\n Returns:\n Tuple[Tensor, Tensor]: The principal components (i.e., right singular vectors)\n and their corresponding singular values.\n\n Note: the algorithm assumes that the rows of X are the data points (after reshaping as needed).\n Consequently, the principal components, which are the eigenvectors of X.T @ X,\n are the right singular vectors in the SVD of X.\n \"\"\"\n X_prime = self.prepare_data_forward(X, center_data=center_data)\n if self.low_rank:\n log(INFO, \"Assuming data matrix is low rank, using low-rank PCA implementation.\")\n m, n = X_prime.size(0), X_prime.size(1)\n if self.rank_estimation > m or self.rank_estimation > n:\n log(WARNING, \"Estimate of data rank given by user is larger than the actual rank.\")\n q = min(self.rank_estimation, m, n)\n _, singular_values, principal_components = torch.pca_lowrank(X_prime, q=q, center=False)\n else:\n if self.full_svd:\n log(INFO, \"Performing full SVD on data matrix.\")\n else:\n log(INFO, \"Performing reduced SVD on data matrix.\")\n _, singular_values, Vh = torch.linalg.svd(X_prime, full_matrices=self.full_svd)\n principal_components = Vh.T\n return principal_components, singular_values", "probing input": " def forward(self, X: Tensor, center_data: bool) -> Tuple[Tensor, Tensor]:\n \"\"\"\n Perform PCA on the data matrix X by computing its SVD.\n\n Args:\n X (Tensor): Data matrix.\n center_data (bool): If true, then the data mean will be subtracted\n from all data points prior to performing PCA. If center_data is false,\n it is expected that the data has already been centered and an exception\n will be thrown if it is not.\n\n Returns:\n Tuple[Tensor, Tensor]: The principal components (i.e., right singular vectors)\n and their corresponding singular values.\n\n Note: the algorithm assumes that the rows of X are the data points (after reshaping as needed).\n Consequently, the principal components, which are the eigenvectors of X.T @ X,\n are the right singular vectors in the SVD of X.\n \"\"\"\n X_prime = self.prepare_data_forward(X, center_data=center_data)\n if self.low_rank:\n log(INFO, \"Assuming data matrix is low rank, using low-rank PCA implementation.\")\n m, n = X_prime.size(0), X_prime.size(1)\n if self.rank_estimation > m or self.rank_estimation > n:\n log(WARNING, \"Estimate of data rank given by user is larger than the actual rank.\")\n q = min(self.rank_estimation, m, n)\n _, singular_values, principal_components = torch.pca_lowrank(X_prime, q=q, center=False)\n else:\n if self.full_svd:\n log(INFO, \"Performing full SVD on data matrix.\")\n else:\n log(INFO, \"Performing reduced SVD on data matrix.\")\n", "probing input new": " def forward(self, X: Tensor, center_data: bool) -> Tuple[Tensor, Tensor]:\n \"\"\"\n Perform PCA on the data matrix X by computing its SVD.\n\n Args:\n X (Tensor): Data matrix.\n center_data (bool): If true, then the data mean will be subtracted\n from all data points prior to performing PCA. If center_data is false,\n it is expected that the data has already been centered and an exception\n will be thrown if it is not.\n\n Returns:\n Tuple[Tensor, Tensor]: The principal components (i.e., right singular vectors)\n and their corresponding singular values.\n\n Note: the algorithm assumes that the rows of X are the data points (after reshaping as needed).\n Consequently, the principal components, which are the eigenvectors of X.T @ X,\n are the right singular vectors in the SVD of X.\n \"\"\"\n X_prime = self.prepare_data_forward(X, center_data=center_data)\n if self.low_rank:\n log(INFO, \"Assuming data matrix is low rank, using low-rank PCA implementation.\")\n m, n = X_prime.size(0), X_prime.size(1)\n if self.rank_estimation > m or self.rank_estimation > n:\n log(WARNING, \"Estimate of data rank given by user is larger than the actual rank.\")\n q = min(self.rank_estimation, m, n)\n _, singular_values, principal_components = torch.pca_lowrank(X_prime, q=q, center=False)\n else:\n if self.full_svd:\n log(INFO, \"Performing full SVD on data matrix.\")\n else:\n log(INFO, \"Performing reduced SVD on data matrix.\")\n _, singular_values, Vh = torch.", "reference": "_,singular_values,Vh=torch.linalg.svd(X_prime,full_matrices=self.full_svd)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,singular_values,Vh=torch.linalg.svd(X_prime,full_matrices=self.full_svd)", "y_neg": " _, singular_values, Vh = torch.svd(X_prime, some=False)", "retain": " def forward(self, X: Tensor, center_data: bool) -> Tuple[Tensor, Tensor]:\n \"\"\"\n Perform PCA on the data matrix X by computing its SVD.\n\n Args:\n X (Tensor): Data matrix.\n center_data (bool): If true, then the data mean will be subtracted\n from all data points prior to performing PCA. If center_data is false,\n it is expected that the data has already been centered and an exception\n will be thrown if it is not.\n\n Returns:\n Tuple[Tensor, Tensor]: The principal components (i.e., right singular vectors)\n and their corresponding singular values.\n\n Note: the algorithm assumes that the rows of X are the data points (after reshaping as needed).\n Consequently, the principal components, which are the eigenvectors of X.T @ X,\n are the right singular vectors in the SVD of X.\n \"\"\"\n X_prime = self.prepare_data_forward(X, center_data=center_data)\n if self.low_rank:\n log(INFO, \"Assuming data matrix is low rank, using low-rank PCA implementation.\")\n m, n = X_prime.size(0), X_prime.size(1)\n if self.rank_estimation > m or self.rank_estimation > n:\n log(WARNING, \"Estimate of data rank given by user is larger than the actual rank.\")\n q = min(self.rank_estimation, m, n)\n _, singular_values, principal_components = torch.pca_lowrank(X_prime, q=q, center=False)\n else:\n if self.full_svd:\n log(INFO, \"Performing full SVD on data matrix.\")\n else:\n log(INFO, \"Performing reduced SVD on data matrix.\")\n _, singular_values, Vh = torch.linalg.svd(X_prime, full_matrices=self.full_svd)\n principal_components = Vh.T\n return principal_components, singular_values" }, { "id": 4908, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _torch_svd_cast(self, input):\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.linalg.svd(input.to(dtype))\n #if torch_version_ge(1, 11):\n # out3 = out3H.mH\n #else:\n out3 = out3H.transpose(-1, -2)\n return (out1.to(input.dtype), out2.to(input.dtype), out3.to(input.dtype))", "probing input": " def _torch_svd_cast(self, input):\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n", "probing input new": " def _torch_svd_cast(self, input):\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.", "reference": "out1,out2,out3H=torch.linalg.svd(input.to(dtype))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "out1,out2,out3H=torch.linalg.svd(input.to(dtype))", "y_neg": " out1, out2, out3H = torch.svd(input)", "retain": " def _torch_svd_cast(self, input):\n \"\"\"Helper function to make torch.svd work with other than fp32/64.\n\n The function torch.svd is only implemented for fp32/64 which makes\n impossible to be used by fp16 or others. What this function does, is cast\n input data type to fp32, apply torch.svd, and cast back to the input dtype.\n\n NOTE: in torch 1.8.1 this function is recommended to use as torch.linalg.svd\n \"\"\"\n # if not isinstance(input, torch.Tensor):\n # raise AssertionError(f\"Input must be torch.Tensor. Got: {type(input)}.\")\n dtype = input.dtype\n if dtype not in (torch.float32, torch.float64):\n dtype = torch.float32\n\n out1, out2, out3H = torch.linalg.svd(input.to(dtype))\n #if torch_version_ge(1, 11):\n # out3 = out3H.mH\n #else:\n out3 = out3H.transpose(-1, -2)\n return (out1.to(input.dtype), out2.to(input.dtype), out3.to(input.dtype))" }, { "id": 4913, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def modalsvd(self, inputs, n):\n \"\"\"\n Method that performs the standard SVD of an unfolded matrix defined from an input tensor\n along a given dimension\n\n :param torch.Tensor inputs: the input tensor\n :param int n: the index of the unfolding matrix being decomposed\n :return: three SVD matrices of the n-th unfolding of tensor inputs\n :rtype: torch.Tensors\n \"\"\"\n return torch.linalg.svd(self.unfolding(inputs, n), full_matrices=True)", "probing input": " def modalsvd(self, inputs, n):\n \"\"\"\n Method that performs the standard SVD of an unfolded matrix defined from an input tensor\n along a given dimension\n\n :param torch.Tensor inputs: the input tensor\n :param int n: the index of the unfolding matrix being decomposed\n :return: three SVD matrices of the n-th unfolding of tensor inputs\n :rtype: torch.Tensors\n \"\"\"\n", "probing input new": " def modalsvd(self, inputs, n):\n \"\"\"\n Method that performs the standard SVD of an unfolded matrix defined from an input tensor\n along a given dimension\n\n :param torch.Tensor inputs: the input tensor\n :param int n: the index of the unfolding matrix being decomposed\n :return: three SVD matrices of the n-th unfolding of tensor inputs\n :rtype: torch.Tensors\n \"\"\"\n return torch.", "reference": "returntorch.linalg.svd(self.unfolding(inputs,n),full_matrices=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "returntorch.linalg.svd(self.unfolding(inputs,n),full_matrices=True)", "y_neg": " return torch.svd(inputs.unfold(n, 1))", "retain": " def modalsvd(self, inputs, n):\n \"\"\"\n Method that performs the standard SVD of an unfolded matrix defined from an input tensor\n along a given dimension\n\n :param torch.Tensor inputs: the input tensor\n :param int n: the index of the unfolding matrix being decomposed\n :return: three SVD matrices of the n-th unfolding of tensor inputs\n :rtype: torch.Tensors\n \"\"\"\n return torch.linalg.svd(self.unfolding(inputs, n), full_matrices=True)" }, { "id": 4927, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert (\n img.ndim == 4\n ), \"Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).\"\n\n # crop image\n b, c, h, w = img.shape\n img_pyr = get_guass_pyramid(img.float() / 255.0)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, \"distinct\")\n _, s, _ = torch.linalg.svd(col, full_matrices=False)\n f3.append(s)\n f3 = torch.cat(f3, dim=1)\n\n # Random forest regression. Currently not differentiable and only support CPU\n preds = torch.ones(b, 1)\n for feat, rf in zip([f1, f2, f3], rf_param):\n tmp_pred = random_forest_regression(feat, *rf)\n preds = torch.cat((preds, tmp_pred), dim=1)\n quality = preds @ torch.Tensor(linear_param)\n\n return quality.squeeze()", "probing input": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert (\n img.ndim == 4\n ), \"Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).\"\n\n # crop image\n b, c, h, w = img.shape\n img_pyr = get_guass_pyramid(img.float() / 255.0)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, \"distinct\")\n", "probing input new": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert (\n img.ndim == 4\n ), \"Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).\"\n\n # crop image\n b, c, h, w = img.shape\n img_pyr = get_guass_pyramid(img.float() / 255.0)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, \"distinct\")\n _, s, _ = torch.", "reference": "_,s,_=torch.linalg.svd(col,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,s,_=torch.linalg.svd(col,full_matrices=False)", "y_neg": " _, s, _ = torch.svd(col)", "retain": "def nrqm(\n img: Tensor,\n linear_param,\n rf_param,\n) -> Tensor:\n \"\"\"Calculate NRQM\n Args:\n img (Tensor): Input image.\n linear_param (np.array): (4, 1) linear regression params\n rf_param: params of 3 random forest for 3 kinds of features\n \"\"\"\n assert (\n img.ndim == 4\n ), \"Input image must be a gray or Y (of YCbCr) image with shape (b, c, h, w).\"\n\n # crop image\n b, c, h, w = img.shape\n img_pyr = get_guass_pyramid(img.float() / 255.0)\n\n # DCT features\n f1 = []\n for im in img_pyr:\n f1.append(block_dct(im))\n f1 = torch.cat(f1, dim=1)\n\n # gsm features\n f2 = global_gsm(img)\n\n # svd features\n f3 = []\n for im in img_pyr:\n col = im2col(im, 5, \"distinct\")\n _, s, _ = torch.linalg.svd(col, full_matrices=False)\n f3.append(s)\n f3 = torch.cat(f3, dim=1)\n\n # Random forest regression. Currently not differentiable and only support CPU\n preds = torch.ones(b, 1)\n for feat, rf in zip([f1, f2, f3], rf_param):\n tmp_pred = random_forest_regression(feat, *rf)\n preds = torch.cat((preds, tmp_pred), dim=1)\n quality = preds @ torch.Tensor(linear_param)\n\n return quality.squeeze()" }, { "id": 4938, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.V.data.copy_(V)\n self.S.data.copy_(torch.ones(S.shape[0], dtype=self.U.dtype, device=self.device))\n elif self.mode == \"phase\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n delta_list, phi_mat = self.decomposer.decompose(U)\n self.delta_list_U.data.copy_(delta_list)\n self.phase_U.data.copy_(self.decomposer.m2v(phi_mat))\n delta_list, phi_mat = self.decomposer.decompose(V)\n self.delta_list_V.data.copy_(delta_list)\n self.phase_V.data.copy_(self.decomposer.m2v(phi_mat))\n self.S_scale.data.copy_(S.abs().max(dim=-1, keepdim=True)[0])\n self.phase_S.data.copy_(S.div(self.S_scale.data).acos())\n\n elif self.mode == \"voltage\":\n raise NotImplementedError\n else:\n raise NotImplementedError\n\n if self.bias is not None:\n init.uniform_(self.bias, 0, 0)", "probing input": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n", "probing input new": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.", "reference": "U,S,V=torch.linalg.svd(W,full_matrices=True,driver=\"gesvd\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,V=torch.linalg.svd(W,full_matrices=True,driver=\"gesvd\")", "y_neg": " U, S, V = torch.svd(W)", "retain": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.V.data.copy_(V)\n self.S.data.copy_(torch.ones(S.shape[0], dtype=self.U.dtype, device=self.device))\n elif self.mode == \"phase\":\n W = init.kaiming_normal_(\n torch.empty(self.out_channels, self.in_channels_flat, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n delta_list, phi_mat = self.decomposer.decompose(U)\n self.delta_list_U.data.copy_(delta_list)\n self.phase_U.data.copy_(self.decomposer.m2v(phi_mat))\n delta_list, phi_mat = self.decomposer.decompose(V)\n self.delta_list_V.data.copy_(delta_list)\n self.phase_V.data.copy_(self.decomposer.m2v(phi_mat))\n self.S_scale.data.copy_(S.abs().max(dim=-1, keepdim=True)[0])\n self.phase_S.data.copy_(S.div(self.S_scale.data).acos())\n\n elif self.mode == \"voltage\":\n raise NotImplementedError\n else:\n raise NotImplementedError\n\n if self.bias is not None:\n init.uniform_(self.bias, 0, 0)" }, { "id": 4939, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def build_usv_from_weight(self, weight: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n ### differentiable feature is gauranteed\n # U, S, V = weight.data.svd(some=False)\n # V = V.transpose(-2, -1).contiguous()\n U, S, V = torch.linalg.svd(weight.data, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.S.data.copy_(S)\n self.V.data.copy_(V)\n return U, S, V", "probing input": " def build_usv_from_weight(self, weight: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n ### differentiable feature is gauranteed\n # U, S, V = weight.data.svd(some=False)\n # V = V.transpose(-2, -1).contiguous()\n", "probing input new": " def build_usv_from_weight(self, weight: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n ### differentiable feature is gauranteed\n # U, S, V = weight.data.svd(some=False)\n # V = V.transpose(-2, -1).contiguous()\n U, S, V = torch.", "reference": "U,S,V=torch.linalg.svd(weight.data,full_matrices=True,driver=\"gesvd\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,V=torch.linalg.svd(weight.data,full_matrices=True,driver=\"gesvd\")", "y_neg": " U, S, V = torch.svd(weight)", "retain": " def build_usv_from_weight(self, weight: Tensor) -> Tuple[Tensor, Tensor, Tensor]:\n ### differentiable feature is gauranteed\n # U, S, V = weight.data.svd(some=False)\n # V = V.transpose(-2, -1).contiguous()\n U, S, V = torch.linalg.svd(weight.data, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.S.data.copy_(S)\n self.V.data.copy_(V)\n return U, S, V" }, { "id": 4950, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def proj2manifold(x):\n u, _, vT = torch.linalg.svd(x)\n return u @ vT", "probing input": "def proj2manifold(x):\n", "probing input new": "def proj2manifold(x):\n u, _, vT = torch.", "reference": "u,_,vT=torch.linalg.svd(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,vT=torch.linalg.svd(x)", "y_neg": " u, _, vT = torch.svd(x)", "retain": "def proj2manifold(x):\n u, _, vT = torch.linalg.svd(x)\n return u @ vT" }, { "id": 4973, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.V.data.copy_(V)\n self.S.data.copy_(torch.ones(S.shape[0], dtype=self.U.dtype, device=self.device))\n elif self.mode == \"phase\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n delta_list, phi_mat = self.decomposer.decompose(U)\n self.delta_list_U.data.copy_(delta_list)\n self.phase_U.data.copy_(self.decomposer.m2v(phi_mat))\n delta_list, phi_mat = self.decomposer.decompose(V)\n self.delta_list_V.data.copy_(delta_list)\n self.phase_V.data.copy_(self.decomposer.m2v(phi_mat))\n self.S_scale.data.copy_(S.abs().max(dim=-1, keepdim=True)[0])\n self.phase_S.data.copy_(S.div(self.S_scale.data).acos())\n\n elif self.mode == \"voltage\":\n raise NotImplementedError\n else:\n raise NotImplementedError\n\n if self.bias is not None:\n init.uniform_(self.bias, 0, 0)", "probing input": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n", "probing input new": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.", "reference": "U,S,V=torch.linalg.svd(W,full_matrices=True,driver=\"gesvd\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,V=torch.linalg.svd(W,full_matrices=True,driver=\"gesvd\")", "y_neg": " U, S, V = torch.svd(W)", "retain": " def reset_parameters(self) -> None:\n if self.mode == \"weight\":\n init.kaiming_normal_(self.weight.data)\n elif self.mode == \"usv\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n self.U.data.copy_(U)\n self.V.data.copy_(V)\n self.S.data.copy_(torch.ones(S.shape[0], dtype=self.U.dtype, device=self.device))\n elif self.mode == \"phase\":\n W = init.kaiming_normal_(\n torch.empty(self.out_features, self.in_features, dtype=self.U.dtype, device=self.device)\n )\n # U, S, V = torch.svd(W, some=False)\n # V = V.transpose(-2, -1)\n U, S, V = torch.linalg.svd(W, full_matrices=True, driver=\"gesvd\") # must use QR decomposition\n delta_list, phi_mat = self.decomposer.decompose(U)\n self.delta_list_U.data.copy_(delta_list)\n self.phase_U.data.copy_(self.decomposer.m2v(phi_mat))\n delta_list, phi_mat = self.decomposer.decompose(V)\n self.delta_list_V.data.copy_(delta_list)\n self.phase_V.data.copy_(self.decomposer.m2v(phi_mat))\n self.S_scale.data.copy_(S.abs().max(dim=-1, keepdim=True)[0])\n self.phase_S.data.copy_(S.div(self.S_scale.data).acos())\n\n elif self.mode == \"voltage\":\n raise NotImplementedError\n else:\n raise NotImplementedError\n\n if self.bias is not None:\n init.uniform_(self.bias, 0, 0)" }, { "id": 4976, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_heatmap(self, img):\n with torch.no_grad():\n tensor = self.prep(img)[None, ...].to(self.device)\n output = self.model(tensor)\n feature = self.feature['output']\n self._check(feature)\n \n _, _, vT = torch.linalg.svd(feature)\n v1 = vT[:, :, 0, :][..., None, :]\n \n cam = feature @ v1.repeat(1, 1, v1.shape[3], 1)\n cam = cam.sum(1)\n cam -= cam.min()\n cam = cam / cam.max() * 255\n cam = cam.cpu().numpy().transpose(1, 2, 0).astype(np.uint8)\n cam = cv2.resize(cam, img.size)\n cam = cv2.applyColorMap(cam, cv2.COLORMAP_JET) \n\n if not isinstance(img, np.ndarray):\n img = np.asarray(img)\n\n overlay = np.uint8(0.6 * img + 0.4 * cam)\n\n return output, overlay", "probing input": " def get_heatmap(self, img):\n with torch.no_grad():\n tensor = self.prep(img)[None, ...].to(self.device)\n output = self.model(tensor)\n feature = self.feature['output']\n self._check(feature)\n \n", "probing input new": " def get_heatmap(self, img):\n with torch.no_grad():\n tensor = self.prep(img)[None, ...].to(self.device)\n output = self.model(tensor)\n feature = self.feature['output']\n self._check(feature)\n \n _, _, vT = torch.", "reference": "_,_,vT=torch.linalg.svd(feature)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,_,vT=torch.linalg.svd(feature)", "y_neg": " _, _, vT = torch.svd(output)", "retain": " def get_heatmap(self, img):\n with torch.no_grad():\n tensor = self.prep(img)[None, ...].to(self.device)\n output = self.model(tensor)\n feature = self.feature['output']\n self._check(feature)\n \n _, _, vT = torch.linalg.svd(feature)\n v1 = vT[:, :, 0, :][..., None, :]\n \n cam = feature @ v1.repeat(1, 1, v1.shape[3], 1)\n cam = cam.sum(1)\n cam -= cam.min()\n cam = cam / cam.max() * 255\n cam = cam.cpu().numpy().transpose(1, 2, 0).astype(np.uint8)\n cam = cv2.resize(cam, img.size)\n cam = cv2.applyColorMap(cam, cv2.COLORMAP_JET) \n\n if not isinstance(img, np.ndarray):\n img = np.asarray(img)\n\n overlay = np.uint8(0.6 * img + 0.4 * cam)\n\n return output, overlay" }, { "id": 4982, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _compute_low_rank_preconditioned_gradient(\n self,\n preconditioned_gradient: torch.Tensor,\n ) -> List[torch.Tensor]:\n \"\"\"Performs low-rank approximation of the preconditioned gradient with SVD.\n\n Args:\n preconditioned_gradient (torch.Tensor):\n The preconditioned per-sample-gradient matrix to be low-rank approximated.\n\n Returns:\n List[torch.Tensor, torch.Tensor]:\n Low-rank matrices that approximate the original preconditioned gradient.\n \"\"\"\n U, S, V = torch.linalg.svd( # pylint: disable=not-callable\n preconditioned_gradient.contiguous().to(dtype=self.score_args.query_gradient_svd_dtype),\n full_matrices=False,\n )\n rank = self.score_args.query_gradient_rank\n U_k = U[:, :, :rank]\n S_k = S[:, :rank]\n # Avoid holding the full memory of the original tensor before indexing.\n V_k = V[:, :rank, :].clone()\n return [\n torch.matmul(U_k, torch.diag_embed(S_k)).to(dtype=self.score_args.score_dtype).contiguous(),\n V_k.to(dtype=self.score_args.score_dtype).contiguous(),\n ]", "probing input": " def _compute_low_rank_preconditioned_gradient(\n self,\n preconditioned_gradient: torch.Tensor,\n ) -> List[torch.Tensor]:\n \"\"\"Performs low-rank approximation of the preconditioned gradient with SVD.\n\n Args:\n preconditioned_gradient (torch.Tensor):\n The preconditioned per-sample-gradient matrix to be low-rank approximated.\n\n Returns:\n List[torch.Tensor, torch.Tensor]:\n Low-rank matrices that approximate the original preconditioned gradient.\n \"\"\"\n", "probing input new": " def _compute_low_rank_preconditioned_gradient(\n self,\n preconditioned_gradient: torch.Tensor,\n ) -> List[torch.Tensor]:\n \"\"\"Performs low-rank approximation of the preconditioned gradient with SVD.\n\n Args:\n preconditioned_gradient (torch.Tensor):\n The preconditioned per-sample-gradient matrix to be low-rank approximated.\n\n Returns:\n List[torch.Tensor, torch.Tensor]:\n Low-rank matrices that approximate the original preconditioned gradient.\n \"\"\"\n U, S, V = torch.", "reference": "U,S,V=torch.linalg.svd(preconditioned_gradient.contiguous().to(dtype=self.score_args.query_gradient_svd_dtype),full_matrices=False,)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,V=torch.linalg.svd(preconditioned_gradient.contiguous().to(dtype=self.score_args.query_gradient_svd_dtype),full_matrices=False,)", "y_neg": " U, S, V = torch.svd(preconditioned_gradient)", "retain": " def _compute_low_rank_preconditioned_gradient(\n self,\n preconditioned_gradient: torch.Tensor,\n ) -> List[torch.Tensor]:\n \"\"\"Performs low-rank approximation of the preconditioned gradient with SVD.\n\n Args:\n preconditioned_gradient (torch.Tensor):\n The preconditioned per-sample-gradient matrix to be low-rank approximated.\n\n Returns:\n List[torch.Tensor, torch.Tensor]:\n Low-rank matrices that approximate the original preconditioned gradient.\n \"\"\"\n U, S, V = torch.linalg.svd( # pylint: disable=not-callable\n preconditioned_gradient.contiguous().to(dtype=self.score_args.query_gradient_svd_dtype),\n full_matrices=False,\n )\n rank = self.score_args.query_gradient_rank\n U_k = U[:, :, :rank]\n S_k = S[:, :rank]\n # Avoid holding the full memory of the original tensor before indexing.\n V_k = V[:, :rank, :].clone()\n return [\n torch.matmul(U_k, torch.diag_embed(S_k)).to(dtype=self.score_args.score_dtype).contiguous(),\n V_k.to(dtype=self.score_args.score_dtype).contiguous(),\n ]" }, { "id": 4988, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, query_feat, support_feat, way_num, shot_num, normalize=True, discriminative=False):\n e, ws, d = support_feat.size()\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n query_feat = query_feat.unsqueeze(1)\n try:\n UU, _, _ = torch.linalg.svd(support_feat.permute(0, 1, 3, 2).double())\n except AttributeError:\n UU, _, _ = torch.svd(support_feat.permute(0, 1, 3, 2).double())\n UU = UU.float()\n subspace = UU[:, :, :, :shot_num - 1].permute(0, 1, 3, 2)\n projection = subspace.permute(0, 1, 3, 2).matmul(subspace.matmul(query_feat.permute(0, 1, 3, 2))).permute(0, 1, 3, 2)\n dist = torch.sum((query_feat - projection) ** 2, dim=-1).permute(0, 2, 1)\n logits = -dist\n if normalize:\n logits /= d\n disc_loss = 0\n if discriminative:\n subspace_metric = torch.norm(torch.matmul(subspace.unsqueeze(1), subspace.unsqueeze(2).transpose(-2, -1)), p='fro', dim=[-2, -1])\n mask = torch.eye(way_num).bool()\n subspace_metric = subspace_metric[:, ~mask]\n disc_loss = torch.sum(subspace_metric ** 2)\n return logits, disc_loss", "probing input": " def forward(self, query_feat, support_feat, way_num, shot_num, normalize=True, discriminative=False):\n e, ws, d = support_feat.size()\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n query_feat = query_feat.unsqueeze(1)\n try:\n", "probing input new": " def forward(self, query_feat, support_feat, way_num, shot_num, normalize=True, discriminative=False):\n e, ws, d = support_feat.size()\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n query_feat = query_feat.unsqueeze(1)\n try:\n UU, _, _ = torch.", "reference": "UU,_,_=torch.linalg.svd(support_feat.permute(0,1,3,2).double())", "reference dict": { "yaml": "MagicMock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "weight_norm": "torch.nn.utils.weight_norm" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "UU,_,_=torch.linalg.svd(support_feat.permute(0,1,3,2).double())", "y_neg": " UU, _, _ = torch.svd(support_feat)", "retain": " def forward(self, query_feat, support_feat, way_num, shot_num, normalize=True, discriminative=False):\n e, ws, d = support_feat.size()\n support_feat = support_feat.reshape(e, way_num, shot_num, -1)\n query_feat = query_feat.unsqueeze(1)\n try:\n UU, _, _ = torch.linalg.svd(support_feat.permute(0, 1, 3, 2).double())\n except AttributeError:\n UU, _, _ = torch.svd(support_feat.permute(0, 1, 3, 2).double())\n UU = UU.float()\n subspace = UU[:, :, :, :shot_num - 1].permute(0, 1, 3, 2)\n projection = subspace.permute(0, 1, 3, 2).matmul(subspace.matmul(query_feat.permute(0, 1, 3, 2))).permute(0, 1, 3, 2)\n dist = torch.sum((query_feat - projection) ** 2, dim=-1).permute(0, 2, 1)\n logits = -dist\n if normalize:\n logits /= d\n disc_loss = 0\n if discriminative:\n subspace_metric = torch.norm(torch.matmul(subspace.unsqueeze(1), subspace.unsqueeze(2).transpose(-2, -1)), p='fro', dim=[-2, -1])\n mask = torch.eye(way_num).bool()\n subspace_metric = subspace_metric[:, ~mask]\n disc_loss = torch.sum(subspace_metric ** 2)\n return logits, disc_loss" }, { "id": 4989, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def init_text_embeddings(self):\n\n label2text_dict = self.label2text_dict\n transformed_dict = {key: value.replace('-', ' ').lower() for key, value in label2text_dict.items()}\n\n clip_dict = {key: f\"A magnetic resonance imaging of a {value} in human brain.\" for key, value in transformed_dict.items()}\n\n text_segments = clip.tokenize(list(clip_dict.values())).to('cuda')\n model, _ = clip.load(self.clip_backbone, 'cuda')\n model.eval()\n model.requires_grad_(False)\n text_features = model.encode_text(text_segments).float() # 35 x 512\n _, _, V = torch.linalg.svd(text_features)\n background_vector = V[:, -1].unsqueeze(0)\n self.text_features = torch.cat([background_vector, text_features], dim=0) # 36 x 512\n self.text_features.requires_grad_(False)\n self.text_features = self.text_features.float()\n print(\"Successfully initialized *CLIP* embedded anatomical features for %d classes using %s backbone.\" % (self.text_features.shape[0], self.clip_backbone))\n\n self.init_dim = self.text_features.shape[1]", "probing input": " def init_text_embeddings(self):\n\n label2text_dict = self.label2text_dict\n transformed_dict = {key: value.replace('-', ' ').lower() for key, value in label2text_dict.items()}\n\n clip_dict = {key: f\"A magnetic resonance imaging of a {value} in human brain.\" for key, value in transformed_dict.items()}\n\n text_segments = clip.tokenize(list(clip_dict.values())).to('cuda')\n model, _ = clip.load(self.clip_backbone, 'cuda')\n model.eval()\n model.requires_grad_(False)\n text_features = model.encode_text(text_segments).float() # 35 x 512\n", "probing input new": " def init_text_embeddings(self):\n\n label2text_dict = self.label2text_dict\n transformed_dict = {key: value.replace('-', ' ').lower() for key, value in label2text_dict.items()}\n\n clip_dict = {key: f\"A magnetic resonance imaging of a {value} in human brain.\" for key, value in transformed_dict.items()}\n\n text_segments = clip.tokenize(list(clip_dict.values())).to('cuda')\n model, _ = clip.load(self.clip_backbone, 'cuda')\n model.eval()\n model.requires_grad_(False)\n text_features = model.encode_text(text_segments).float() # 35 x 512\n _, _, V = torch.", "reference": "_,_,V=torch.linalg.svd(text_features)", "reference dict": { "self.label2text_dict": "OrderedDict", "self.abbr2full_dict": "OrderedDict" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,_,V=torch.linalg.svd(text_features)", "y_neg": " _, _, V = torch.svd(text_features)", "retain": " def init_text_embeddings(self):\n\n label2text_dict = self.label2text_dict\n transformed_dict = {key: value.replace('-', ' ').lower() for key, value in label2text_dict.items()}\n\n clip_dict = {key: f\"A magnetic resonance imaging of a {value} in human brain.\" for key, value in transformed_dict.items()}\n\n text_segments = clip.tokenize(list(clip_dict.values())).to('cuda')\n model, _ = clip.load(self.clip_backbone, 'cuda')\n model.eval()\n model.requires_grad_(False)\n text_features = model.encode_text(text_segments).float() # 35 x 512\n _, _, V = torch.linalg.svd(text_features)\n background_vector = V[:, -1].unsqueeze(0)\n self.text_features = torch.cat([background_vector, text_features], dim=0) # 36 x 512\n self.text_features.requires_grad_(False)\n self.text_features = self.text_features.float()\n print(\"Successfully initialized *CLIP* embedded anatomical features for %d classes using %s backbone.\" % (self.text_features.shape[0], self.clip_backbone))\n\n self.init_dim = self.text_features.shape[1]" }, { "id": 4991, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_power_svd(matrix: torch.Tensor, power: float) -> torch.Tensor:\n r\"\"\"Compute G^{-1/p} using a SVD.\n\n Calculate SVD on the GPU. Sometimes, SVD on the CPU is faster than GPU, but based on the several experiments,\n CUDA seems much faster than on CPU.\n\n :param matrix: torch.Tensor. a square positive semi-definite matrix.\n :param power: float. rank.\n \"\"\"\n u, s, vh = torch.linalg.svd(matrix, full_matrices=False)\n s.pow_(-1.0 / power)\n return u @ (s.diag() if len(matrix.shape) == 2 else s.diag_embed()) @ vh", "probing input": "def compute_power_svd(matrix: torch.Tensor, power: float) -> torch.Tensor:\n r\"\"\"Compute G^{-1/p} using a SVD.\n\n Calculate SVD on the GPU. Sometimes, SVD on the CPU is faster than GPU, but based on the several experiments,\n CUDA seems much faster than on CPU.\n\n :param matrix: torch.Tensor. a square positive semi-definite matrix.\n :param power: float. rank.\n \"\"\"\n", "probing input new": "def compute_power_svd(matrix: torch.Tensor, power: float) -> torch.Tensor:\n r\"\"\"Compute G^{-1/p} using a SVD.\n\n Calculate SVD on the GPU. Sometimes, SVD on the CPU is faster than GPU, but based on the several experiments,\n CUDA seems much faster than on CPU.\n\n :param matrix: torch.Tensor. a square positive semi-definite matrix.\n :param power: float. rank.\n \"\"\"\n u, s, vh = torch.", "reference": "u,s,vh=torch.linalg.svd(matrix,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,vh=torch.linalg.svd(matrix,full_matrices=False)", "y_neg": " u, s, vh = torch.svd(matrix)", "retain": "def compute_power_svd(matrix: torch.Tensor, power: float) -> torch.Tensor:\n r\"\"\"Compute G^{-1/p} using a SVD.\n\n Calculate SVD on the GPU. Sometimes, SVD on the CPU is faster than GPU, but based on the several experiments,\n CUDA seems much faster than on CPU.\n\n :param matrix: torch.Tensor. a square positive semi-definite matrix.\n :param power: float. rank.\n \"\"\"\n u, s, vh = torch.linalg.svd(matrix, full_matrices=False)\n s.pow_(-1.0 / power)\n return u @ (s.diag() if len(matrix.shape) == 2 else s.diag_embed()) @ vh" }, { "id": 4995, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _fit(self, x, y=None):\n try:\n # Future-proofing of SVD, different import point\n # Same result as `torch.svd`.\n _, _, Vh = torch.linalg.svd(x, **self.init_args)\n V = Vh.transpose(-2, -1).conj()\n except AttributeError:\n # Legacy SVD. Same result as `torch.linalg.svd`.\n _, _, V = torch.svd(x, **self.init_args)\n\n # Numerical instability: The generated torch tensors are not guaranteed to be unique\n # Specifically, the `V` tensor can be a matrix M, or its negative (-M), depending on the underlying system\n # See: https://pytorch.org/docs/stable/generated/torch.linalg.svd.html#torch.linalg.svd\n # To ensure consistency across systems, we can arbitrarily select the version of the matrix that is positive\n # in the very first index.\n init_value = torch.flatten(V.data).detach().cpu().numpy()[0]\n if init_value < 0:\n V = -V\n\n if self.n_components:\n V = V[:, :self.n_components]\n if V.shape[1] < self.n_components:\n V = torch.cat((V, torch.zeros(V.shape[0], self.n_components - V.shape[1], requires_grad=True,\n device=device)), dim=1)\n self.V = torch.nn.Parameter(V)", "probing input": " def _fit(self, x, y=None):\n try:\n # Future-proofing of SVD, different import point\n # Same result as `torch.svd`.\n", "probing input new": " def _fit(self, x, y=None):\n try:\n # Future-proofing of SVD, different import point\n # Same result as `torch.svd`.\n _, _, Vh = torch.", "reference": "_,_,Vh=torch.linalg.svd(x,**self.init_args)", "reference dict": { "self.V": "torch.nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "_,_,Vh=torch.linalg.svd(x,**self.init_args)", "y_neg": " _, _, Vh = torch.svd(x)", "retain": " def _fit(self, x, y=None):\n try:\n # Future-proofing of SVD, different import point\n # Same result as `torch.svd`.\n _, _, Vh = torch.linalg.svd(x, **self.init_args)\n V = Vh.transpose(-2, -1).conj()\n except AttributeError:\n # Legacy SVD. Same result as `torch.linalg.svd`.\n _, _, V = torch.svd(x, **self.init_args)\n\n # Numerical instability: The generated torch tensors are not guaranteed to be unique\n # Specifically, the `V` tensor can be a matrix M, or its negative (-M), depending on the underlying system\n # See: https://pytorch.org/docs/stable/generated/torch.linalg.svd.html#torch.linalg.svd\n # To ensure consistency across systems, we can arbitrarily select the version of the matrix that is positive\n # in the very first index.\n init_value = torch.flatten(V.data).detach().cpu().numpy()[0]\n if init_value < 0:\n V = -V\n\n if self.n_components:\n V = V[:, :self.n_components]\n if V.shape[1] < self.n_components:\n V = torch.cat((V, torch.zeros(V.shape[0], self.n_components - V.shape[1], requires_grad=True,\n device=device)), dim=1)\n self.V = torch.nn.Parameter(V)" }, { "id": 4997, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up_frozen.weight, self.down_frozen.weight) #+ \\\n # torch.mm(self.up_trainable.weight, self.down_trainable.weight)\n\n # torch.svd\n U, s, Vt = torch.linalg.svd(new_weight, full_matrices=False)\n print(\"shape====================>\")\n print(new_weight.shape)\n print(U.shape)\n print(Vt.shape)\n\n # Select the first r singular values\n r = self.rank_f + self.rank_t\n Ur = U[:, :r]\n sr = s[:r]\n Vtr = Vt[:r, :]\n\n # set the weights of down and up matrix\n up = Ur * sr\n down = Vtr\n\n if not up.is_contiguous():\n up = up.contiguous()\n if not down.is_contiguous():\n down = down.contiguous()\n down = nn.Parameter(down)\n up = nn.Parameter(up)\n\n # convert down and up matrix to linear layer\n self.down = nn.Linear(self.in_features, r, bias=False)\n self.down.weight = down\n self.up = nn.Linear(r, self.out_features, bias=False)\n self.up.weight = nn.Parameter(up)\n\n # Remove redundant layers and variables\n del self.down_frozen\n del self.up_frozen\n del self.down_trainable\n del self.up_trainable", "probing input": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up_frozen.weight, self.down_frozen.weight) #+ \\\n # torch.mm(self.up_trainable.weight, self.down_trainable.weight)\n\n # torch.svd\n", "probing input new": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up_frozen.weight, self.down_frozen.weight) #+ \\\n # torch.mm(self.up_trainable.weight, self.down_trainable.weight)\n\n # torch.svd\n U, s, Vt = torch.", "reference": "U,s,Vt=torch.linalg.svd(new_weight,full_matrices=False)", "reference dict": { "down": "nn.Parameter", "up": "nn.Parameter", "self.down": "nn.Linear", "self.up": "nn.Linear", "self.up.weight": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,s,Vt=torch.linalg.svd(new_weight,full_matrices=False)", "y_neg": " U, s, Vt = torch.svd(new_weight)", "retain": " def convert_to_standard_lora(self):\n # convert down and up matrix to linear layer, nn.Linear call F.linear\n with torch.no_grad():\n # merge two lora weight\n new_weight = torch.mm(self.up_frozen.weight, self.down_frozen.weight) #+ \\\n # torch.mm(self.up_trainable.weight, self.down_trainable.weight)\n\n # torch.svd\n U, s, Vt = torch.linalg.svd(new_weight, full_matrices=False)\n print(\"shape====================>\")\n print(new_weight.shape)\n print(U.shape)\n print(Vt.shape)\n\n # Select the first r singular values\n r = self.rank_f + self.rank_t\n Ur = U[:, :r]\n sr = s[:r]\n Vtr = Vt[:r, :]\n\n # set the weights of down and up matrix\n up = Ur * sr\n down = Vtr\n\n if not up.is_contiguous():\n up = up.contiguous()\n if not down.is_contiguous():\n down = down.contiguous()\n down = nn.Parameter(down)\n up = nn.Parameter(up)\n\n # convert down and up matrix to linear layer\n self.down = nn.Linear(self.in_features, r, bias=False)\n self.down.weight = down\n self.up = nn.Linear(r, self.out_features, bias=False)\n self.up.weight = nn.Parameter(up)\n\n # Remove redundant layers and variables\n del self.down_frozen\n del self.up_frozen\n del self.down_trainable\n del self.up_trainable" }, { "id": 5001, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def punish_wight(wo_batch, latent_size, alpha, method):\n if method == 'weight':\n wo_batch *= alpha\n elif method in ['alpha', 'beta', 'delete', 'soft-weight']:\n u, s, vh = torch.linalg.svd(wo_batch)\n u = u[:,:latent_size]\n zero_idx = int(latent_size * alpha)\n if method == 'alpha':\n s[:zero_idx] = 0\n elif method == 'beta':\n s[zero_idx:] = 0\n elif method == 'delete':\n s = s[zero_idx:] if zero_idx < latent_size else torch.zeros(latent_size).to(s.device)\n u = u[:, zero_idx:] if zero_idx < latent_size else u\n vh = vh[zero_idx:, :] if zero_idx < latent_size else vh\n elif method == 'soft-weight':\n if CALC_SIMILARITY:\n _s = s.clone()\n _s[zero_idx:] = 0\n _wo_batch = u @ torch.diag(_s) @ vh\n dist = cdist(wo_batch[:,0].unsqueeze(0).cpu(), _wo_batch[:,0].unsqueeze(0).cpu(), metric='cosine')\n print(f'The distance between the word embedding before and after the punishment: {dist}')\n if alpha == -.001:\n s *= (torch.exp(-.001 * s) * 1.2) # strengthen objects (our Appendix.F)\n else:\n s *= torch.exp(-alpha*s) # suppression EOT (our main paper)\n\n wo_batch = u @ torch.diag(s) @ vh\n else:\n raise ValueError('Unsupported method')\n return wo_batch", "probing input": "def punish_wight(wo_batch, latent_size, alpha, method):\n if method == 'weight':\n wo_batch *= alpha\n elif method in ['alpha', 'beta', 'delete', 'soft-weight']:\n", "probing input new": "def punish_wight(wo_batch, latent_size, alpha, method):\n if method == 'weight':\n wo_batch *= alpha\n elif method in ['alpha', 'beta', 'delete', 'soft-weight']:\n u, s, vh = torch.", "reference": "u,s,vh=torch.linalg.svd(wo_batch)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,s,vh=torch.linalg.svd(wo_batch)", "y_neg": " u, s, vh = torch.svd(wo_batch)", "retain": "def punish_wight(wo_batch, latent_size, alpha, method):\n if method == 'weight':\n wo_batch *= alpha\n elif method in ['alpha', 'beta', 'delete', 'soft-weight']:\n u, s, vh = torch.linalg.svd(wo_batch)\n u = u[:,:latent_size]\n zero_idx = int(latent_size * alpha)\n if method == 'alpha':\n s[:zero_idx] = 0\n elif method == 'beta':\n s[zero_idx:] = 0\n elif method == 'delete':\n s = s[zero_idx:] if zero_idx < latent_size else torch.zeros(latent_size).to(s.device)\n u = u[:, zero_idx:] if zero_idx < latent_size else u\n vh = vh[zero_idx:, :] if zero_idx < latent_size else vh\n elif method == 'soft-weight':\n if CALC_SIMILARITY:\n _s = s.clone()\n _s[zero_idx:] = 0\n _wo_batch = u @ torch.diag(_s) @ vh\n dist = cdist(wo_batch[:,0].unsqueeze(0).cpu(), _wo_batch[:,0].unsqueeze(0).cpu(), metric='cosine')\n print(f'The distance between the word embedding before and after the punishment: {dist}')\n if alpha == -.001:\n s *= (torch.exp(-.001 * s) * 1.2) # strengthen objects (our Appendix.F)\n else:\n s *= torch.exp(-alpha*s) # suppression EOT (our main paper)\n\n wo_batch = u @ torch.diag(s) @ vh\n else:\n raise ValueError('Unsupported method')\n return wo_batch" }, { "id": 5004, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def canonical_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.CanonicalStiefel]\n ex = torch.randn(*shape)\n ev = torch.randn(*shape)\n u, _, v = torch.linalg.svd(ex, full_matrices=False)\n x = torch.einsum(\"...ik,...kj->...ij\", u, v)\n v = ev - x @ ev.t() @ x\n manifold = geoopt.manifolds.CanonicalStiefel()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case", "probing input": "def canonical_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.CanonicalStiefel]\n ex = torch.randn(*shape)\n ev = torch.randn(*shape)\n", "probing input new": "def canonical_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.CanonicalStiefel]\n ex = torch.randn(*shape)\n ev = torch.randn(*shape)\n u, _, v = torch.", "reference": "u,_,v=torch.linalg.svd(ex,full_matrices=False)", "reference dict": { "manifold": "geoopt.manifolds.CanonicalStiefel", "x": "geoopt.ManifoldTensor", "case": "UnaryCase" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,v=torch.linalg.svd(ex,full_matrices=False)", "y_neg": " u, _, v = torch.svd(ex)", "retain": "def canonical_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.CanonicalStiefel]\n ex = torch.randn(*shape)\n ev = torch.randn(*shape)\n u, _, v = torch.linalg.svd(ex, full_matrices=False)\n x = torch.einsum(\"...ik,...kj->...ij\", u, v)\n v = ev - x @ ev.t() @ x\n manifold = geoopt.manifolds.CanonicalStiefel()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case" }, { "id": 5005, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def euclidean_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.EuclideanStiefel]\n ex = torch.randn(*shape, dtype=torch.float64)\n ev = torch.randn(*shape, dtype=torch.float64)\n u, _, v = torch.linalg.svd(ex, full_matrices=False)\n x = torch.einsum(\"...ik,...kj->...ij\", u, v)\n nonsym = x.t() @ ev\n v = ev - x @ (nonsym + nonsym.t()) / 2\n\n manifold = geoopt.manifolds.EuclideanStiefel()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case\n manifold = geoopt.manifolds.EuclideanStiefelExact()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case", "probing input": "def euclidean_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.EuclideanStiefel]\n ex = torch.randn(*shape, dtype=torch.float64)\n ev = torch.randn(*shape, dtype=torch.float64)\n", "probing input new": "def euclidean_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.EuclideanStiefel]\n ex = torch.randn(*shape, dtype=torch.float64)\n ev = torch.randn(*shape, dtype=torch.float64)\n u, _, v = torch.", "reference": "u,_,v=torch.linalg.svd(ex,full_matrices=False)", "reference dict": { "manifold": "geoopt.manifolds.EuclideanStiefelExact", "x": "geoopt.ManifoldTensor", "case": "UnaryCase" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "u,_,v=torch.linalg.svd(ex,full_matrices=False)", "y_neg": " u, _, v = torch.svd(ex)", "retain": "def euclidean_stiefel_case():\n torch.manual_seed(42)\n shape = manifold_shapes[geoopt.manifolds.EuclideanStiefel]\n ex = torch.randn(*shape, dtype=torch.float64)\n ev = torch.randn(*shape, dtype=torch.float64)\n u, _, v = torch.linalg.svd(ex, full_matrices=False)\n x = torch.einsum(\"...ik,...kj->...ij\", u, v)\n nonsym = x.t() @ ev\n v = ev - x @ (nonsym + nonsym.t()) / 2\n\n manifold = geoopt.manifolds.EuclideanStiefel()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case\n manifold = geoopt.manifolds.EuclideanStiefelExact()\n x = geoopt.ManifoldTensor(x, manifold=manifold)\n case = UnaryCase(shape, x, ex, v, ev, manifold)\n yield case" }, { "id": 5009, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def coral(source_features, val_target_features, unlabeled_target_features, labeled_target_features, k, save_path):\n x_s = torch.cat((source_features.to(device), labeled_target_features.to(device)))\n x_t = unlabeled_target_features.to(device)\n x_tv = val_target_features.to(device)\n \n # PCA\n x = torch.cat((x_s, x_t))\n x = x - x.mean(0)\n \n # below line takes forever, save it\n if os.path.isfile(save_path):\n print('Using saved SVD decomposition')\n U, S, Vh = torch.load(save_path)\n U = U.to(device)\n S = S.to(device)\n else:\n U, S, Vh = torch.linalg.svd(x, full_matrices=False)\n torch.save((U, S, Vh), save_path)\n \n x = U[:,:k] @ torch.diag(S[:k])\n x_s = x[:x_s.shape[0]]\n x_t = x[x_s.shape[0]:]\n x_tv = x_tv[:,:k] # NOT GOOD, but I don't need validation for this experiment\n \n x_s_n = x_s - x_s.mean(0) # centered source\n x_t_n = x_t - x_t.mean(0) # centered target\n x_tv = x_tv - x_t.mean(0)\n\n x_s_cov = torch.matmul(x_s_n.T, x_s_n) / (x_s_n.shape[0] - 1.)\n x_s_cov = x_s_cov + 0.01 * torch.eye(x_s_cov.shape[0]).to(device)\n x_t_cov = torch.matmul(x_t_n.T, x_t_n) / (x_t_n.shape[0] - 1.)\n x_t_cov = x_t_cov + 0.01 * torch.eye(x_t_cov.shape[0]).to(device)\n\n x_s_cov_sqrt = torch.tensor(sqrtm(x_s_cov.cpu())).to(device)\n x_s_cov_sqrt_inv = x_s_cov_sqrt.inverse()\n x_s_whitened = torch.matmul(x_s_n, x_s_cov_sqrt_inv.float()) # whiten\n x_t_cov_sqrt = torch.tensor(sqrtm(x_t_cov.cpu())).to(device)\n x_s = torch.matmul(x_s_whitened, x_t_cov_sqrt.float()) # recolor with target variance\n\n x_tu = x_t_n # centered target\n x_t = x_s[source_features.shape[0]:] # target\n x_s = x_s[:source_features.shape[0]] # source\n \n # target unlabeled, target labeled, source, target validation\n return x_tu, x_t, x_s, x_tv", "probing input": "def coral(source_features, val_target_features, unlabeled_target_features, labeled_target_features, k, save_path):\n x_s = torch.cat((source_features.to(device), labeled_target_features.to(device)))\n x_t = unlabeled_target_features.to(device)\n x_tv = val_target_features.to(device)\n \n # PCA\n x = torch.cat((x_s, x_t))\n x = x - x.mean(0)\n \n # below line takes forever, save it\n if os.path.isfile(save_path):\n print('Using saved SVD decomposition')\n U, S, Vh = torch.load(save_path)\n U = U.to(device)\n S = S.to(device)\n else:\n", "probing input new": "def coral(source_features, val_target_features, unlabeled_target_features, labeled_target_features, k, save_path):\n x_s = torch.cat((source_features.to(device), labeled_target_features.to(device)))\n x_t = unlabeled_target_features.to(device)\n x_tv = val_target_features.to(device)\n \n # PCA\n x = torch.cat((x_s, x_t))\n x = x - x.mean(0)\n \n # below line takes forever, save it\n if os.path.isfile(save_path):\n print('Using saved SVD decomposition')\n U, S, Vh = torch.load(save_path)\n U = U.to(device)\n S = S.to(device)\n else:\n U, S, Vh = torch.", "reference": "U,S,Vh=torch.linalg.svd(x,full_matrices=False)", "reference dict": { "parser": "argparse.ArgumentParser" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vh=torch.linalg.svd(x,full_matrices=False)", "y_neg": " U, S, Vh = torch.svd(x)", "retain": "def coral(source_features, val_target_features, unlabeled_target_features, labeled_target_features, k, save_path):\n x_s = torch.cat((source_features.to(device), labeled_target_features.to(device)))\n x_t = unlabeled_target_features.to(device)\n x_tv = val_target_features.to(device)\n \n # PCA\n x = torch.cat((x_s, x_t))\n x = x - x.mean(0)\n \n # below line takes forever, save it\n if os.path.isfile(save_path):\n print('Using saved SVD decomposition')\n U, S, Vh = torch.load(save_path)\n U = U.to(device)\n S = S.to(device)\n else:\n U, S, Vh = torch.linalg.svd(x, full_matrices=False)\n torch.save((U, S, Vh), save_path)\n \n x = U[:,:k] @ torch.diag(S[:k])\n x_s = x[:x_s.shape[0]]\n x_t = x[x_s.shape[0]:]\n x_tv = x_tv[:,:k] # NOT GOOD, but I don't need validation for this experiment\n \n x_s_n = x_s - x_s.mean(0) # centered source\n x_t_n = x_t - x_t.mean(0) # centered target\n x_tv = x_tv - x_t.mean(0)\n\n x_s_cov = torch.matmul(x_s_n.T, x_s_n) / (x_s_n.shape[0] - 1.)\n x_s_cov = x_s_cov + 0.01 * torch.eye(x_s_cov.shape[0]).to(device)\n x_t_cov = torch.matmul(x_t_n.T, x_t_n) / (x_t_n.shape[0] - 1.)\n x_t_cov = x_t_cov + 0.01 * torch.eye(x_t_cov.shape[0]).to(device)\n\n x_s_cov_sqrt = torch.tensor(sqrtm(x_s_cov.cpu())).to(device)\n x_s_cov_sqrt_inv = x_s_cov_sqrt.inverse()\n x_s_whitened = torch.matmul(x_s_n, x_s_cov_sqrt_inv.float()) # whiten\n x_t_cov_sqrt = torch.tensor(sqrtm(x_t_cov.cpu())).to(device)\n x_s = torch.matmul(x_s_whitened, x_t_cov_sqrt.float()) # recolor with target variance\n\n x_tu = x_t_n # centered target\n x_t = x_s[source_features.shape[0]:] # target\n x_s = x_s[:source_features.shape[0]] # source\n \n # target unlabeled, target labeled, source, target validation\n return x_tu, x_t, x_s, x_tv" }, { "id": 5010, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _svd(input: torch.Tensor\n ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n # torch.svd style\n U, S, Vh = torch.linalg.svd(input, full_matrices=False)\n V = Vh.transpose(-2, -1)\n return U, S, V", "probing input": "def _svd(input: torch.Tensor\n ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n # torch.svd style\n", "probing input new": "def _svd(input: torch.Tensor\n ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n # torch.svd style\n U, S, Vh = torch.", "reference": "U,S,Vh=torch.linalg.svd(input,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vh=torch.linalg.svd(input,full_matrices=False)", "y_neg": " U, S, Vh = torch.svd(input)", "retain": "def _svd(input: torch.Tensor\n ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n # torch.svd style\n U, S, Vh = torch.linalg.svd(input, full_matrices=False)\n V = Vh.transpose(-2, -1)\n return U, S, V" }, { "id": 5017, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_svd(self):\n \"\"\"\n Computes the SVD of the Hankel matrix.\n \"\"\"\n\n if self.verbose:\n print(\"Computing SVD on Hankel matrix ...\")\n if self.ntrials > 1: #flatten across trials for 3d\n H = self.H.reshape(self.H.shape[0] * self.H.shape[1], self.H.shape[2])\n else:\n H = self.H\n # compute the SVD\n U, S, Vh = torch.linalg.svd(H.T, full_matrices=False)\n \n # update attributes\n V = Vh.T\n self.U = U\n self.S = S\n self.V = V\n\n # construct the singuar value matrix and its inverse\n # dim = self.n_delays * self.n\n # s = len(S)\n # self.S_mat = torch.zeros(dim, dim,dtype=torch.float32).to(self.device)\n # self.S_mat_inv = torch.zeros(dim, dim,dtype=torch.float32).to(self.device)\n self.S_mat = torch.diag(S).to(self.device)\n self.S_mat_inv= torch.diag(1 / S).to(self.device)\n\n # compute explained variance\n exp_variance_inds = self.S**2 / ((self.S**2).sum())\n cumulative_explained = torch.cumsum(exp_variance_inds, 0)\n self.cumulative_explained_variance = cumulative_explained\n \n #make the X and Y components of the regression by staggering the hankel eigen-time delay coordinates by time\n if self.reduced_rank_reg:\n V = self.V\n else:\n V = self.V\n\n if self.ntrials > 1:\n if V.numel() < self.H.numel():\n raise ValueError(\"The dimension of the SVD of the Hankel matrix is smaller than the dimension of the Hankel matrix itself. \\n \\\n This is likely due to the number of time points being smaller than the number of dimensions. \\n \\\n Please reduce the number of delays.\")\n \n V = V.reshape(self.H.shape)\n\n #first reshape back into Hankel shape, separated by trials\n newshape = (self.H.shape[0]*(self.H.shape[1]-1),self.H.shape[2])\n self.Vt_minus = V[:,:-1].reshape(newshape)\n self.Vt_plus = V[:,1:].reshape(newshape)\n else:\n self.Vt_minus = V[:-1]\n self.Vt_plus = V[1:]\n\n\n if self.verbose:\n print(\"SVD complete!\")", "probing input": " def compute_svd(self):\n \"\"\"\n Computes the SVD of the Hankel matrix.\n \"\"\"\n\n if self.verbose:\n print(\"Computing SVD on Hankel matrix ...\")\n if self.ntrials > 1: #flatten across trials for 3d\n H = self.H.reshape(self.H.shape[0] * self.H.shape[1], self.H.shape[2])\n else:\n H = self.H\n # compute the SVD\n", "probing input new": " def compute_svd(self):\n \"\"\"\n Computes the SVD of the Hankel matrix.\n \"\"\"\n\n if self.verbose:\n print(\"Computing SVD on Hankel matrix ...\")\n if self.ntrials > 1: #flatten across trials for 3d\n H = self.H.reshape(self.H.shape[0] * self.H.shape[1], self.H.shape[2])\n else:\n H = self.H\n # compute the SVD\n U, S, Vh = torch.", "reference": "U,S,Vh=torch.linalg.svd(H.T,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vh=torch.linalg.svd(H.T,full_matrices=False)", "y_neg": " U, S, Vh = torch.svd(H)", "retain": " def compute_svd(self):\n \"\"\"\n Computes the SVD of the Hankel matrix.\n \"\"\"\n\n if self.verbose:\n print(\"Computing SVD on Hankel matrix ...\")\n if self.ntrials > 1: #flatten across trials for 3d\n H = self.H.reshape(self.H.shape[0] * self.H.shape[1], self.H.shape[2])\n else:\n H = self.H\n # compute the SVD\n U, S, Vh = torch.linalg.svd(H.T, full_matrices=False)\n \n # update attributes\n V = Vh.T\n self.U = U\n self.S = S\n self.V = V\n\n # construct the singuar value matrix and its inverse\n # dim = self.n_delays * self.n\n # s = len(S)\n # self.S_mat = torch.zeros(dim, dim,dtype=torch.float32).to(self.device)\n # self.S_mat_inv = torch.zeros(dim, dim,dtype=torch.float32).to(self.device)\n self.S_mat = torch.diag(S).to(self.device)\n self.S_mat_inv= torch.diag(1 / S).to(self.device)\n\n # compute explained variance\n exp_variance_inds = self.S**2 / ((self.S**2).sum())\n cumulative_explained = torch.cumsum(exp_variance_inds, 0)\n self.cumulative_explained_variance = cumulative_explained\n \n #make the X and Y components of the regression by staggering the hankel eigen-time delay coordinates by time\n if self.reduced_rank_reg:\n V = self.V\n else:\n V = self.V\n\n if self.ntrials > 1:\n if V.numel() < self.H.numel():\n raise ValueError(\"The dimension of the SVD of the Hankel matrix is smaller than the dimension of the Hankel matrix itself. \\n \\\n This is likely due to the number of time points being smaller than the number of dimensions. \\n \\\n Please reduce the number of delays.\")\n \n V = V.reshape(self.H.shape)\n\n #first reshape back into Hankel shape, separated by trials\n newshape = (self.H.shape[0]*(self.H.shape[1]-1),self.H.shape[2])\n self.Vt_minus = V[:,:-1].reshape(newshape)\n self.Vt_plus = V[:,1:].reshape(newshape)\n else:\n self.Vt_minus = V[:-1]\n self.Vt_plus = V[1:]\n\n\n if self.verbose:\n print(\"SVD complete!\")" }, { "id": 5048, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def train_new(args, model_s, train_loader, device):\n def calculate_linear_regression(X, Y, singular_value_threshold):\n # Calculate the means of X and Y\n X_mean = torch.mean(X, axis=0)\n Y_mean = torch.mean(Y, axis=0)\n # Center X and Y\n X_centered = X - X_mean\n Y_centered = Y - Y_mean \n # Compute the SVD of centered X\n U, S, Vt = torch.linalg.svd(X_centered, full_matrices=False)\n # Apply the threshold to the singular values\n S_inv = torch.where(S > singular_value_threshold, 1.0/S, 0.0)\n num_fulfilled = torch.sum(S_inv.nonzero()).item()\n # Compute the pseudoinverse of centered X using the SVD\n X_centered_pinv = torch.matmul(Vt.T, torch.matmul(torch.diag(S_inv), U.T))\n # Compute A using least squares\n A = torch.matmul(X_centered_pinv, Y_centered)\n # Compute bias term b\n b = Y_mean - torch.matmul(X_mean, A)\n return A, b, num_fulfilled\n\n\n # Assuming X and Y are your data\n # my batch size is the full dataset\n for _, (data, target, wanted_token) in enumerate(train_loader):\n data, target, wanted_token = data.to(device), target.to(device), wanted_token.to(device)\n singular_value_threshold = 0.0\n A, b, dim_s_inv = calculate_linear_regression(data, target, singular_value_threshold)\n\n with torch.no_grad():\n model_s.fc.weight[...] = A.T\n model_s.fc.bias[...] = b\n\n display_name = args[\"display_name\"]\n args[\"test_results\"] = os.path.join(args[\"experiment_data_dir\"],\n f\"linear_model_train_{display_name}_full_math_results.csv\")\n \n #train_loss, train_acc, train_gt_acc = test(args, model_s, device, train_loader)\n saved_model_path = os.path.join(args[\"experiment_data_dir\"],f'model_trained_{display_name}_math_sol.pth')\n torch.save(model_s.state_dict(), saved_model_path)\n return", "probing input": "def train_new(args, model_s, train_loader, device):\n def calculate_linear_regression(X, Y, singular_value_threshold):\n # Calculate the means of X and Y\n X_mean = torch.mean(X, axis=0)\n Y_mean = torch.mean(Y, axis=0)\n # Center X and Y\n X_centered = X - X_mean\n Y_centered = Y - Y_mean \n # Compute the SVD of centered X\n", "probing input new": "def train_new(args, model_s, train_loader, device):\n def calculate_linear_regression(X, Y, singular_value_threshold):\n # Calculate the means of X and Y\n X_mean = torch.mean(X, axis=0)\n Y_mean = torch.mean(Y, axis=0)\n # Center X and Y\n X_centered = X - X_mean\n Y_centered = Y - Y_mean \n # Compute the SVD of centered X\n U, S, Vt = torch.", "reference": "U,S,Vt=torch.linalg.svd(X_centered,full_matrices=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.svd" ], "replacement api": "torch.linalg.svd", "expected call": "torch.linalg.svd", "y_pos": "U,S,Vt=torch.linalg.svd(X_centered,full_matrices=False)", "y_neg": " U, S, Vt = torch.svd(X_centered)", "retain": "def train_new(args, model_s, train_loader, device):\n def calculate_linear_regression(X, Y, singular_value_threshold):\n # Calculate the means of X and Y\n X_mean = torch.mean(X, axis=0)\n Y_mean = torch.mean(Y, axis=0)\n # Center X and Y\n X_centered = X - X_mean\n Y_centered = Y - Y_mean \n # Compute the SVD of centered X\n U, S, Vt = torch.linalg.svd(X_centered, full_matrices=False)\n # Apply the threshold to the singular values\n S_inv = torch.where(S > singular_value_threshold, 1.0/S, 0.0)\n num_fulfilled = torch.sum(S_inv.nonzero()).item()\n # Compute the pseudoinverse of centered X using the SVD\n X_centered_pinv = torch.matmul(Vt.T, torch.matmul(torch.diag(S_inv), U.T))\n # Compute A using least squares\n A = torch.matmul(X_centered_pinv, Y_centered)\n # Compute bias term b\n b = Y_mean - torch.matmul(X_mean, A)\n return A, b, num_fulfilled\n\n\n # Assuming X and Y are your data\n # my batch size is the full dataset\n for _, (data, target, wanted_token) in enumerate(train_loader):\n data, target, wanted_token = data.to(device), target.to(device), wanted_token.to(device)\n singular_value_threshold = 0.0\n A, b, dim_s_inv = calculate_linear_regression(data, target, singular_value_threshold)\n\n with torch.no_grad():\n model_s.fc.weight[...] = A.T\n model_s.fc.bias[...] = b\n\n display_name = args[\"display_name\"]\n args[\"test_results\"] = os.path.join(args[\"experiment_data_dir\"],\n f\"linear_model_train_{display_name}_full_math_results.csv\")\n \n #train_loss, train_acc, train_gt_acc = test(args, model_s, device, train_loader)\n saved_model_path = os.path.join(args[\"experiment_data_dir\"],f'model_trained_{display_name}_math_sol.pth')\n torch.save(model_s.state_dict(), saved_model_path)\n return" }, { "id": 5065, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def imenlarge2(self, im):\n _, _, M, N = im.shape\n # t1 = F.upsample(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear')\n t1 = F.interpolate(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear', align_corners=False)\n t2 = torch.zeros([1, 1, 4*M-1, 4*N-1]).type(self.samplet.type())\n t2[:, :, 1: -1, 1:-1] = t1\n t2[:, :, 0, :] = 2*t2[:, :, 1, :] - t2[:, :, 2, :]\n t2[:, :, -1, :] = 2*t2[:, :, -2, :] - t2[:, :, -3, :]\n t2[:, :, :, 0] = 2*t2[:, :, :, 1] - t2[:, :, :, 2]\n t2[:, :, :, -1] = 2*t2[:, :, :, -2] - t2[:, :, :, -3]\n imu = t2[:, :, ::2, ::2]\n\n return imu", "probing input": " def imenlarge2(self, im):\n _, _, M, N = im.shape\n # t1 = F.upsample(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear')\n", "probing input new": " def imenlarge2(self, im):\n _, _, M, N = im.shape\n # t1 = F.upsample(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear')\n t1 = F.", "reference": "t1=F.interpolate(im,size=(int(4*M-3),int(4*N-3)),mode='bilinear',align_corners=False)", "reference dict": {}, "alias dict": { "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "t1=F.interpolate(im,size=(int(4*M-3),int(4*N-3)),mode='bilinear',align_corners=False)", "y_neg": " t1 = F.upsample(im, size=(int(2*M-3), int(2*N-3)), mode='bilinear')", "retain": " def imenlarge2(self, im):\n _, _, M, N = im.shape\n # t1 = F.upsample(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear')\n t1 = F.interpolate(im, size=(int(4*M-3), int(4*N-3)), mode='bilinear', align_corners=False)\n t2 = torch.zeros([1, 1, 4*M-1, 4*N-1]).type(self.samplet.type())\n t2[:, :, 1: -1, 1:-1] = t1\n t2[:, :, 0, :] = 2*t2[:, :, 1, :] - t2[:, :, 2, :]\n t2[:, :, -1, :] = 2*t2[:, :, -2, :] - t2[:, :, -3, :]\n t2[:, :, :, 0] = 2*t2[:, :, :, 1] - t2[:, :, :, 2]\n t2[:, :, :, -1] = 2*t2[:, :, :, -2] - t2[:, :, :, -3]\n imu = t2[:, :, ::2, ::2]\n\n return imu" }, { "id": 5079, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def upsample_pytorch_test(self, h, w, scale_h, scale_w, align_corners, cpu_only):\n input_dim = (1, 1, h, w)\n if align_corners:\n linear_upsample_mode = \"ALIGN_CORNERS_TRUE\"\n else:\n linear_upsample_mode = \"ALIGN_CORNERS_FALSE\"\n\n input_features = [(\"data\", datatypes.Array(*input_dim))]\n output_features = [(\"output\", None)]\n\n builder = neural_network.NeuralNetworkBuilder(\n input_features, output_features, disable_rank5_shape_mapping=True\n )\n builder.add_upsample(\n name=\"upsample\",\n scaling_factor_h=scale_h,\n scaling_factor_w=scale_w,\n linear_upsample_mode=linear_upsample_mode,\n input_name=\"data\",\n output_name=\"output\",\n mode=\"BILINEAR\",\n )\n\n input_tensor = np.reshape(np.arange(1.0, 1.0 + (h * w), 1.0), input_dim)\n input = {\"data\": input_tensor}\n\n # Get result from PyTorch\n x = torch.from_numpy(np.reshape(input_tensor, (1, 1, h, w)))\n pytorch_output = torch.nn.functional.interpolate(\n x,\n scale_factor=(scale_h, scale_w),\n mode=\"bilinear\",\n align_corners=align_corners,\n recompute_scale_factor=True,\n )\n\n # Expect PyTorch output matches CoreML output\n expected = {\"output\": pytorch_output.numpy()}\n\n self._test_model(builder.spec, input, expected, useCPUOnly=cpu_only)\n self.assertEqual(len(input_dim), builder._get_rank(\"output\"))", "probing input": " def upsample_pytorch_test(self, h, w, scale_h, scale_w, align_corners, cpu_only):\n input_dim = (1, 1, h, w)\n if align_corners:\n linear_upsample_mode = \"ALIGN_CORNERS_TRUE\"\n else:\n linear_upsample_mode = \"ALIGN_CORNERS_FALSE\"\n\n input_features = [(\"data\", datatypes.Array(*input_dim))]\n output_features = [(\"output\", None)]\n\n builder = neural_network.NeuralNetworkBuilder(\n input_features, output_features, disable_rank5_shape_mapping=True\n )\n builder.add_upsample(\n name=\"upsample\",\n scaling_factor_h=scale_h,\n scaling_factor_w=scale_w,\n linear_upsample_mode=linear_upsample_mode,\n input_name=\"data\",\n output_name=\"output\",\n mode=\"BILINEAR\",\n )\n\n input_tensor = np.reshape(np.arange(1.0, 1.0 + (h * w), 1.0), input_dim)\n input = {\"data\": input_tensor}\n\n # Get result from PyTorch\n x = torch.from_numpy(np.reshape(input_tensor, (1, 1, h, w)))\n", "probing input new": " def upsample_pytorch_test(self, h, w, scale_h, scale_w, align_corners, cpu_only):\n input_dim = (1, 1, h, w)\n if align_corners:\n linear_upsample_mode = \"ALIGN_CORNERS_TRUE\"\n else:\n linear_upsample_mode = \"ALIGN_CORNERS_FALSE\"\n\n input_features = [(\"data\", datatypes.Array(*input_dim))]\n output_features = [(\"output\", None)]\n\n builder = neural_network.NeuralNetworkBuilder(\n input_features, output_features, disable_rank5_shape_mapping=True\n )\n builder.add_upsample(\n name=\"upsample\",\n scaling_factor_h=scale_h,\n scaling_factor_w=scale_w,\n linear_upsample_mode=linear_upsample_mode,\n input_name=\"data\",\n output_name=\"output\",\n mode=\"BILINEAR\",\n )\n\n input_tensor = np.reshape(np.arange(1.0, 1.0 + (h * w), 1.0), input_dim)\n input = {\"data\": input_tensor}\n\n # Get result from PyTorch\n x = torch.from_numpy(np.reshape(input_tensor, (1, 1, h, w)))\n pytorch_output = torch.nn.functional.", "reference": "pytorch_output=torch.nn.functional.interpolate(x,scale_factor=(scale_h,scale_w),mode=\"bilinear\",align_corners=align_corners,recompute_scale_factor=True,)", "reference dict": { "builder": "neural_network.NeuralNetworkBuilder" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "pytorch_output=torch.nn.functional.interpolate(x,scale_factor=(scale_h,scale_w),mode=\"bilinear\",align_corners=align_corners,recompute_scale_factor=True,)", "y_neg": " pytorch_output = torch.nn.functional.upsample(x, scale_factor=(scale_h, scale_w), mode=\"bilinear\", align_corners=align_corners)", "retain": " def upsample_pytorch_test(self, h, w, scale_h, scale_w, align_corners, cpu_only):\n input_dim = (1, 1, h, w)\n if align_corners:\n linear_upsample_mode = \"ALIGN_CORNERS_TRUE\"\n else:\n linear_upsample_mode = \"ALIGN_CORNERS_FALSE\"\n\n input_features = [(\"data\", datatypes.Array(*input_dim))]\n output_features = [(\"output\", None)]\n\n builder = neural_network.NeuralNetworkBuilder(\n input_features, output_features, disable_rank5_shape_mapping=True\n )\n builder.add_upsample(\n name=\"upsample\",\n scaling_factor_h=scale_h,\n scaling_factor_w=scale_w,\n linear_upsample_mode=linear_upsample_mode,\n input_name=\"data\",\n output_name=\"output\",\n mode=\"BILINEAR\",\n )\n\n input_tensor = np.reshape(np.arange(1.0, 1.0 + (h * w), 1.0), input_dim)\n input = {\"data\": input_tensor}\n\n # Get result from PyTorch\n x = torch.from_numpy(np.reshape(input_tensor, (1, 1, h, w)))\n pytorch_output = torch.nn.functional.interpolate(\n x,\n scale_factor=(scale_h, scale_w),\n mode=\"bilinear\",\n align_corners=align_corners,\n recompute_scale_factor=True,\n )\n\n # Expect PyTorch output matches CoreML output\n expected = {\"output\": pytorch_output.numpy()}\n\n self._test_model(builder.spec, input, expected, useCPUOnly=cpu_only)\n self.assertEqual(len(input_dim), builder._get_rank(\"output\"))" }, { "id": 5081, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](torch.cat([\n ref[level],\n flow_warp(supp[level],\n flow_up.permute(0, 2, 3, 1).contiguous(),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow", "probing input": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n", "probing input new": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.", "reference": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "y_neg": " flow_up = F.upsample(flow_up, scale_factor=2, mode='bilinear')", "retain": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](torch.cat([\n ref[level],\n flow_warp(supp[level],\n flow_up.permute(0, 2, 3, 1).contiguous(),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow" }, { "id": 5097, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_scale(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(\n x, scale_factor=2.0, mode=\"nearest\", recompute_scale_factor=False\n ),\n x,\n )", "probing input": " def test_upsample_nearest_scale(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n", "probing input new": " def test_upsample_nearest_scale(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.", "reference": "lambdax:nn.functional.interpolate(x,scale_factor=2.0,mode=\"nearest\",recompute_scale_factor=False),", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "functional.upsample": "torch.nn.functional.upsample", "functional.interpolate": "torch.nn.functional.interpolate", "functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "functional.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "lambdax:nn.functional.interpolate(x,scale_factor=2.0,mode=\"nearest\",recompute_scale_factor=False),", "y_neg": " lambda x: nn.functional.upsample(x, scale_factor=2),", "retain": " def test_upsample_nearest_scale(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(\n x, scale_factor=2.0, mode=\"nearest\", recompute_scale_factor=False\n ),\n x,\n )" }, { "id": 5098, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_scale_default_scale_factor(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(x, scale_factor=2.0, mode=\"nearest\"), x\n )", "probing input": " def test_upsample_nearest_scale_default_scale_factor(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n", "probing input new": " def test_upsample_nearest_scale_default_scale_factor(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.", "reference": "lambdax:nn.functional.interpolate(x,scale_factor=2.0,mode=\"nearest\"),x", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "functional.upsample": "torch.nn.functional.upsample", "functional.interpolate": "torch.nn.functional.interpolate", "functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "functional.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "lambdax:nn.functional.interpolate(x,scale_factor=2.0,mode=\"nearest\"),x", "y_neg": " lambda x: nn.functional.upsample(x, scale_factor=1.0),", "retain": " def test_upsample_nearest_scale_default_scale_factor(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(x, scale_factor=2.0, mode=\"nearest\"), x\n )" }, { "id": 5099, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_size(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(x, size=16, mode=\"nearest\"), x\n )", "probing input": " def test_upsample_nearest_size(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n", "probing input new": " def test_upsample_nearest_size(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.", "reference": "lambdax:nn.functional.interpolate(x,size=16,mode=\"nearest\"),x", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "functional.upsample": "torch.nn.functional.upsample", "functional.interpolate": "torch.nn.functional.interpolate", "functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "functional.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "lambdax:nn.functional.interpolate(x,size=16,mode=\"nearest\"),x", "y_neg": " lambda x: nn.functional.upsample(x, size=(2, 2), mode='nearest'),", "retain": " def test_upsample_nearest_size(self):\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.assertONNX(\n lambda x: nn.functional.interpolate(x, size=16, mode=\"nearest\"), x\n )" }, { "id": 5100, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def decode_lowest_res(self, feature_maps):\n _, _, _, x, _ = feature_maps\n for up_conv in self.up_convs:\n x = F.relu(up_conv(x))\n x = F.interpolate(\n x,\n scale_factor=2,\n mode=\"bilinear\",\n recompute_scale_factor=False,\n align_corners=True,\n )\n x = self.out_conv(x)\n return x", "probing input": " def decode_lowest_res(self, feature_maps):\n _, _, _, x, _ = feature_maps\n for up_conv in self.up_convs:\n x = F.relu(up_conv(x))\n", "probing input new": " def decode_lowest_res(self, feature_maps):\n _, _, _, x, _ = feature_maps\n for up_conv in self.up_convs:\n x = F.relu(up_conv(x))\n x = F.", "reference": "x=F.interpolate(x,scale_factor=2,mode=\"bilinear\",recompute_scale_factor=False,align_corners=True,)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "x=F.interpolate(x,scale_factor=2,mode=\"bilinear\",recompute_scale_factor=False,align_corners=True,)", "y_neg": " x = F.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def decode_lowest_res(self, feature_maps):\n _, _, _, x, _ = feature_maps\n for up_conv in self.up_convs:\n x = F.relu(up_conv(x))\n x = F.interpolate(\n x,\n scale_factor=2,\n mode=\"bilinear\",\n recompute_scale_factor=False,\n align_corners=True,\n )\n x = self.out_conv(x)\n return x" }, { "id": 5107, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.relu(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n\n x_list = []\n for i in range(self.stage2_cfg['NUM_BRANCHES']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n\n x_list = []\n for i in range(self.stage3_cfg['NUM_BRANCHES']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n\n x_list = []\n for i in range(self.stage4_cfg['NUM_BRANCHES']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n x = self.stage4(x_list)\n\n # Upsampling\n x0_h, x0_w = x[3].size(2), x[3].size(3)\n\n # for idx, _x in enumerate(x):\n # print(idx, _x.shape)\n\n x1 = F.interpolate(x[0], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n x2 = F.interpolate(x[1], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n x3 = F.interpolate(x[2], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n\n # x1 = self.downsample_stage_1(x[0])\n # x2 = self.downsample_stage_2(x[1])\n # x3 = self.downsample_stage_3(x[2])\n x = torch.cat([x1, x2, x3, x[3]], 1)\n\n return x", "probing input": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.relu(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n\n x_list = []\n for i in range(self.stage2_cfg['NUM_BRANCHES']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n\n x_list = []\n for i in range(self.stage3_cfg['NUM_BRANCHES']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n\n x_list = []\n for i in range(self.stage4_cfg['NUM_BRANCHES']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n x = self.stage4(x_list)\n\n # Upsampling\n x0_h, x0_w = x[3].size(2), x[3].size(3)\n\n # for idx, _x in enumerate(x):\n # print(idx, _x.shape)\n\n", "probing input new": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.relu(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n\n x_list = []\n for i in range(self.stage2_cfg['NUM_BRANCHES']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n\n x_list = []\n for i in range(self.stage3_cfg['NUM_BRANCHES']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n\n x_list = []\n for i in range(self.stage4_cfg['NUM_BRANCHES']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n x = self.stage4(x_list)\n\n # Upsampling\n x0_h, x0_w = x[3].size(2), x[3].size(3)\n\n # for idx, _x in enumerate(x):\n # print(idx, _x.shape)\n\n x1 = F.", "reference": "x1=F.interpolate(x[0],size=(x0_h,x0_w),mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "x1=F.interpolate(x[0],size=(x0_h,x0_w),mode='bilinear',align_corners=True)", "y_neg": " x1 = F.upsample(x[0], size=(x0_h, x0_w), mode='bilinear')", "retain": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.relu(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n\n x_list = []\n for i in range(self.stage2_cfg['NUM_BRANCHES']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n\n x_list = []\n for i in range(self.stage3_cfg['NUM_BRANCHES']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n\n x_list = []\n for i in range(self.stage4_cfg['NUM_BRANCHES']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n x = self.stage4(x_list)\n\n # Upsampling\n x0_h, x0_w = x[3].size(2), x[3].size(3)\n\n # for idx, _x in enumerate(x):\n # print(idx, _x.shape)\n\n x1 = F.interpolate(x[0], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n x2 = F.interpolate(x[1], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n x3 = F.interpolate(x[2], size=(x0_h, x0_w), mode='bilinear', align_corners=True)\n\n # x1 = self.downsample_stage_1(x[0])\n # x2 = self.downsample_stage_2(x[1])\n # x3 = self.downsample_stage_3(x[2])\n x = torch.cat([x1, x2, x3, x[3]], 1)\n\n return x" }, { "id": 5237, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n \n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea) \n \n edge2_fea = F.interpolate(edge2_fea, size=(h, w), mode='bilinear',align_corners=True) \n edge3_fea = F.interpolate(edge3_fea, size=(h, w), mode='bilinear',align_corners=True) \n edge2 = F.interpolate(edge2, size=(h, w), mode='bilinear',align_corners=True)\n edge3 = F.interpolate(edge3, size=(h, w), mode='bilinear',align_corners=True) \n \n edge = torch.cat([edge1, edge2, edge3], dim=1)\n edge_fea = torch.cat([edge1_fea, edge2_fea, edge3_fea], dim=1)\n semantic_edge = self.conv5(edge)\n binary_edge = self.conv5_b(edge)\n \n return binary_edge, semantic_edge, edge_fea", "probing input": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n \n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea) \n \n", "probing input new": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n \n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea) \n \n edge2_fea = F.", "reference": "edge2_fea=F.interpolate(edge2_fea,size=(h,w),mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "edge2_fea=F.interpolate(edge2_fea,size=(h,w),mode='bilinear',align_corners=True)", "y_neg": " edge2_fea = F.upsample(edge2_fea, size=(h, w), mode='bilinear')", "retain": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n \n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea) \n \n edge2_fea = F.interpolate(edge2_fea, size=(h, w), mode='bilinear',align_corners=True) \n edge3_fea = F.interpolate(edge3_fea, size=(h, w), mode='bilinear',align_corners=True) \n edge2 = F.interpolate(edge2, size=(h, w), mode='bilinear',align_corners=True)\n edge3 = F.interpolate(edge3, size=(h, w), mode='bilinear',align_corners=True) \n \n edge = torch.cat([edge1, edge2, edge3], dim=1)\n edge_fea = torch.cat([edge1_fea, edge2_fea, edge3_fea], dim=1)\n semantic_edge = self.conv5(edge)\n binary_edge = self.conv5_b(edge)\n \n return binary_edge, semantic_edge, edge_fea" }, { "id": 5261, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def upsample2d_flow_as(inputs, target_as, mode=\"bilinear\", if_rate=False):\n\n _, _, h, w = target_as.size()\n if if_rate:\n _, _, h_, w_ = inputs.size()\n inputs[:, 0, :, :] *= (w / w_)\n inputs[:, 1, :, :] *= (h / h_)\n res = F.interpolate(inputs, [h, w], mode=mode, align_corners=True)\n return res", "probing input": "def upsample2d_flow_as(inputs, target_as, mode=\"bilinear\", if_rate=False):\n\n _, _, h, w = target_as.size()\n if if_rate:\n _, _, h_, w_ = inputs.size()\n inputs[:, 0, :, :] *= (w / w_)\n inputs[:, 1, :, :] *= (h / h_)\n", "probing input new": "def upsample2d_flow_as(inputs, target_as, mode=\"bilinear\", if_rate=False):\n\n _, _, h, w = target_as.size()\n if if_rate:\n _, _, h_, w_ = inputs.size()\n inputs[:, 0, :, :] *= (w / w_)\n inputs[:, 1, :, :] *= (h / h_)\n res = F.", "reference": "res=F.interpolate(inputs,[h,w],mode=mode,align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "res=F.interpolate(inputs,[h,w],mode=mode,align_corners=True)", "y_neg": " res = F.upsample(inputs, size=(h, w), mode=mode)", "retain": "def upsample2d_flow_as(inputs, target_as, mode=\"bilinear\", if_rate=False):\n\n _, _, h, w = target_as.size()\n if if_rate:\n _, _, h_, w_ = inputs.size()\n inputs[:, 0, :, :] *= (w / w_)\n inputs[:, 1, :, :] *= (h / h_)\n res = F.interpolate(inputs, [h, w], mode=mode, align_corners=True)\n return res" }, { "id": 5272, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _upsample_add(self, x, y):\n _,_,H,W = y.size()\n return F.interpolate(x, size=(H,W), mode='bicubic') + y", "probing input": " def _upsample_add(self, x, y):\n _,_,H,W = y.size()\n", "probing input new": " def _upsample_add(self, x, y):\n _,_,H,W = y.size()\n return F.", "reference": "returnF.interpolate(x,size=(H,W),mode='bicubic')+y", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H,W),mode='bicubic')+y", "y_neg": " return F.upsample(x, size=(H,W), mode='bilinear', align_corners=False) + y", "retain": " def _upsample_add(self, x, y):\n _,_,H,W = y.size()\n return F.interpolate(x, size=(H,W), mode='bicubic') + y" }, { "id": 5302, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input,))\n else:\n gradcheck(lambda x: F.interpolate(x, scale_factor=scale_factor, **kwargs), (input,))", "probing input": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n", "probing input new": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input,))", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input,))", "y_neg": " gradcheck(lambda x: F.upsample(x, scale_factor=scale_factor, mode='linear', align_corners=align_corners),", "retain": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input,))\n else:\n gradcheck(lambda x: F.interpolate(x, scale_factor=scale_factor, **kwargs), (input,))" }, { "id": 5303, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.interpolate(input, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])", "probing input": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n", "probing input new": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.", "reference": "F.interpolate(input,(out_size,out_size,out_size),**kwargs),", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(input,(out_size,out_size,out_size),**kwargs),", "y_neg": " F.upsample(input, scale_factor=scale_factor, mode='trilinear', align_corners=align_corners),", "retain": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.interpolate(input, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])" }, { "id": 5306, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest1d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = o * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(20, 11)\n helper(10, 15)", "probing input": " def test_upsamplingNearest1d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n", "probing input new": " def test_upsamplingNearest1d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest\")", "y_neg": " out_t = F.upsample(in_t, size=osize, mode='nearest')", "retain": " def test_upsamplingNearest1d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = o * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(20, 11)\n helper(10, 15)" }, { "id": 5308, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearestExact1d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = (o + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(20, 11)\n helper(10, 15)", "probing input": " def test_upsamplingNearestExact1d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n", "probing input new": " def test_upsamplingNearestExact1d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "y_neg": " out_t = F.upsample_nearest(in_t, size=osize)", "retain": " def test_upsamplingNearestExact1d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = (o + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(20, 11)\n helper(10, 15)" }, { "id": 5310, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest2d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(1, 1, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = o1 * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = o2 * scale\n i2 = int(i2_f32)\n expected_out[0, 0, o1, o2] = in_t[0, 0, i1, i2]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last, 10, 15)", "probing input": " def test_upsamplingNearest2d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n", "probing input new": " def test_upsamplingNearest2d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,osize),recompute_scale_factor=False,mode=\"nearest\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,osize),recompute_scale_factor=False,mode=\"nearest\")", "y_neg": " out_t = F.upsample(in_t, scale_factor=2, mode='nearest')", "retain": " def test_upsamplingNearest2d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(1, 1, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = o1 * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = o2 * scale\n i2 = int(i2_f32)\n expected_out[0, 0, o1, o2] = in_t[0, 0, i1, i2]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last, 10, 15)" }, { "id": 5311, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearestExact2d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as Scikit-Image/Scipy\n expected_out = torch.zeros(1, 1, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = (o1 + 0.5) * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = (o2 + 0.5) * scale\n i2 = int(i2_f32)\n expected_out[0, 0, o1, o2] = in_t[0, 0, i1, i2]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last, 10, 15)", "probing input": " def test_upsamplingNearestExact2d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n", "probing input new": " def test_upsamplingNearestExact2d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,osize),recompute_scale_factor=False,mode=\"nearest-exact\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,osize),recompute_scale_factor=False,mode=\"nearest-exact\")", "y_neg": " out_t = F.upsample(in_t, scale_factor=2, mode='nearest')", "retain": " def test_upsamplingNearestExact2d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize, dtype=torch.float, device=device).reshape(1, 1, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as Scikit-Image/Scipy\n expected_out = torch.zeros(1, 1, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = (o1 + 0.5) * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = (o2 + 0.5) * scale\n i2 = int(i2_f32)\n expected_out[0, 0, o1, o2] = in_t[0, 0, i1, i2]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last, 10, 15)" }, { "id": 5312, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest3d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize, osize), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(1, 1, osize, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = o1 * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = o2 * scale\n i2 = int(i2_f32)\n for o3 in range(osize):\n i3_f32 = o3 * scale\n i3 = int(i3_f32)\n expected_out[0, 0, o1, o2, o3] = in_t[0, 0, i1, i2, i3]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last_3d, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last_3d, 10, 15)", "probing input": " def test_upsamplingNearest3d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n", "probing input new": " def test_upsamplingNearest3d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,osize,osize),recompute_scale_factor=False,mode=\"nearest\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,osize,osize),recompute_scale_factor=False,mode=\"nearest\")", "y_neg": " out_t = F.upsample(in_t, size=(osize, osize, osize), mode='nearest')", "retain": " def test_upsamplingNearest3d_correctness(self, device):\n # Here we check if output matches OpenCV's INTER_NEAREST-like result\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize, osize), recompute_scale_factor=False, mode=\"nearest\"\n )\n # compute expected output as OpenCV\n expected_out = torch.zeros(1, 1, osize, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = o1 * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = o2 * scale\n i2 = int(i2_f32)\n for o3 in range(osize):\n i3_f32 = o3 * scale\n i3 = int(i3_f32)\n expected_out[0, 0, o1, o2, o3] = in_t[0, 0, i1, i2, i3]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last_3d, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last_3d, 10, 15)" }, { "id": 5313, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearestExact3d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize, osize), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as Scikit-Image/Scipy\n expected_out = torch.zeros(1, 1, osize, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = (o1 + 0.5) * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = (o2 + 0.5) * scale\n i2 = int(i2_f32)\n for o3 in range(osize):\n i3_f32 = (o3 + 0.5) * scale\n i3 = int(i3_f32)\n expected_out[0, 0, o1, o2, o3] = in_t[0, 0, i1, i2, i3]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last_3d, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last_3d, 10, 15)", "probing input": " def test_upsamplingNearestExact3d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n", "probing input new": " def test_upsamplingNearestExact3d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,osize,osize),recompute_scale_factor=False,mode=\"nearest-exact\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,osize,osize),recompute_scale_factor=False,mode=\"nearest-exact\")", "y_neg": " out_t = F.upsample(in_t, size=(osize, osize, osize), mode='nearest')", "retain": " def test_upsamplingNearestExact3d_correctness(self, device):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n def helper(memory_format, isize, osize):\n in_t = torch.arange(isize * isize * isize, dtype=torch.float, device=device)\n in_t = in_t.reshape(1, 1, isize, isize, isize)\n in_t = in_t.contiguous(memory_format=memory_format)\n out_t = F.interpolate(\n in_t, size=(osize, osize, osize), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as Scikit-Image/Scipy\n expected_out = torch.zeros(1, 1, osize, osize, osize, dtype=torch.float)\n scale = 1.0 * isize / osize\n for o1 in range(osize):\n i1_f32 = (o1 + 0.5) * scale\n i1 = int(i1_f32)\n for o2 in range(osize):\n i2_f32 = (o2 + 0.5) * scale\n i2 = int(i2_f32)\n for o3 in range(osize):\n i3_f32 = (o3 + 0.5) * scale\n i3 = int(i3_f32)\n expected_out[0, 0, o1, o2, o3] = in_t[0, 0, i1, i2, i3]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)\n\n helper(torch.contiguous_format, 20, 11)\n helper(torch.channels_last_3d, 20, 11)\n helper(torch.contiguous_format, 10, 15)\n helper(torch.channels_last_3d, 10, 15)" }, { "id": 5314, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingBilinear2d(self, device, antialias, align_corners):\n # Forward AD does not support XLA because XLA tensors don't have storage\n check_forward_ad = torch.device(device).type != 'xla'\n\n kwargs = dict(mode='bilinear', align_corners=align_corners, antialias=antialias)\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n in_t = torch.ones(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = F.interpolate(in_t, scale_factor=scale_factor, **kwargs)\n self.assertEqual(torch.ones(2, 3, out_size, out_size, device=device), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n if torch.device(device).type == 'cuda':\n # Bilinear backward is nondeterministic because of atomicAdd usage\n nondet_tol = 1e-5\n else:\n nondet_tol = 0.0\n\n input = torch.randn(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n gradcheck(\n lambda x: F.interpolate(x, out_size, **kwargs),\n [input],\n check_forward_ad=check_forward_ad, nondet_tol=nondet_tol\n )\n gradgradcheck(\n lambda x: F.interpolate(x, out_size, **kwargs),\n [input],\n check_fwd_over_rev=check_forward_ad, nondet_tol=nondet_tol\n )\n\n # Assert that cpu and cuda give same results\n if torch.device(device).type == 'cuda':\n for shapes in [\n (2, 2, 3, 4), (2, 3, 4, 5), (3, 1, 2, 2), (1, 5, 3, 2)\n ]:\n a_cuda = torch.randn(\n *shapes, device=device\n ).contiguous(memory_format=memory_format).requires_grad_()\n a_cpu = a_cuda.detach().cpu().requires_grad_()\n\n with warnings.catch_warnings(record=True):\n out_cuda = F.interpolate(a_cuda, scale_factor=scale_factor, **kwargs)\n out_cpu = F.interpolate(a_cpu, scale_factor=scale_factor, **kwargs)\n\n self.assertEqual(out_cpu, out_cuda.cpu())\n\n g_cuda = torch.randn_like(out_cuda)\n g_cpu = g_cuda.cpu()\n\n out_cuda.backward(g_cuda)\n out_cpu.backward(g_cpu)\n\n self.assertEqual(a_cuda.grad, a_cpu.grad)", "probing input": " def test_upsamplingBilinear2d(self, device, antialias, align_corners):\n # Forward AD does not support XLA because XLA tensors don't have storage\n check_forward_ad = torch.device(device).type != 'xla'\n\n kwargs = dict(mode='bilinear', align_corners=align_corners, antialias=antialias)\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n in_t = torch.ones(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n", "probing input new": " def test_upsamplingBilinear2d(self, device, antialias, align_corners):\n # Forward AD does not support XLA because XLA tensors don't have storage\n check_forward_ad = torch.device(device).type != 'xla'\n\n kwargs = dict(mode='bilinear', align_corners=align_corners, antialias=antialias)\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n in_t = torch.ones(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = F.", "reference": "out_t=F.interpolate(in_t,scale_factor=scale_factor,**kwargs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,scale_factor=scale_factor,**kwargs)", "y_neg": " out_t = F.upsample_bilinear(in_t, size=(out_size, out_size), **kwargs)", "retain": " def test_upsamplingBilinear2d(self, device, antialias, align_corners):\n # Forward AD does not support XLA because XLA tensors don't have storage\n check_forward_ad = torch.device(device).type != 'xla'\n\n kwargs = dict(mode='bilinear', align_corners=align_corners, antialias=antialias)\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n in_t = torch.ones(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = F.interpolate(in_t, scale_factor=scale_factor, **kwargs)\n self.assertEqual(torch.ones(2, 3, out_size, out_size, device=device), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n if torch.device(device).type == 'cuda':\n # Bilinear backward is nondeterministic because of atomicAdd usage\n nondet_tol = 1e-5\n else:\n nondet_tol = 0.0\n\n input = torch.randn(2, 3, 8, 8, device=device).contiguous(memory_format=memory_format).requires_grad_()\n gradcheck(\n lambda x: F.interpolate(x, out_size, **kwargs),\n [input],\n check_forward_ad=check_forward_ad, nondet_tol=nondet_tol\n )\n gradgradcheck(\n lambda x: F.interpolate(x, out_size, **kwargs),\n [input],\n check_fwd_over_rev=check_forward_ad, nondet_tol=nondet_tol\n )\n\n # Assert that cpu and cuda give same results\n if torch.device(device).type == 'cuda':\n for shapes in [\n (2, 2, 3, 4), (2, 3, 4, 5), (3, 1, 2, 2), (1, 5, 3, 2)\n ]:\n a_cuda = torch.randn(\n *shapes, device=device\n ).contiguous(memory_format=memory_format).requires_grad_()\n a_cpu = a_cuda.detach().cpu().requires_grad_()\n\n with warnings.catch_warnings(record=True):\n out_cuda = F.interpolate(a_cuda, scale_factor=scale_factor, **kwargs)\n out_cpu = F.interpolate(a_cpu, scale_factor=scale_factor, **kwargs)\n\n self.assertEqual(out_cpu, out_cuda.cpu())\n\n g_cuda = torch.randn_like(out_cuda)\n g_cpu = g_cuda.cpu()\n\n out_cuda.backward(g_cuda)\n out_cpu.backward(g_cpu)\n\n self.assertEqual(a_cuda.grad, a_cpu.grad)" }, { "id": 5323, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _upsample_add(self, x, y):\n '''Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n '''\n _, _, H, W = y.size()\n return F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y", "probing input": " def _upsample_add(self, x, y):\n '''Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n '''\n _, _, H, W = y.size()\n", "probing input new": " def _upsample_add(self, x, y):\n '''Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n '''\n _, _, H, W = y.size()\n return F.", "reference": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "y_neg": " return F.upsample(x, size=(H, W), mode='bilinear') + y", "retain": " def _upsample_add(self, x, y):\n '''Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n '''\n _, _, H, W = y.size()\n return F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y" }, { "id": 5360, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest2d(self):\n x = torch.randn(2, 2, 4, 4)\n x1 = x.clone().detach().requires_grad_()\n y1 = F.interpolate(x1, scale_factor=2, mode=\"nearest\")\n y1.mean().backward()\n\n # test channels last\n x2 = x.clone().detach().to(memory_format=torch.channels_last).requires_grad_()\n y2 = F.interpolate(x2, scale_factor=2, mode=\"nearest\")\n y2.mean().backward()\n self.assertTrue(y2.is_contiguous(memory_format=torch.channels_last))\n self.assertEqual(y1, y2)\n self.assertTrue(x2.grad.is_contiguous(memory_format=torch.channels_last))\n self.assertEqual(x1.grad, x2.grad)\n\n # test bfloat16\n x3 = x.clone().detach().bfloat16().requires_grad_()\n y3 = F.interpolate(x3, scale_factor=2, mode=\"nearest\")\n y3.mean().backward()\n self.assertTrue(y3.dtype == torch.bfloat16)\n self.assertEqual(y1, y3, prec=0.01)\n self.assertTrue(x3.grad.dtype == torch.bfloat16)\n self.assertEqual(x1.grad, x3.grad)\n\n # test autocast\n with torch.cpu.amp.autocast():\n for datatype in (torch.bfloat16, torch.float32):\n x4 = x.clone().detach().to(datatype).requires_grad_()\n y4 = F.interpolate(x4, scale_factor=2, mode=\"nearest\")\n y4.mean().backward()\n self.assertTrue(y4.dtype == datatype)\n self.assertTrue(x4.grad.dtype == datatype)\n\n x5 = (\n x.clone()\n .detach()\n .to(datatype)\n .to(memory_format=torch.channels_last)\n .requires_grad_()\n )\n y5 = F.interpolate(x5, scale_factor=2, mode=\"nearest\")\n y5.mean().backward()\n self.assertTrue(y5.dtype == datatype)\n self.assertTrue(x5.grad.dtype == datatype)\n self.assertTrue(y5.is_contiguous(memory_format=torch.channels_last))\n self.assertTrue(\n x5.grad.is_contiguous(memory_format=torch.channels_last)\n )", "probing input": " def test_upsample_nearest2d(self):\n x = torch.randn(2, 2, 4, 4)\n x1 = x.clone().detach().requires_grad_()\n", "probing input new": " def test_upsample_nearest2d(self):\n x = torch.randn(2, 2, 4, 4)\n x1 = x.clone().detach().requires_grad_()\n y1 = F.", "reference": "y1=F.interpolate(x1,scale_factor=2,mode=\"nearest\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "y1=F.interpolate(x1,scale_factor=2,mode=\"nearest\")", "y_neg": " y1 = F.upsample(x1, scale_factor=2, mode='nearest')", "retain": " def test_upsample_nearest2d(self):\n x = torch.randn(2, 2, 4, 4)\n x1 = x.clone().detach().requires_grad_()\n y1 = F.interpolate(x1, scale_factor=2, mode=\"nearest\")\n y1.mean().backward()\n\n # test channels last\n x2 = x.clone().detach().to(memory_format=torch.channels_last).requires_grad_()\n y2 = F.interpolate(x2, scale_factor=2, mode=\"nearest\")\n y2.mean().backward()\n self.assertTrue(y2.is_contiguous(memory_format=torch.channels_last))\n self.assertEqual(y1, y2)\n self.assertTrue(x2.grad.is_contiguous(memory_format=torch.channels_last))\n self.assertEqual(x1.grad, x2.grad)\n\n # test bfloat16\n x3 = x.clone().detach().bfloat16().requires_grad_()\n y3 = F.interpolate(x3, scale_factor=2, mode=\"nearest\")\n y3.mean().backward()\n self.assertTrue(y3.dtype == torch.bfloat16)\n self.assertEqual(y1, y3, prec=0.01)\n self.assertTrue(x3.grad.dtype == torch.bfloat16)\n self.assertEqual(x1.grad, x3.grad)\n\n # test autocast\n with torch.cpu.amp.autocast():\n for datatype in (torch.bfloat16, torch.float32):\n x4 = x.clone().detach().to(datatype).requires_grad_()\n y4 = F.interpolate(x4, scale_factor=2, mode=\"nearest\")\n y4.mean().backward()\n self.assertTrue(y4.dtype == datatype)\n self.assertTrue(x4.grad.dtype == datatype)\n\n x5 = (\n x.clone()\n .detach()\n .to(datatype)\n .to(memory_format=torch.channels_last)\n .requires_grad_()\n )\n y5 = F.interpolate(x5, scale_factor=2, mode=\"nearest\")\n y5.mean().backward()\n self.assertTrue(y5.dtype == datatype)\n self.assertTrue(x5.grad.dtype == datatype)\n self.assertTrue(y5.is_contiguous(memory_format=torch.channels_last))\n self.assertTrue(\n x5.grad.is_contiguous(memory_format=torch.channels_last)\n )" }, { "id": 5389, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_bilinear2d_output_size(self):\n def func(x: torch.Tensor):\n return torch.nn.functional.interpolate(x, size=(4, 4), mode=\"bilinear\")\n\n onnx_program = torch.onnx.dynamo_export(func, torch.randn(1, 1, 2, 2))\n # If decomposition is skipped, the model will contain a Resize op instead of fine grained subgraph.\n assert_op_in_onnx_model(onnx_program.model_proto, \"Resize\")", "probing input": " def test_upsample_bilinear2d_output_size(self):\n def func(x: torch.Tensor):\n", "probing input new": " def test_upsample_bilinear2d_output_size(self):\n def func(x: torch.Tensor):\n return torch.nn.functional.", "reference": "returntorch.nn.functional.interpolate(x,size=(4,4),mode=\"bilinear\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "returntorch.nn.functional.interpolate(x,size=(4,4),mode=\"bilinear\")", "y_neg": " return torch.nn.functional.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def test_upsample_bilinear2d_output_size(self):\n def func(x: torch.Tensor):\n return torch.nn.functional.interpolate(x, size=(4, 4), mode=\"bilinear\")\n\n onnx_program = torch.onnx.dynamo_export(func, torch.randn(1, 1, 2, 2))\n # If decomposition is skipped, the model will contain a Resize op instead of fine grained subgraph.\n assert_op_in_onnx_model(onnx_program.model_proto, \"Resize\")" }, { "id": 5414, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.interpolate(x,\n size=size,\n mode='nearest')\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(model, train=False, input=(x),\n batch_size=BATCH_SIZE, use_gpu=False)", "probing input": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n", "probing input new": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.", "reference": "returnnn.functional.interpolate(x,size=size,mode='nearest')", "reference dict": { "model": "MyModel" }, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "returnnn.functional.interpolate(x,size=size,mode='nearest')", "y_neg": " return nn.functional.upsample(x, size=size, mode='bilinear', align_corners=False)", "retain": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.interpolate(x,\n size=size,\n mode='nearest')\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(model, train=False, input=(x),\n batch_size=BATCH_SIZE, use_gpu=False)" }, { "id": 5415, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.interpolate(x,\n size=size,\n mode='nearest')\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(model, train=False, input=(x),\n batch_size=BATCH_SIZE, use_gpu=False)", "probing input": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n", "probing input new": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.", "reference": "returnnn.functional.interpolate(x,size=size,mode='nearest')", "reference dict": { "model": "MyModel" }, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "returnnn.functional.interpolate(x,size=size,mode='nearest')", "y_neg": " return nn.functional.upsample(x, size=size, mode='bilinear', align_corners=False)", "retain": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def __init__(self):\n super(MyModel, self).__init__()\n\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.interpolate(x,\n size=size,\n mode='nearest')\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(model, train=False, input=(x),\n batch_size=BATCH_SIZE, use_gpu=False)" }, { "id": 5421, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = (o + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)", "probing input": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n", "probing input new": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "y_neg": " out_t = F.upsample_nearest(in_t, size=(osize,))", "retain": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n # Here we check if output matches Scikit-Image/Scipy-like result\n # Checks https://github.com/pytorch/pytorch/issues/34808\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for o in range(osize):\n i_f32 = (o + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, o] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)" }, { "id": 5430, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsampling_64bit_indexing_channels_last(self, device, dtype):\n x = torch.rand((32, 64, 512, 512), dtype=dtype, device=device)\n out = torch.nn.functional.interpolate(x.to(memory_format=torch.channels_last), scale_factor=2, mode='nearest')\n out_ref = torch.nn.functional.interpolate(x, scale_factor=2, mode='nearest')\n del x\n self.assertTrue(torch.allclose(out, out_ref))", "probing input": " def test_upsampling_64bit_indexing_channels_last(self, device, dtype):\n x = torch.rand((32, 64, 512, 512), dtype=dtype, device=device)\n", "probing input new": " def test_upsampling_64bit_indexing_channels_last(self, device, dtype):\n x = torch.rand((32, 64, 512, 512), dtype=dtype, device=device)\n out = torch.nn.functional.", "reference": "out=torch.nn.functional.interpolate(x.to(memory_format=torch.channels_last),scale_factor=2,mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "out=torch.nn.functional.interpolate(x.to(memory_format=torch.channels_last),scale_factor=2,mode='nearest')", "y_neg": " out = torch.nn.functional.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def test_upsampling_64bit_indexing_channels_last(self, device, dtype):\n x = torch.rand((32, 64, 512, 512), dtype=dtype, device=device)\n out = torch.nn.functional.interpolate(x.to(memory_format=torch.channels_last), scale_factor=2, mode='nearest')\n out_ref = torch.nn.functional.interpolate(x, scale_factor=2, mode='nearest')\n del x\n self.assertTrue(torch.allclose(out, out_ref))" }, { "id": 5437, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_basic_upsample_nearest_size(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, size=16, mode='nearest')\n return out\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))", "probing input": " def test_basic_upsample_nearest_size(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n", "probing input new": " def test_basic_upsample_nearest_size(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.", "reference": "out=torch.nn.functional.interpolate(x,size=16,mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "out=torch.nn.functional.interpolate(x,size=16,mode='nearest')", "y_neg": " out = torch.nn.functional.upsample(x, size=(2, 2), mode='nearest')", "retain": " def test_basic_upsample_nearest_size(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, size=16, mode='nearest')\n return out\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))" }, { "id": 5438, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_scale(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, scale_factor=2.,\n mode='nearest', recompute_scale_factor=False)\n return out\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))", "probing input": " def test_upsample_nearest_scale(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n", "probing input new": " def test_upsample_nearest_scale(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.", "reference": "out=torch.nn.functional.interpolate(x,scale_factor=2.,mode='nearest',recompute_scale_factor=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "out=torch.nn.functional.interpolate(x,scale_factor=2.,mode='nearest',recompute_scale_factor=False)", "y_neg": " out = torch.nn.functional.upsample(x, scale_factor=2, mode='nearest')", "retain": " def test_upsample_nearest_scale(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, scale_factor=2.,\n mode='nearest', recompute_scale_factor=False)\n return out\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))" }, { "id": 5439, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_scale_default_scale_factor(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, scale_factor=2.,\n mode='nearest')\n return out\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))", "probing input": " def test_upsample_nearest_scale_default_scale_factor(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n", "probing input new": " def test_upsample_nearest_scale_default_scale_factor(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.", "reference": "out=torch.nn.functional.interpolate(x,scale_factor=2.,mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "out=torch.nn.functional.interpolate(x,scale_factor=2.,mode='nearest')", "y_neg": " out = torch.nn.functional.upsample(x, scale_factor=1.0)", "retain": " def test_upsample_nearest_scale_default_scale_factor(self):\n class SimpleOp(nn.Module):\n def forward(self, x):\n out = torch.nn.functional.interpolate(x, scale_factor=2.,\n mode='nearest')\n return out\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n self.checkExportImport(SimpleOp(), (x, ))" }, { "id": 5443, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, top, lateral):\n if lateral.shape[2] != top.shape[2]:\n h, w = lateral.size(2), lateral.size(3)\n top = F.interpolate(input=top, size=(h, w), mode='bilinear',align_corners=True)\n out = torch.cat((lateral, top), dim=1)\n out = self.relu(self.bn1(self.conv1(out)))\n out = self.relu(self.bn2(self.conv2(out)))\n return out", "probing input": " def forward(self, top, lateral):\n if lateral.shape[2] != top.shape[2]:\n h, w = lateral.size(2), lateral.size(3)\n", "probing input new": " def forward(self, top, lateral):\n if lateral.shape[2] != top.shape[2]:\n h, w = lateral.size(2), lateral.size(3)\n top = F.", "reference": "top=F.interpolate(input=top,size=(h,w),mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "top=F.interpolate(input=top,size=(h,w),mode='bilinear',align_corners=True)", "y_neg": " top = F.upsample(top, size=(h, w), mode='bilinear')", "retain": " def forward(self, top, lateral):\n if lateral.shape[2] != top.shape[2]:\n h, w = lateral.size(2), lateral.size(3)\n top = F.interpolate(input=top, size=(h, w), mode='bilinear',align_corners=True)\n out = torch.cat((lateral, top), dim=1)\n out = self.relu(self.bn1(self.conv1(out)))\n out = self.relu(self.bn2(self.conv2(out)))\n return out" }, { "id": 5462, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n # TODO(#38095): Replace assertEqualIgnoreType. See issue #38095\n self.assertEqualIgnoreType(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])", "probing input": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n # TODO(#38095): Replace assertEqualIgnoreType. See issue #38095\n self.assertEqualIgnoreType(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n", "probing input new": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n # TODO(#38095): Replace assertEqualIgnoreType. See issue #38095\n self.assertEqualIgnoreType(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "y_neg": " gradcheck(lambda x: F.upsample(x, size=4, mode='nearest'), (input,), atol=1e-6, rtol=1e-6)", "retain": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n # TODO(#38095): Replace assertEqualIgnoreType. See issue #38095\n self.assertEqualIgnoreType(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])" }, { "id": 5463, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='linear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input,))", "probing input": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='linear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n", "probing input new": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='linear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input,))", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input,))", "y_neg": " gradcheck(lambda x: F.upsample(x, scale_factor=scale_factor, mode='linear', align_corners=align_corners),", "retain": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='linear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input,))" }, { "id": 5464, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest2d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n self.assertEqual(\n F.interpolate(input, 4, mode='nearest'),\n F.interpolate(input, scale_factor=2, mode='nearest'))\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])\n gradgradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])", "probing input": " def test_upsamplingNearest2d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n self.assertEqual(\n", "probing input new": " def test_upsamplingNearest2d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n self.assertEqual(\n F.", "reference": "F.interpolate(input,4,mode='nearest'),", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(input,4,mode='nearest'),", "y_neg": " F.upsample(input, scale_factor=4, mode='nearest'),", "retain": " def test_upsamplingNearest2d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n self.assertEqual(\n F.interpolate(input, 4, mode='nearest'),\n F.interpolate(input, scale_factor=2, mode='nearest'))\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])\n gradgradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])" }, { "id": 5465, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])", "probing input": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True)\n", "probing input new": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),[input])", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),[input])", "y_neg": " gradcheck(lambda x: F.upsample(x, scale_factor=scale_factor, mode='bilinear', align_corners=align_corners), (input,), atol=1e-6, rtol=1e-6)", "retain": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])" }, { "id": 5467, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest3d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])", "probing input": " def test_upsamplingNearest3d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n", "probing input new": " def test_upsamplingNearest3d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "y_neg": " gradcheck(lambda x: F.upsample(x, size=4, mode='nearest'), (input,), atol=1e-6, rtol=1e-6)", "retain": " def test_upsamplingNearest3d(self):\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2, 2, 2).contiguous(memory_format=memory_format)\n in_uint8_t = torch.ones(1, 1, 2, 2, 2, dtype=torch.uint8).contiguous(memory_format=memory_format)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4).contiguous(memory_format=memory_format), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, 4, 4, dtype=torch.uint8).contiguous(memory_format=memory_format), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True).contiguous(memory_format=memory_format)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])" }, { "id": 5468, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.interpolate(input, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])", "probing input": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n", "probing input new": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.", "reference": "F.interpolate(input,(out_size,out_size,out_size),**kwargs),", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(input,(out_size,out_size,out_size),**kwargs),", "y_neg": " F.upsample(input, scale_factor=scale_factor, mode='trilinear', align_corners=align_corners),", "retain": " def test_upsamplingTrilinear3d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2, 2, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size, out_size, out_size), out_t.data)\n\n input = torch.randn(1, 1, 2, 2, 2, requires_grad=True)\n self.assertEqual(\n F.interpolate(input, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])" }, { "id": 5483, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def adjust_input_image_size_for_proper_feature_alignment(input_img_batch, output_stride=8):\n \"\"\"Resizes the input image to allow proper feature alignment during the\n forward propagation.\n\n Resizes the input image to a closest multiple of `output_stride` + 1.\n This allows the proper alignment of features.\n To get more details, read here:\n https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n\n Parameters\n ----------\n input_img_batch : torch.Tensor\n Tensor containing a single input image of size (1, 3, h, w)\n\n output_stride : int\n Output stride of the network where the input image batch\n will be fed.\n\n Returns\n -------\n input_img_batch_new_size : torch.Tensor\n Resized input image batch tensor\n \"\"\"\n\n input_spatial_dims = np.asarray( input_img_batch.shape[2:], dtype=np.float )\n\n # Comments about proper alignment can be found here\n # https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n new_spatial_dims = np.ceil(input_spatial_dims / output_stride).astype(np.int) * output_stride + 1\n\n # Converting the numpy to list, torch.nn.functional.upsample_bilinear accepts\n # size in the list representation.\n new_spatial_dims = list(new_spatial_dims)\n\n #input_img_batch_new_size = nn.functional.upsample_bilinear(input=input_img_batch, size=new_spatial_dims)\n input_img_batch_new_size = nn.functional.interpolate(input=input_img_batch, size=new_spatial_dims,\n mode='bilinear', align_corners=True)\n\n return input_img_batch_new_size", "probing input": "def adjust_input_image_size_for_proper_feature_alignment(input_img_batch, output_stride=8):\n \"\"\"Resizes the input image to allow proper feature alignment during the\n forward propagation.\n\n Resizes the input image to a closest multiple of `output_stride` + 1.\n This allows the proper alignment of features.\n To get more details, read here:\n https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n\n Parameters\n ----------\n input_img_batch : torch.Tensor\n Tensor containing a single input image of size (1, 3, h, w)\n\n output_stride : int\n Output stride of the network where the input image batch\n will be fed.\n\n Returns\n -------\n input_img_batch_new_size : torch.Tensor\n Resized input image batch tensor\n \"\"\"\n\n input_spatial_dims = np.asarray( input_img_batch.shape[2:], dtype=np.float )\n\n # Comments about proper alignment can be found here\n # https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n new_spatial_dims = np.ceil(input_spatial_dims / output_stride).astype(np.int) * output_stride + 1\n\n # Converting the numpy to list, torch.nn.functional.upsample_bilinear accepts\n # size in the list representation.\n new_spatial_dims = list(new_spatial_dims)\n\n #input_img_batch_new_size = nn.functional.upsample_bilinear(input=input_img_batch, size=new_spatial_dims)\n", "probing input new": "def adjust_input_image_size_for_proper_feature_alignment(input_img_batch, output_stride=8):\n \"\"\"Resizes the input image to allow proper feature alignment during the\n forward propagation.\n\n Resizes the input image to a closest multiple of `output_stride` + 1.\n This allows the proper alignment of features.\n To get more details, read here:\n https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n\n Parameters\n ----------\n input_img_batch : torch.Tensor\n Tensor containing a single input image of size (1, 3, h, w)\n\n output_stride : int\n Output stride of the network where the input image batch\n will be fed.\n\n Returns\n -------\n input_img_batch_new_size : torch.Tensor\n Resized input image batch tensor\n \"\"\"\n\n input_spatial_dims = np.asarray( input_img_batch.shape[2:], dtype=np.float )\n\n # Comments about proper alignment can be found here\n # https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n new_spatial_dims = np.ceil(input_spatial_dims / output_stride).astype(np.int) * output_stride + 1\n\n # Converting the numpy to list, torch.nn.functional.upsample_bilinear accepts\n # size in the list representation.\n new_spatial_dims = list(new_spatial_dims)\n\n #input_img_batch_new_size = nn.functional.upsample_bilinear(input=input_img_batch, size=new_spatial_dims)\n input_img_batch_new_size = nn.functional.", "reference": "input_img_batch_new_size=nn.functional.interpolate(input=input_img_batch,size=new_spatial_dims,mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "input_img_batch_new_size=nn.functional.interpolate(input=input_img_batch,size=new_spatial_dims,mode='bilinear',align_corners=True)", "y_neg": " input_img_batch_new_size = nn.functional.upsample(input=input_img_batch, size=new_spatial_dims)", "retain": "def adjust_input_image_size_for_proper_feature_alignment(input_img_batch, output_stride=8):\n \"\"\"Resizes the input image to allow proper feature alignment during the\n forward propagation.\n\n Resizes the input image to a closest multiple of `output_stride` + 1.\n This allows the proper alignment of features.\n To get more details, read here:\n https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n\n Parameters\n ----------\n input_img_batch : torch.Tensor\n Tensor containing a single input image of size (1, 3, h, w)\n\n output_stride : int\n Output stride of the network where the input image batch\n will be fed.\n\n Returns\n -------\n input_img_batch_new_size : torch.Tensor\n Resized input image batch tensor\n \"\"\"\n\n input_spatial_dims = np.asarray( input_img_batch.shape[2:], dtype=np.float )\n\n # Comments about proper alignment can be found here\n # https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v1.py#L159\n new_spatial_dims = np.ceil(input_spatial_dims / output_stride).astype(np.int) * output_stride + 1\n\n # Converting the numpy to list, torch.nn.functional.upsample_bilinear accepts\n # size in the list representation.\n new_spatial_dims = list(new_spatial_dims)\n\n #input_img_batch_new_size = nn.functional.upsample_bilinear(input=input_img_batch, size=new_spatial_dims)\n input_img_batch_new_size = nn.functional.interpolate(input=input_img_batch, size=new_spatial_dims,\n mode='bilinear', align_corners=True)\n\n return input_img_batch_new_size" }, { "id": 5488, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, feats):\n h, w = feats.size(2), feats.size(3)\n priors = [\n F.interpolate(\n input=self.act(stage(feats)),\n size=(h, w),\n mode='bilinear',\n align_corners=False) for stage in self.stages\n ] + [feats]\n out = self.act(self.bottleneck(torch.cat(priors, 1)))\n return out", "probing input": " def forward(self, feats):\n h, w = feats.size(2), feats.size(3)\n priors = [\n", "probing input new": " def forward(self, feats):\n h, w = feats.size(2), feats.size(3)\n priors = [\n F.", "reference": "F.interpolate(input=self.act(stage(feats)),size=(h,w),mode='bilinear',align_corners=False)forstageinself.stages", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(input=self.act(stage(feats)),size=(h,w),mode='bilinear',align_corners=False)forstageinself.stages", "y_neg": " F.upsample(input=feats[:, :, ::2, ::2], scale_factor=2),", "retain": " def forward(self, feats):\n h, w = feats.size(2), feats.size(3)\n priors = [\n F.interpolate(\n input=self.act(stage(feats)),\n size=(h, w),\n mode='bilinear',\n align_corners=False) for stage in self.stages\n ] + [feats]\n out = self.act(self.bottleneck(torch.cat(priors, 1)))\n return out" }, { "id": 5514, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n H0, W0 = x.size()[2:]\n feat8, feat16, feat32 = self.resnet(x)\n H8, W8 = feat8.size()[2:]\n H16, W16 = feat16.size()[2:]\n H32, W32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.interpolate(avg, (H32, W32), mode='nearest')\n\n feat32_arm = self.arm32(feat32)\n feat32_sum = feat32_arm + avg_up\n feat32_up = F.interpolate(feat32_sum, (H16, W16), mode='nearest')\n feat32_up = self.conv_head32(feat32_up)\n\n feat16_arm = self.arm16(feat16)\n feat16_sum = feat16_arm + feat32_up\n feat16_up = F.interpolate(feat16_sum, (H8, W8), mode='nearest')\n feat16_up = self.conv_head16(feat16_up)\n\n return feat8, feat16_up, feat32_up", "probing input": " def forward(self, x):\n H0, W0 = x.size()[2:]\n feat8, feat16, feat32 = self.resnet(x)\n H8, W8 = feat8.size()[2:]\n H16, W16 = feat16.size()[2:]\n H32, W32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n", "probing input new": " def forward(self, x):\n H0, W0 = x.size()[2:]\n feat8, feat16, feat32 = self.resnet(x)\n H8, W8 = feat8.size()[2:]\n H16, W16 = feat16.size()[2:]\n H32, W32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.", "reference": "avg_up=F.interpolate(avg,(H32,W32),mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "avg_up=F.interpolate(avg,(H32,W32),mode='nearest')", "y_neg": " avg_up = F.upsample(avg, scale_factor=2, mode='bilinear')", "retain": " def forward(self, x):\n H0, W0 = x.size()[2:]\n feat8, feat16, feat32 = self.resnet(x)\n H8, W8 = feat8.size()[2:]\n H16, W16 = feat16.size()[2:]\n H32, W32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.interpolate(avg, (H32, W32), mode='nearest')\n\n feat32_arm = self.arm32(feat32)\n feat32_sum = feat32_arm + avg_up\n feat32_up = F.interpolate(feat32_sum, (H16, W16), mode='nearest')\n feat32_up = self.conv_head32(feat32_up)\n\n feat16_arm = self.arm16(feat16)\n feat16_sum = feat16_arm + feat32_up\n feat16_up = F.interpolate(feat16_sum, (H8, W8), mode='nearest')\n feat16_up = self.conv_head16(feat16_up)\n\n return feat8, feat16_up, feat32_up" }, { "id": 5529, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _upsample_add(x, y):\n \"\"\"Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n \"\"\"\n _, _, H, W = y.size()\n return F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y", "probing input": "def _upsample_add(x, y):\n \"\"\"Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n \"\"\"\n _, _, H, W = y.size()\n", "probing input new": "def _upsample_add(x, y):\n \"\"\"Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n \"\"\"\n _, _, H, W = y.size()\n return F.", "reference": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "y_neg": " return F.upsample(x, size=(H, W), mode='bilinear') + y", "retain": "def _upsample_add(x, y):\n \"\"\"Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsample(..., scale_factor=2, mode='nearest')`\n maybe not equal to the lateral feature map size.\n e.g.\n original input size: [N,_,15,15] ->\n conv2d feature map size: [N,_,8,8] ->\n upsampled feature map size: [N,_,16,16]\n So we choose bilinear upsample which supports arbitrary output sizes.\n \"\"\"\n _, _, H, W = y.size()\n return F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y" }, { "id": 5539, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])", "probing input": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n", "probing input new": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,4,mode='nearest'),[input])", "y_neg": " gradcheck(lambda x: F.upsample(x, size=(2, 2), mode='nearest'), (input,), atol=1e-6, rtol=1e-6)", "retain": " def test_upsamplingNearest1d(self):\n m = nn.Upsample(size=4, mode='nearest')\n in_t = torch.ones(1, 1, 2)\n in_uint8_t = torch.ones(1, 1, 2, dtype=torch.uint8)\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n out_uint8_t = m(in_uint8_t)\n self.assertEqual(torch.ones(1, 1, 4), out_t.data)\n self.assertEqual(torch.ones(1, 1, 4, dtype=torch.uint8), out_uint8_t.data)\n\n input = torch.randn(1, 1, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, 4, mode='nearest'), [input])" }, { "id": 5544, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n\n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea)\n\n edge2_fea = F.interpolate(edge2_fea, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge3_fea = F.interpolate(edge3_fea, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge2 = F.interpolate(edge2, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge3 = F.interpolate(edge3, size=(h, w), mode=\"bilinear\", align_corners=True)\n\n edge = torch.cat([edge1, edge2, edge3], dim=1)\n edge_fea = torch.cat([edge1_fea, edge2_fea, edge3_fea], dim=1)\n edge = self.conv5(edge)\n\n return edge, edge_fea", "probing input": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n\n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea)\n\n", "probing input new": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n\n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea)\n\n edge2_fea = F.", "reference": "edge2_fea=F.interpolate(edge2_fea,size=(h,w),mode=\"bilinear\",align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "edge2_fea=F.interpolate(edge2_fea,size=(h,w),mode=\"bilinear\",align_corners=True)", "y_neg": " edge2_fea = F.upsample(edge2_fea, scale_factor=2, mode='bilinear')", "retain": " def forward(self, x1, x2, x3):\n _, _, h, w = x1.size()\n\n edge1_fea = self.conv1(x1)\n edge1 = self.conv4(edge1_fea)\n edge2_fea = self.conv2(x2)\n edge2 = self.conv4(edge2_fea)\n edge3_fea = self.conv3(x3)\n edge3 = self.conv4(edge3_fea)\n\n edge2_fea = F.interpolate(edge2_fea, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge3_fea = F.interpolate(edge3_fea, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge2 = F.interpolate(edge2, size=(h, w), mode=\"bilinear\", align_corners=True)\n edge3 = F.interpolate(edge3, size=(h, w), mode=\"bilinear\", align_corners=True)\n\n edge = torch.cat([edge1, edge2, edge3], dim=1)\n edge_fea = torch.cat([edge1_fea, edge2_fea, edge3_fea], dim=1)\n edge = self.conv5(edge)\n\n return edge, edge_fea" }, { "id": 5566, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n feat8, feat16, feat32 = self.resnet(x)\n h8, w8 = feat8.size()[2:]\n h16, w16 = feat16.size()[2:]\n h32, w32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.interpolate(avg, (h32, w32), mode='nearest')\n\n feat32_arm = self.arm32(feat32)\n feat32_sum = feat32_arm + avg_up\n feat32_up = F.interpolate(feat32_sum, (h16, w16), mode='nearest')\n feat32_up = self.conv_head32(feat32_up)\n\n feat16_arm = self.arm16(feat16)\n feat16_sum = feat16_arm + feat32_up\n feat16_up = F.interpolate(feat16_sum, (h8, w8), mode='nearest')\n feat16_up = self.conv_head16(feat16_up)\n\n return feat8, feat16_up, feat32_up", "probing input": " def forward(self, x):\n feat8, feat16, feat32 = self.resnet(x)\n h8, w8 = feat8.size()[2:]\n h16, w16 = feat16.size()[2:]\n h32, w32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n", "probing input new": " def forward(self, x):\n feat8, feat16, feat32 = self.resnet(x)\n h8, w8 = feat8.size()[2:]\n h16, w16 = feat16.size()[2:]\n h32, w32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.", "reference": "avg_up=F.interpolate(avg,(h32,w32),mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "avg_up=F.interpolate(avg,(h32,w32),mode='nearest')", "y_neg": " avg_up = F.upsample(avg, scale_factor=2, mode='bilinear')", "retain": " def forward(self, x):\n feat8, feat16, feat32 = self.resnet(x)\n h8, w8 = feat8.size()[2:]\n h16, w16 = feat16.size()[2:]\n h32, w32 = feat32.size()[2:]\n\n avg = F.avg_pool2d(feat32, feat32.size()[2:])\n avg = self.conv_avg(avg)\n avg_up = F.interpolate(avg, (h32, w32), mode='nearest')\n\n feat32_arm = self.arm32(feat32)\n feat32_sum = feat32_arm + avg_up\n feat32_up = F.interpolate(feat32_sum, (h16, w16), mode='nearest')\n feat32_up = self.conv_head32(feat32_up)\n\n feat16_arm = self.arm16(feat16)\n feat16_sum = feat16_arm + feat32_up\n feat16_up = F.interpolate(feat16_sum, (h8, w8), mode='nearest')\n feat16_up = self.conv_head16(feat16_up)\n\n return feat8, feat16_up, feat32_up" }, { "id": 5581, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(\n input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](\n torch.cat([\n ref[level],\n flow_warp(\n supp[level],\n flow_up.permute(0, 2, 3, 1),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow", "probing input": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n", "probing input new": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.", "reference": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "y_neg": " flow_up = F.upsample(flow_up, scale_factor=2, mode='bilinear')", "retain": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n Note that in this function, the images are already resized to a\n multiple of 32.\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(\n input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](\n torch.cat([\n ref[level],\n flow_warp(\n supp[level],\n flow_up.permute(0, 2, 3, 1),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow" }, { "id": 5601, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_torch_upsample(self):\n def run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=\"float32\",\n atol=1e-5,\n ):\n with self.subTest(\n N=N,\n C=C,\n idim=idim,\n scale_factor=scale_factor,\n mode=mode,\n align_corner=align_corner,\n ):\n np_dtype = getattr(np, dtype)\n np.random.seed(0)\n iH, iW = idim\n in_np = np.random.normal(-1.0, 1.0, (N, iH, iW, C)).astype(np_dtype)\n\n in_mx = mx.array(in_np)\n in_pt = torch.from_numpy(in_np.transpose(0, 3, 1, 2)).to(\"cpu\")\n\n out_mx = nn.Upsample(\n scale_factor=scale_factor,\n mode=mode,\n align_corners=align_corner,\n )(in_mx)\n mode_pt = {\n \"linear\": \"bilinear\",\n \"cubic\": \"bicubic\",\n }[mode]\n out_pt = F.interpolate(\n in_pt,\n scale_factor=scale_factor,\n mode=mode_pt,\n align_corners=align_corner,\n )\n out_pt = torch.permute(out_pt, (0, 2, 3, 1)).numpy(force=True)\n self.assertEqual(out_pt.shape, out_mx.shape)\n self.assertTrue(np.allclose(out_pt, out_mx, atol=atol))\n\n for dtype in (\"float32\",):\n for N, C in ((1, 1), (2, 3)):\n # only test cases in which target sizes are intergers\n # if not, there will be numerical difference between mlx\n # and torch due to different indices selection.\n for idim, scale_factor in (\n ((2, 2), (1.0, 1.0)),\n ((2, 2), (1.5, 1.5)),\n ((2, 2), (2.0, 2.0)),\n ((4, 4), (0.5, 0.5)),\n ((7, 7), (2.0, 2.0)),\n ((10, 10), (0.2, 0.2)),\n ((11, 21), (3.0, 3.0)),\n ((11, 21), (3.0, 2.0)),\n ):\n # only test linear and cubic interpolation\n # there will be numerical difference in nearest\n # due to different indices selection.\n for mode in (\"cubic\", \"linear\"):\n for align_corner in (False, True):\n run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=dtype,\n )", "probing input": " def test_torch_upsample(self):\n def run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=\"float32\",\n atol=1e-5,\n ):\n with self.subTest(\n N=N,\n C=C,\n idim=idim,\n scale_factor=scale_factor,\n mode=mode,\n align_corner=align_corner,\n ):\n np_dtype = getattr(np, dtype)\n np.random.seed(0)\n iH, iW = idim\n in_np = np.random.normal(-1.0, 1.0, (N, iH, iW, C)).astype(np_dtype)\n\n in_mx = mx.array(in_np)\n in_pt = torch.from_numpy(in_np.transpose(0, 3, 1, 2)).to(\"cpu\")\n\n out_mx = nn.Upsample(\n scale_factor=scale_factor,\n mode=mode,\n align_corners=align_corner,\n )(in_mx)\n mode_pt = {\n \"linear\": \"bilinear\",\n \"cubic\": \"bicubic\",\n }[mode]\n", "probing input new": " def test_torch_upsample(self):\n def run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=\"float32\",\n atol=1e-5,\n ):\n with self.subTest(\n N=N,\n C=C,\n idim=idim,\n scale_factor=scale_factor,\n mode=mode,\n align_corner=align_corner,\n ):\n np_dtype = getattr(np, dtype)\n np.random.seed(0)\n iH, iW = idim\n in_np = np.random.normal(-1.0, 1.0, (N, iH, iW, C)).astype(np_dtype)\n\n in_mx = mx.array(in_np)\n in_pt = torch.from_numpy(in_np.transpose(0, 3, 1, 2)).to(\"cpu\")\n\n out_mx = nn.Upsample(\n scale_factor=scale_factor,\n mode=mode,\n align_corners=align_corner,\n )(in_mx)\n mode_pt = {\n \"linear\": \"bilinear\",\n \"cubic\": \"bicubic\",\n }[mode]\n out_pt = F.", "reference": "out_pt=F.interpolate(in_pt,scale_factor=scale_factor,mode=mode_pt,align_corners=align_corner,)", "reference dict": { "out_mx": "nn.Upsample(\n scale_factor=scale_factor,\n mode=mode,\n align_corners=align_corner,\n )" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_pt=F.interpolate(in_pt,scale_factor=scale_factor,mode=mode_pt,align_corners=align_corner,)", "y_neg": " out_pt = F.upsample(", "retain": " def test_torch_upsample(self):\n def run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=\"float32\",\n atol=1e-5,\n ):\n with self.subTest(\n N=N,\n C=C,\n idim=idim,\n scale_factor=scale_factor,\n mode=mode,\n align_corner=align_corner,\n ):\n np_dtype = getattr(np, dtype)\n np.random.seed(0)\n iH, iW = idim\n in_np = np.random.normal(-1.0, 1.0, (N, iH, iW, C)).astype(np_dtype)\n\n in_mx = mx.array(in_np)\n in_pt = torch.from_numpy(in_np.transpose(0, 3, 1, 2)).to(\"cpu\")\n\n out_mx = nn.Upsample(\n scale_factor=scale_factor,\n mode=mode,\n align_corners=align_corner,\n )(in_mx)\n mode_pt = {\n \"linear\": \"bilinear\",\n \"cubic\": \"bicubic\",\n }[mode]\n out_pt = F.interpolate(\n in_pt,\n scale_factor=scale_factor,\n mode=mode_pt,\n align_corners=align_corner,\n )\n out_pt = torch.permute(out_pt, (0, 2, 3, 1)).numpy(force=True)\n self.assertEqual(out_pt.shape, out_mx.shape)\n self.assertTrue(np.allclose(out_pt, out_mx, atol=atol))\n\n for dtype in (\"float32\",):\n for N, C in ((1, 1), (2, 3)):\n # only test cases in which target sizes are intergers\n # if not, there will be numerical difference between mlx\n # and torch due to different indices selection.\n for idim, scale_factor in (\n ((2, 2), (1.0, 1.0)),\n ((2, 2), (1.5, 1.5)),\n ((2, 2), (2.0, 2.0)),\n ((4, 4), (0.5, 0.5)),\n ((7, 7), (2.0, 2.0)),\n ((10, 10), (0.2, 0.2)),\n ((11, 21), (3.0, 3.0)),\n ((11, 21), (3.0, 2.0)),\n ):\n # only test linear and cubic interpolation\n # there will be numerical difference in nearest\n # due to different indices selection.\n for mode in (\"cubic\", \"linear\"):\n for align_corner in (False, True):\n run_upsample(\n N,\n C,\n idim,\n scale_factor,\n mode,\n align_corner,\n dtype=dtype,\n )" }, { "id": 5608, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(c3)\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear', align_corners=False) \n cf = self.conv_f(c1_)\n c4 = self.conv4(c3+cf)\n m = self.sigmoid(c4)\n \n return x * m", "probing input": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(c3)\n", "probing input new": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(c3)\n c3 = F.", "reference": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear',align_corners=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear',align_corners=False)", "y_neg": " c3 = F.upsample(c3, scale_factor=2)", "retain": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(c3)\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear', align_corners=False) \n cf = self.conv_f(c1_)\n c4 = self.conv4(c3+cf)\n m = self.sigmoid(c4)\n \n return x * m" }, { "id": 5631, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _upsample_add(self, x, y):\n return F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=False) + y", "probing input": " def _upsample_add(self, x, y):\n", "probing input new": " def _upsample_add(self, x, y):\n return F.", "reference": "returnF.interpolate(x,scale_factor=2,mode='bilinear',align_corners=False)+y", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,scale_factor=2,mode='bilinear',align_corners=False)+y", "y_neg": " return F.upsample(x, scale_factor=2, mode='bilinear', align_corners=False) + y", "retain": " def _upsample_add(self, x, y):\n return F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=False) + y" }, { "id": 5637, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def upsample(x, y, scale=1):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H // scale, W // scale), mode='nearest')\n return F.interpolate(x, size=(H // scale, W // scale), mode='nearest')", "probing input": "def upsample(x, y, scale=1):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H // scale, W // scale), mode='nearest')\n", "probing input new": "def upsample(x, y, scale=1):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H // scale, W // scale), mode='nearest')\n return F.", "reference": "returnF.interpolate(x,size=(H//scale,W//scale),mode='nearest')", "reference dict": {}, "alias dict": { "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H//scale,W//scale),mode='nearest')", "y_neg": " return F.upsample(x, scale_factor=scale, mode='nearest')", "retain": "def upsample(x, y, scale=1):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H // scale, W // scale), mode='nearest')\n return F.interpolate(x, size=(H // scale, W // scale), mode='nearest')" }, { "id": 5638, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def upsample_add(x, y):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H, W), mode='nearest') + y\n return F.interpolate(x, size=(H, W), mode='nearest') + y", "probing input": "def upsample_add(x, y):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H, W), mode='nearest') + y\n", "probing input new": "def upsample_add(x, y):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H, W), mode='nearest') + y\n return F.", "reference": "returnF.interpolate(x,size=(H,W),mode='nearest')+y", "reference dict": {}, "alias dict": { "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H,W),mode='nearest')+y", "y_neg": " return F.upsample(x, size=(H, W), mode='nearest') + y", "retain": "def upsample_add(x, y):\n _, _, H, W = y.size()\n # return F.upsample(x, size=(H, W), mode='nearest') + y\n return F.interpolate(x, size=(H, W), mode='nearest') + y" }, { "id": 5678, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, P2=None):\n # residual = x\n x3, x4, x5, x6 = self.backbone(x)\n\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x6 = self.fullencoders(x6)\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.interpolate(x, scale_factor=4, align_corners=True, mode='bilinear')\n #x = self.up3(x)\n #x = self.up4(x, residual)\n #x = torch.cat([x, residual], dim=1)\n outs['scale_1'] = self.outc(x)\n return outs", "probing input": " def forward(self, x, P2=None):\n # residual = x\n x3, x4, x5, x6 = self.backbone(x)\n\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x6 = self.fullencoders(x6)\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n", "probing input new": " def forward(self, x, P2=None):\n # residual = x\n x3, x4, x5, x6 = self.backbone(x)\n\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x6 = self.fullencoders(x6)\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.", "reference": "x=F.interpolate(x,scale_factor=4,align_corners=True,mode='bilinear')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "x=F.interpolate(x,scale_factor=4,align_corners=True,mode='bilinear')", "y_neg": " x = F.upsample(x, scale_factor=4)", "retain": " def forward(self, x, P2=None):\n # residual = x\n x3, x4, x5, x6 = self.backbone(x)\n\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x6 = self.fullencoders(x6)\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.interpolate(x, scale_factor=4, align_corners=True, mode='bilinear')\n #x = self.up3(x)\n #x = self.up4(x, residual)\n #x = torch.cat([x, residual], dim=1)\n outs['scale_1'] = self.outc(x)\n return outs" }, { "id": 5688, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_bilinear(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='bilinear')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_bilinear(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_bilinear(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,scale_factor=2.0,mode='bilinear')", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,scale_factor=2.0,mode='bilinear')", "y_neg": " return F.upsample_bilinear(x, scale_factor=2)", "retain": " def test_upsample_bilinear(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='bilinear')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5689, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_bilinear_align_corners(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='bilinear', align_corners=True)\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_bilinear_align_corners(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_bilinear_align_corners(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,scale_factor=2.0,mode='bilinear',align_corners=True)", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,scale_factor=2.0,mode='bilinear',align_corners=True)", "y_neg": " return F.upsample_bilinear(x, scale_factor=2, mode='bilinear', align_corners=True)", "retain": " def test_upsample_bilinear_align_corners(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='bilinear', align_corners=True)\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5690, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_nearest(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_nearest(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,scale_factor=2.0,mode='nearest')", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,scale_factor=2.0,mode='nearest')", "y_neg": " return F.upsample_nearest(x, scale_factor=2)", "retain": " def test_upsample_nearest(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, scale_factor=2.0, mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5691, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_bilinear_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(448, 448), mode='bilinear')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_bilinear_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_bilinear_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,size=(448,448),mode='bilinear')", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(448,448),mode='bilinear')", "y_neg": " return F.upsample(x, scale_factor=2, mode='bilinear', align_corners=True)", "retain": " def test_upsample_bilinear_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(448, 448), mode='bilinear')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5692, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(448, 448), mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_nearest_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_nearest_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,size=(448,448),mode='nearest')", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(448,448),mode='nearest')", "y_neg": " return F.upsample(x, scale_factor=2, mode='nearest')", "retain": " def test_upsample_nearest_output_size(self):\n dummy_input = torch.randn(1, 3, 224, 224, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(448, 448), mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5693, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample_nearest_output_size_complex(self):\n dummy_input = torch.randn(1, 3, 8, 22, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(15, 43), mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)", "probing input": " def test_upsample_nearest_output_size_complex(self):\n dummy_input = torch.randn(1, 3, 8, 22, dtype=torch.float32)\n\n def model(x):\n", "probing input new": " def test_upsample_nearest_output_size_complex(self):\n dummy_input = torch.randn(1, 3, 8, 22, dtype=torch.float32)\n\n def model(x):\n return F.", "reference": "returnF.interpolate(x,size=(15,43),mode='nearest')", "reference dict": { "converter": "TFLiteConverter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(15,43),mode='nearest')", "y_neg": " return F.upsample(x, scale_factor=2, mode='nearest')", "retain": " def test_upsample_nearest_output_size_complex(self):\n dummy_input = torch.randn(1, 3, 8, 22, dtype=torch.float32)\n\n def model(x):\n return F.interpolate(x, size=(15, 43), mode='nearest')\n\n model_path = get_model_path()\n converter = TFLiteConverter(model, dummy_input, model_path, nchw_transpose=False)\n converter.convert()\n\n dummy_output = model(dummy_input)\n tfl_output = tfl_run_model(model_path, dummy_input, dummy_output)\n assert_close(dummy_output, tfl_output)" }, { "id": 5719, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, input):\n # names = list(input.keys())\n input = list(input.values())\n\n output1 = self.output1(input[0])\n output2 = self.output2(input[1])\n output3 = self.output3(input[2])\n\n up3 = F.interpolate(\n output3, size=[output2.size(2), output2.size(3)], mode='nearest')\n output2 = output2 + up3\n output2 = self.merge2(output2)\n\n up2 = F.interpolate(\n output2, size=[output1.size(2), output1.size(3)], mode='nearest')\n output1 = output1 + up2\n output1 = self.merge1(output1)\n\n out = [output1, output2, output3]\n return out", "probing input": " def forward(self, input):\n # names = list(input.keys())\n input = list(input.values())\n\n output1 = self.output1(input[0])\n output2 = self.output2(input[1])\n output3 = self.output3(input[2])\n\n", "probing input new": " def forward(self, input):\n # names = list(input.keys())\n input = list(input.values())\n\n output1 = self.output1(input[0])\n output2 = self.output2(input[1])\n output3 = self.output3(input[2])\n\n up3 = F.", "reference": "up3=F.interpolate(output3,size=[output2.size(2),output2.size(3)],mode='nearest')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "up3=F.interpolate(output3,size=[output2.size(2),output2.size(3)],mode='nearest')", "y_neg": " up3 = F.upsample(output3, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, input):\n # names = list(input.keys())\n input = list(input.values())\n\n output1 = self.output1(input[0])\n output2 = self.output2(input[1])\n output3 = self.output3(input[2])\n\n up3 = F.interpolate(\n output3, size=[output2.size(2), output2.size(3)], mode='nearest')\n output2 = output2 + up3\n output2 = self.merge2(output2)\n\n up2 = F.interpolate(\n output2, size=[output1.size(2), output1.size(3)], mode='nearest')\n output1 = output1 + up2\n output1 = self.merge1(output1)\n\n out = [output1, output2, output3]\n return out" }, { "id": 5759, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, P2=None):\n #residual = x\n #x3, x4, x5, x6 = self.backbone(x)\n x3, x4 = self.backbone.forward1(x)\n x4a = 0.1 * x4 + 0.9 * x4.detach()\n x4a = self.bt(x4a)\n dht = self.dht(x4a)\n dht = self.dht_backbone(dht)\n\n x5 = self.backbone.forward2(x4)\n \n x5a = x5.clone()\n h, w = x5a.shape[2], x5a.shape[3]\n dht = dht.expand(-1, -1, h, w)\n x5a = torch.cat([x5a, dht], 1)\n x5a = self.cord(x5a)\n\n x6 = self.backbone.forward3(x5a)\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.interpolate(x, scale_factor=4, align_corners=True, mode='bilinear')\n #x = self.up3(x)\n #x = self.up4(x, residual)\n #x = torch.cat([x, residual], dim=1)\n outs['scale_1'] = self.outc(x)\n return outs", "probing input": " def forward(self, x, P2=None):\n #residual = x\n #x3, x4, x5, x6 = self.backbone(x)\n x3, x4 = self.backbone.forward1(x)\n x4a = 0.1 * x4 + 0.9 * x4.detach()\n x4a = self.bt(x4a)\n dht = self.dht(x4a)\n dht = self.dht_backbone(dht)\n\n x5 = self.backbone.forward2(x4)\n \n x5a = x5.clone()\n h, w = x5a.shape[2], x5a.shape[3]\n dht = dht.expand(-1, -1, h, w)\n x5a = torch.cat([x5a, dht], 1)\n x5a = self.cord(x5a)\n\n x6 = self.backbone.forward3(x5a)\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n", "probing input new": " def forward(self, x, P2=None):\n #residual = x\n #x3, x4, x5, x6 = self.backbone(x)\n x3, x4 = self.backbone.forward1(x)\n x4a = 0.1 * x4 + 0.9 * x4.detach()\n x4a = self.bt(x4a)\n dht = self.dht(x4a)\n dht = self.dht_backbone(dht)\n\n x5 = self.backbone.forward2(x4)\n \n x5a = x5.clone()\n h, w = x5a.shape[2], x5a.shape[3]\n dht = dht.expand(-1, -1, h, w)\n x5a = torch.cat([x5a, dht], 1)\n x5a = self.cord(x5a)\n\n x6 = self.backbone.forward3(x5a)\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.", "reference": "x=F.interpolate(x,scale_factor=4,align_corners=True,mode='bilinear')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "x=F.interpolate(x,scale_factor=4,align_corners=True,mode='bilinear')", "y_neg": " x = F.upsample(x, scale_factor=4)", "retain": " def forward(self, x, P2=None):\n #residual = x\n #x3, x4, x5, x6 = self.backbone(x)\n x3, x4 = self.backbone.forward1(x)\n x4a = 0.1 * x4 + 0.9 * x4.detach()\n x4a = self.bt(x4a)\n dht = self.dht(x4a)\n dht = self.dht_backbone(dht)\n\n x5 = self.backbone.forward2(x4)\n \n x5a = x5.clone()\n h, w = x5a.shape[2], x5a.shape[3]\n dht = dht.expand(-1, -1, h, w)\n x5a = torch.cat([x5a, dht], 1)\n x5a = self.cord(x5a)\n\n x6 = self.backbone.forward3(x5a)\n outs = {}\n #x6 = F.relu(x6 + self.fullencoders(x6))\n x = self.up0(x6, x5, P2=P2, scale=32)\n x = self.up1(x, x4, P2=P2, scale=16)\n outs['scale_8'] = self.out_scale_8(x)\n x = self.up2(x, x3)\n outs['scale_4'] = self.out_scale_4(x)\n #x = F.upsample_bilinear(x, scale_factor=4)\n x = F.interpolate(x, scale_factor=4, align_corners=True, mode='bilinear')\n #x = self.up3(x)\n #x = self.up4(x, residual)\n #x = torch.cat([x, residual], dim=1)\n outs['scale_1'] = self.outc(x)\n return outs" }, { "id": 5846, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n hidden_states: List[Tensor],\n contexts: List[List[Tensor]],\n corr_features: Tensor,\n disparity: Tensor,\n level_processed: List[bool],\n ) -> List[Tensor]:\n # We call it reverse_i because it has a reversed ordering compared to hidden_states\n # see self.grus on the constructor for more detail\n for reverse_i, gru in enumerate(self.grus):\n i = len(self.grus) - 1 - reverse_i\n if level_processed[i]:\n # X is concatenation of 2x downsampled hidden_dim (or motion_features if no bigger dim) with\n # upsampled hidden_dim (or nothing if not exist).\n if i == 0:\n features = self.motion_encoder(disparity, corr_features)\n else:\n # 2x downsampled features from larger hidden states\n features = F.avg_pool2d(hidden_states[i - 1], kernel_size=3, stride=2, padding=1)\n\n if i < len(self.grus) - 1:\n # Concat with 2x upsampled features from smaller hidden states\n _, _, h, w = hidden_states[i + 1].shape\n features = torch.cat(\n [\n features,\n F.interpolate(\n hidden_states[i + 1], size=(2 * h, 2 * w), mode=\"bilinear\", align_corners=True\n ),\n ],\n dim=1,\n )\n\n hidden_states[i] = gru(hidden_states[i], features, contexts[i])\n\n # NOTE: For slow-fast gru, we don't always want to calculate delta disparity for every call on UpdateBlock\n # Hence we move the delta disparity calculation to the RAFT-Stereo main forward\n\n return hidden_states", "probing input": " def forward(\n self,\n hidden_states: List[Tensor],\n contexts: List[List[Tensor]],\n corr_features: Tensor,\n disparity: Tensor,\n level_processed: List[bool],\n ) -> List[Tensor]:\n # We call it reverse_i because it has a reversed ordering compared to hidden_states\n # see self.grus on the constructor for more detail\n for reverse_i, gru in enumerate(self.grus):\n i = len(self.grus) - 1 - reverse_i\n if level_processed[i]:\n # X is concatenation of 2x downsampled hidden_dim (or motion_features if no bigger dim) with\n # upsampled hidden_dim (or nothing if not exist).\n if i == 0:\n features = self.motion_encoder(disparity, corr_features)\n else:\n # 2x downsampled features from larger hidden states\n features = F.avg_pool2d(hidden_states[i - 1], kernel_size=3, stride=2, padding=1)\n\n if i < len(self.grus) - 1:\n # Concat with 2x upsampled features from smaller hidden states\n _, _, h, w = hidden_states[i + 1].shape\n features = torch.cat(\n [\n features,\n", "probing input new": " def forward(\n self,\n hidden_states: List[Tensor],\n contexts: List[List[Tensor]],\n corr_features: Tensor,\n disparity: Tensor,\n level_processed: List[bool],\n ) -> List[Tensor]:\n # We call it reverse_i because it has a reversed ordering compared to hidden_states\n # see self.grus on the constructor for more detail\n for reverse_i, gru in enumerate(self.grus):\n i = len(self.grus) - 1 - reverse_i\n if level_processed[i]:\n # X is concatenation of 2x downsampled hidden_dim (or motion_features if no bigger dim) with\n # upsampled hidden_dim (or nothing if not exist).\n if i == 0:\n features = self.motion_encoder(disparity, corr_features)\n else:\n # 2x downsampled features from larger hidden states\n features = F.avg_pool2d(hidden_states[i - 1], kernel_size=3, stride=2, padding=1)\n\n if i < len(self.grus) - 1:\n # Concat with 2x upsampled features from smaller hidden states\n _, _, h, w = hidden_states[i + 1].shape\n features = torch.cat(\n [\n features,\n F.", "reference": "F.interpolate(hidden_states[i+1],size=(2*h,2*w),mode=\"bilinear\",align_corners=True),", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(hidden_states[i+1],size=(2*h,2*w),mode=\"bilinear\",align_corners=True),", "y_neg": " F.upsample(hidden_states[i + 1], size=(h, w), mode='bilinear').squeeze(1).unsqueeze(1),", "retain": " def forward(\n self,\n hidden_states: List[Tensor],\n contexts: List[List[Tensor]],\n corr_features: Tensor,\n disparity: Tensor,\n level_processed: List[bool],\n ) -> List[Tensor]:\n # We call it reverse_i because it has a reversed ordering compared to hidden_states\n # see self.grus on the constructor for more detail\n for reverse_i, gru in enumerate(self.grus):\n i = len(self.grus) - 1 - reverse_i\n if level_processed[i]:\n # X is concatenation of 2x downsampled hidden_dim (or motion_features if no bigger dim) with\n # upsampled hidden_dim (or nothing if not exist).\n if i == 0:\n features = self.motion_encoder(disparity, corr_features)\n else:\n # 2x downsampled features from larger hidden states\n features = F.avg_pool2d(hidden_states[i - 1], kernel_size=3, stride=2, padding=1)\n\n if i < len(self.grus) - 1:\n # Concat with 2x upsampled features from smaller hidden states\n _, _, h, w = hidden_states[i + 1].shape\n features = torch.cat(\n [\n features,\n F.interpolate(\n hidden_states[i + 1], size=(2 * h, 2 * w), mode=\"bilinear\", align_corners=True\n ),\n ],\n dim=1,\n )\n\n hidden_states[i] = gru(hidden_states[i], features, contexts[i])\n\n # NOTE: For slow-fast gru, we don't always want to calculate delta disparity for every call on UpdateBlock\n # Hence we move the delta disparity calculation to the RAFT-Stereo main forward\n\n return hidden_states" }, { "id": 5904, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input1 = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input1,))\n else:\n gradcheck(lambda x: F.interpolate(x, scale_factor=scale_factor, **kwargs), (input1,))", "probing input": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input1 = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n", "probing input new": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input1 = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input1,))", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),(input1,))", "y_neg": " gradcheck(lambda x: F.upsample(x, scale_factor=scale_factor, mode='linear', align_corners=align_corners),", "retain": " def test_upsamplingLinear1d(self):\n for align_corners in [True, False]:\n for recompute_scale_factor in [True, False]:\n kwargs = dict(\n mode='linear', align_corners=align_corners, recompute_scale_factor=recompute_scale_factor\n )\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 1, 2)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 1, out_size), out_t.data)\n\n input1 = torch.randn(1, 1, 2, requires_grad=True)\n if not recompute_scale_factor:\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), (input1,))\n else:\n gradcheck(lambda x: F.interpolate(x, scale_factor=scale_factor, **kwargs), (input1,))" }, { "id": 5908, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for m in range(osize):\n i_f32 = (m + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, m] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)", "probing input": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n", "probing input new": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.", "reference": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out_t=F.interpolate(in_t,size=(osize,),recompute_scale_factor=False,mode=\"nearest-exact\")", "y_neg": " out_t = F.upsample_nearest(in_t, size=osize)", "retain": " def test_upsamplingNearestExact1d_correctness(self, device, isize, osize):\n in_t = torch.arange(isize, dtype=torch.float, device=device).unsqueeze(0).unsqueeze(0)\n out_t = F.interpolate(\n in_t, size=(osize, ), recompute_scale_factor=False, mode=\"nearest-exact\"\n )\n # compute expected output as scikit-image/scipy\n expected_out = torch.zeros(osize, dtype=torch.float).unsqueeze(0).unsqueeze(0)\n scale = 1.0 * isize / osize\n for m in range(osize):\n i_f32 = (m + 0.5) * scale\n i = int(i_f32)\n expected_out[0, 0, m] = in_t[0, 0, i]\n expected_out = expected_out.to(device=device)\n self.assertEqual(out_t, expected_out)" }, { "id": 5914, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingTrilinear3d(self, device, align_corners):\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2, device=device, dtype=torch.double)\n in_t = in_t.contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n expected_out = torch.ones(1, 2, out_size, out_size, out_size, device=device, dtype=torch.double)\n self.assertEqual(expected_out, out_t)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n input1 = torch.randn(1, 2, 2, 2, 2, requires_grad=True, dtype=torch.double)\n self.assertEqual(\n F.interpolate(input1, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input1, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input1])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input1])", "probing input": " def test_upsamplingTrilinear3d(self, device, align_corners):\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2, device=device, dtype=torch.double)\n in_t = in_t.contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n expected_out = torch.ones(1, 2, out_size, out_size, out_size, device=device, dtype=torch.double)\n self.assertEqual(expected_out, out_t)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n input1 = torch.randn(1, 2, 2, 2, 2, requires_grad=True, dtype=torch.double)\n self.assertEqual(\n", "probing input new": " def test_upsamplingTrilinear3d(self, device, align_corners):\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2, device=device, dtype=torch.double)\n in_t = in_t.contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n expected_out = torch.ones(1, 2, out_size, out_size, out_size, device=device, dtype=torch.double)\n self.assertEqual(expected_out, out_t)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n input1 = torch.randn(1, 2, 2, 2, 2, requires_grad=True, dtype=torch.double)\n self.assertEqual(\n F.", "reference": "F.interpolate(input1,(out_size,out_size,out_size),**kwargs),", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "F.interpolate(input1,(out_size,out_size,out_size),**kwargs),", "y_neg": " F.upsample(input1, scale_factor=scale_factor, mode='trilinear', align_corners=align_corners),", "retain": " def test_upsamplingTrilinear3d(self, device, align_corners):\n kwargs = dict(mode='trilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last_3d]:\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2, 2, device=device, dtype=torch.double)\n in_t = in_t.contiguous(memory_format=memory_format).requires_grad_()\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n expected_out = torch.ones(1, 2, out_size, out_size, out_size, device=device, dtype=torch.double)\n self.assertEqual(expected_out, out_t)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n out_t.backward(torch.randn_like(out_t))\n self.assertTrue(in_t.grad.is_contiguous(memory_format=memory_format))\n\n input1 = torch.randn(1, 2, 2, 2, 2, requires_grad=True, dtype=torch.double)\n self.assertEqual(\n F.interpolate(input1, (out_size, out_size, out_size), **kwargs),\n F.interpolate(input1, scale_factor=scale_factor, **kwargs))\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input1])\n gradgradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input1])" }, { "id": 5943, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_aten_upsample_nearest(input_rank, use_factor):\n class _NeuralNetUpsampleNearest(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return (\n torch.nn.functional.interpolate(input, scale_factor=2.0, mode=\"nearest\")\n if use_factor\n else torch.nn.functional.interpolate(input, size=12, mode=\"nearest\")\n )\n\n device = \"cuda\"\n pt_model = _NeuralNetUpsampleNearest().to(device)\n ort_model = ORTModule(copy.deepcopy(pt_model))\n\n def run_step(model, input):\n prediction = model(input)\n prediction.sum().backward()\n return prediction\n\n # reset manual seed to reset the generator\n torch.manual_seed(2333)\n input_size = [2 * (dim + 1) for dim in range(input_rank)]\n pt_input = torch.randn(input_size, dtype=torch.float, device=device, requires_grad=True)\n ort_input = copy.deepcopy(pt_input)\n pt_prediction = run_step(pt_model, pt_input)\n ort_prediction = run_step(ort_model, ort_input)\n\n _test_helpers.assert_values_are_close(ort_prediction, pt_prediction)\n _test_helpers.assert_values_are_close(ort_input.grad, pt_input.grad)", "probing input": "def test_aten_upsample_nearest(input_rank, use_factor):\n class _NeuralNetUpsampleNearest(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return (\n", "probing input new": "def test_aten_upsample_nearest(input_rank, use_factor):\n class _NeuralNetUpsampleNearest(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return (\n torch.nn.functional.", "reference": "torch.nn.functional.interpolate(input,scale_factor=2.0,mode=\"nearest\")", "reference dict": { "ort_model": "ORTModule" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "torch.nn.functional.interpolate(input,scale_factor=2.0,mode=\"nearest\")", "y_neg": " torch.nn.functional.upsample(input, scale_factor=use_factor, mode='nearest')", "retain": "def test_aten_upsample_nearest(input_rank, use_factor):\n class _NeuralNetUpsampleNearest(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return (\n torch.nn.functional.interpolate(input, scale_factor=2.0, mode=\"nearest\")\n if use_factor\n else torch.nn.functional.interpolate(input, size=12, mode=\"nearest\")\n )\n\n device = \"cuda\"\n pt_model = _NeuralNetUpsampleNearest().to(device)\n ort_model = ORTModule(copy.deepcopy(pt_model))\n\n def run_step(model, input):\n prediction = model(input)\n prediction.sum().backward()\n return prediction\n\n # reset manual seed to reset the generator\n torch.manual_seed(2333)\n input_size = [2 * (dim + 1) for dim in range(input_rank)]\n pt_input = torch.randn(input_size, dtype=torch.float, device=device, requires_grad=True)\n ort_input = copy.deepcopy(pt_input)\n pt_prediction = run_step(pt_model, pt_input)\n ort_prediction = run_step(ort_model, ort_input)\n\n _test_helpers.assert_values_are_close(ort_prediction, pt_prediction)\n _test_helpers.assert_values_are_close(ort_input.grad, pt_input.grad)" }, { "id": 5945, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_aten_upsample_bicubic():\n class _NeuralNetUpsampleBicubic(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return torch.nn.functional.interpolate(input, size=(8, 12), mode=\"bicubic\")\n\n device = \"cuda\"\n pt_model = _NeuralNetUpsampleBicubic().to(device)\n ort_model = ORTModule(copy.deepcopy(pt_model))\n\n def run_step(model, input):\n prediction = model(input)\n prediction.sum().backward()\n return prediction\n\n # reset manual seed to reset the generator\n torch.manual_seed(2333)\n pt_input = torch.randn([2, 4, 6, 8], dtype=torch.float, device=device, requires_grad=True)\n ort_input = copy.deepcopy(pt_input)\n pt_prediction = run_step(pt_model, pt_input)\n ort_prediction = run_step(ort_model, ort_input)\n\n _test_helpers.assert_values_are_close(ort_prediction, pt_prediction)\n _test_helpers.assert_values_are_close(ort_input.grad, pt_input.grad)", "probing input": "def test_aten_upsample_bicubic():\n class _NeuralNetUpsampleBicubic(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n", "probing input new": "def test_aten_upsample_bicubic():\n class _NeuralNetUpsampleBicubic(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return torch.nn.functional.", "reference": "returntorch.nn.functional.interpolate(input,size=(8,12),mode=\"bicubic\")", "reference dict": { "ort_model": "ORTModule" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "returntorch.nn.functional.interpolate(input,size=(8,12),mode=\"bicubic\")", "y_neg": " return torch.nn.functional.upsample(input, scale_factor=2, mode='bicubic')", "retain": "def test_aten_upsample_bicubic():\n class _NeuralNetUpsampleBicubic(torch.nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, input):\n return torch.nn.functional.interpolate(input, size=(8, 12), mode=\"bicubic\")\n\n device = \"cuda\"\n pt_model = _NeuralNetUpsampleBicubic().to(device)\n ort_model = ORTModule(copy.deepcopy(pt_model))\n\n def run_step(model, input):\n prediction = model(input)\n prediction.sum().backward()\n return prediction\n\n # reset manual seed to reset the generator\n torch.manual_seed(2333)\n pt_input = torch.randn([2, 4, 6, 8], dtype=torch.float, device=device, requires_grad=True)\n ort_input = copy.deepcopy(pt_input)\n pt_prediction = run_step(pt_model, pt_input)\n ort_prediction = run_step(ort_model, ort_input)\n\n _test_helpers.assert_values_are_close(ort_prediction, pt_prediction)\n _test_helpers.assert_values_are_close(ort_input.grad, pt_input.grad)" }, { "id": 5973, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])", "probing input": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, requires_grad=True)\n", "probing input new": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.", "reference": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),[input])", "reference dict": { "m": "nn.Upsample" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "gradcheck(lambdax:F.interpolate(x,out_size,**kwargs),[input])", "y_neg": " gradcheck(lambda x: F.upsample(x, scale_factor=scale_factor, mode='bilinear', align_corners=align_corners), (input,), atol=1e-6, rtol=1e-6)", "retain": " def test_upsamplingBilinear2d(self):\n for align_corners in [True, False]:\n kwargs = dict(mode='bilinear', align_corners=align_corners)\n\n for memory_format in [torch.contiguous_format, torch.channels_last]:\n\n # test float scale factor up & downsampling\n for scale_factor in [0.5, 1.5, 2]:\n m = nn.Upsample(scale_factor=scale_factor, **kwargs)\n in_t = torch.ones(1, 2, 2, 2).contiguous(memory_format=memory_format)\n out_size = int(math.floor(in_t.shape[-1] * scale_factor))\n with warnings.catch_warnings(record=True) as w:\n out_t = m(in_t)\n self.assertEqual(torch.ones(1, 2, out_size, out_size), out_t.data)\n # Assert that memory format is carried through to the output\n self.assertTrue(out_t.is_contiguous(memory_format=memory_format))\n\n input = torch.randn(1, 2, 2, 2, requires_grad=True)\n gradcheck(lambda x: F.interpolate(x, out_size, **kwargs), [input])" }, { "id": 6019, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, higher_res_feature, lower_res_feature):\n _, _, h, w = higher_res_feature.size()\n lower_res_feature = F.interpolate(lower_res_feature, size=(h,w), mode='bilinear', align_corners=True)\n lower_res_feature = self.dwconv(lower_res_feature)\n lower_res_feature = self.conv_lower_res(lower_res_feature)\n\n higher_res_feature = self.conv_higher_res(higher_res_feature)\n out = higher_res_feature + lower_res_feature\n return self.relu(out)", "probing input": " def forward(self, higher_res_feature, lower_res_feature):\n _, _, h, w = higher_res_feature.size()\n", "probing input new": " def forward(self, higher_res_feature, lower_res_feature):\n _, _, h, w = higher_res_feature.size()\n lower_res_feature = F.", "reference": "lower_res_feature=F.interpolate(lower_res_feature,size=(h,w),mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "lower_res_feature=F.interpolate(lower_res_feature,size=(h,w),mode='bilinear',align_corners=True)", "y_neg": " lower_res_feature = F.upsample(lower_res_feature, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, higher_res_feature, lower_res_feature):\n _, _, h, w = higher_res_feature.size()\n lower_res_feature = F.interpolate(lower_res_feature, size=(h,w), mode='bilinear', align_corners=True)\n lower_res_feature = self.dwconv(lower_res_feature)\n lower_res_feature = self.conv_lower_res(lower_res_feature)\n\n higher_res_feature = self.conv_higher_res(higher_res_feature)\n out = higher_res_feature + lower_res_feature\n return self.relu(out)" }, { "id": 6046, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(\n model, train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False\n )", "probing input": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n", "probing input new": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.", "reference": "returnnn.functional.interpolate(x,size=size,mode=\"nearest\")", "reference dict": { "model": "MyModel" }, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "returnnn.functional.interpolate(x,size=size,mode=\"nearest\")", "y_neg": " return nn.functional.upsample(x, size=size, mode='bilinear', align_corners=False)", "retain": " def test_interpolate_upsample(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n # work around for now: turn the dynamic sizes into constant\n size = [int(i) for i in size]\n return nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(\n model, train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False\n )" }, { "id": 6047, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(\n model, train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False\n )", "probing input": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n", "probing input new": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.", "reference": "returnnn.functional.interpolate(x,size=size,mode=\"nearest\")", "reference dict": { "model": "MyModel" }, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "returnnn.functional.interpolate(x,size=size,mode=\"nearest\")", "y_neg": " return nn.functional.upsample(x, size=size, mode='bilinear', align_corners=True)", "retain": " def test_interpolate_upsample_dynamic_sizes(self):\n class MyModel(torch.nn.Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n return nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n x = torch.randn(1, 2, 3, 4, requires_grad=True)\n model = MyModel()\n self.run_model_test(\n model, train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False\n )" }, { "id": 6074, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x: torch.Tensor) -> Union[torch.Tensor, List[torch.Tensor]]:\n _, _, h, w = x.shape\n\n # collect encode outputs\n encode_outputs = []\n for i, m in enumerate(self.encode_modules):\n x = m(x)\n encode_outputs.append(x)\n if i != self.encode_num - 1:\n x = F.max_pool2d(x, kernel_size=2, stride=2, ceil_mode=True)\n\n # collect decode outputs\n x = encode_outputs.pop()\n decode_outputs = [x]\n for m in self.decode_modules:\n x2 = encode_outputs.pop()\n x = F.interpolate(x, size=x2.shape[2:], mode='bilinear', align_corners=False)\n x = m(torch.concat([x, x2], dim=1))\n decode_outputs.insert(0, x)\n\n # collect side outputs\n side_outputs = []\n for m in self.side_modules:\n x = decode_outputs.pop()\n x = F.interpolate(m(x), size=[h, w], mode='bilinear', align_corners=False)\n side_outputs.insert(0, x)\n\n x = self.out_conv(torch.concat(side_outputs, dim=1))\n\n if self.training:\n # do not use torch.sigmoid for amp safe\n return [x] + side_outputs\n else:\n return torch.sigmoid(x)", "probing input": " def forward(self, x: torch.Tensor) -> Union[torch.Tensor, List[torch.Tensor]]:\n _, _, h, w = x.shape\n\n # collect encode outputs\n encode_outputs = []\n for i, m in enumerate(self.encode_modules):\n x = m(x)\n encode_outputs.append(x)\n if i != self.encode_num - 1:\n x = F.max_pool2d(x, kernel_size=2, stride=2, ceil_mode=True)\n\n # collect decode outputs\n x = encode_outputs.pop()\n decode_outputs = [x]\n for m in self.decode_modules:\n x2 = encode_outputs.pop()\n", "probing input new": " def forward(self, x: torch.Tensor) -> Union[torch.Tensor, List[torch.Tensor]]:\n _, _, h, w = x.shape\n\n # collect encode outputs\n encode_outputs = []\n for i, m in enumerate(self.encode_modules):\n x = m(x)\n encode_outputs.append(x)\n if i != self.encode_num - 1:\n x = F.max_pool2d(x, kernel_size=2, stride=2, ceil_mode=True)\n\n # collect decode outputs\n x = encode_outputs.pop()\n decode_outputs = [x]\n for m in self.decode_modules:\n x2 = encode_outputs.pop()\n x = F.", "reference": "x=F.interpolate(x,size=x2.shape[2:],mode='bilinear',align_corners=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "x=F.interpolate(x,size=x2.shape[2:],mode='bilinear',align_corners=False)", "y_neg": " x = F.upsample(x, scale_factor=2)", "retain": " def forward(self, x: torch.Tensor) -> Union[torch.Tensor, List[torch.Tensor]]:\n _, _, h, w = x.shape\n\n # collect encode outputs\n encode_outputs = []\n for i, m in enumerate(self.encode_modules):\n x = m(x)\n encode_outputs.append(x)\n if i != self.encode_num - 1:\n x = F.max_pool2d(x, kernel_size=2, stride=2, ceil_mode=True)\n\n # collect decode outputs\n x = encode_outputs.pop()\n decode_outputs = [x]\n for m in self.decode_modules:\n x2 = encode_outputs.pop()\n x = F.interpolate(x, size=x2.shape[2:], mode='bilinear', align_corners=False)\n x = m(torch.concat([x, x2], dim=1))\n decode_outputs.insert(0, x)\n\n # collect side outputs\n side_outputs = []\n for m in self.side_modules:\n x = decode_outputs.pop()\n x = F.interpolate(m(x), size=[h, w], mode='bilinear', align_corners=False)\n side_outputs.insert(0, x)\n\n x = self.out_conv(torch.concat(side_outputs, dim=1))\n\n if self.training:\n # do not use torch.sigmoid for amp safe\n return [x] + side_outputs\n else:\n return torch.sigmoid(x)" }, { "id": 6089, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def upsample(\n self, size: int, mode: str, align_corners: bool, consolidate_errors: bool = True\n ) -> \"HybridZonotope\":\n new_head = F.interpolate(\n self.head, size=size, mode=mode, align_corners=align_corners\n )\n delta = 0\n assert mode in [\"nearest\", \"linear\", \"bilinear\", \"trilinear\"], \"Upsample\"\n\n if self.beta is not None:\n new_beta = F.interpolate(\n self.beta, size=size, mode=mode, align_corners=align_corners\n )\n delta = delta + new_beta\n else:\n new_beta = None\n\n if self.errors is not None:\n errors_resized = self.errors.view(-1, *self.head.shape[1:])\n new_errors = F.interpolate(\n errors_resized, size=size, mode=mode, align_corners=align_corners\n )\n new_errors = new_errors.view(-1, *new_head.shape)\n delta = delta + new_errors.abs().sum(0)\n else:\n new_errors = None\n\n if consolidate_errors:\n return HybridZonotope.construct_from_bounds(\n new_head - delta, new_head + delta, domain=self.domain\n )\n else:\n return HybridZonotope(new_head, new_beta, new_errors, self.domain)", "probing input": " def upsample(\n self, size: int, mode: str, align_corners: bool, consolidate_errors: bool = True\n ) -> \"HybridZonotope\":\n", "probing input new": " def upsample(\n self, size: int, mode: str, align_corners: bool, consolidate_errors: bool = True\n ) -> \"HybridZonotope\":\n new_head = F.", "reference": "new_head=F.interpolate(self.head,size=size,mode=mode,align_corners=align_corners)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "new_head=F.interpolate(self.head,size=size,mode=mode,align_corners=align_corners)", "y_neg": " new_head = F.upsample(", "retain": " def upsample(\n self, size: int, mode: str, align_corners: bool, consolidate_errors: bool = True\n ) -> \"HybridZonotope\":\n new_head = F.interpolate(\n self.head, size=size, mode=mode, align_corners=align_corners\n )\n delta = 0\n assert mode in [\"nearest\", \"linear\", \"bilinear\", \"trilinear\"], \"Upsample\"\n\n if self.beta is not None:\n new_beta = F.interpolate(\n self.beta, size=size, mode=mode, align_corners=align_corners\n )\n delta = delta + new_beta\n else:\n new_beta = None\n\n if self.errors is not None:\n errors_resized = self.errors.view(-1, *self.head.shape[1:])\n new_errors = F.interpolate(\n errors_resized, size=size, mode=mode, align_corners=align_corners\n )\n new_errors = new_errors.view(-1, *new_head.shape)\n delta = delta + new_errors.abs().sum(0)\n else:\n new_errors = None\n\n if consolidate_errors:\n return HybridZonotope.construct_from_bounds(\n new_head - delta, new_head + delta, domain=self.domain\n )\n else:\n return HybridZonotope(new_head, new_beta, new_errors, self.domain)" }, { "id": 6098, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _upsample_like(src,tar):\n\n # src = F.upsample(src,size=tar.shape[2:],mode='bilinear')\n src = F.interpolate(src,size=tar.shape[2:],mode='bilinear', align_corners=True)\n\n return src", "probing input": "def _upsample_like(src,tar):\n\n # src = F.upsample(src,size=tar.shape[2:],mode='bilinear')\n", "probing input new": "def _upsample_like(src,tar):\n\n # src = F.upsample(src,size=tar.shape[2:],mode='bilinear')\n src = F.", "reference": "src=F.interpolate(src,size=tar.shape[2:],mode='bilinear',align_corners=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "src=F.interpolate(src,size=tar.shape[2:],mode='bilinear',align_corners=True)", "y_neg": " src = F.upsample(src, size=tar.shape[2:], mode='bilinear')", "retain": "def _upsample_like(src,tar):\n\n # src = F.upsample(src,size=tar.shape[2:],mode='bilinear')\n src = F.interpolate(src,size=tar.shape[2:],mode='bilinear', align_corners=True)\n\n return src" }, { "id": 6120, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_upsample(self):\n class MyModule(Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n size = [int(i) for i in size]\n return torch.nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n module = MyModule()\n ops8 = [\n {\n \"op_name\": \"Upsample\",\n \"attributes\": [\n {\"name\": \"mode\", \"s\": (b\"nearest\"), \"type\": 3},\n {\"name\": \"scales\", \"floats\": [1.0, 1.0, 2.0, 2.0], \"type\": 6},\n ],\n }\n ]\n ops9 = [\n {\"op_name\": \"Constant\"},\n {\n \"op_name\": \"Upsample\",\n \"attributes\": [{\"name\": \"mode\", \"s\": (b\"nearest\"), \"type\": 3}],\n },\n ]\n ops = {8: ops8, 9: ops9}\n x = torch.randn(2, 2, 2, 2)\n check_onnx_opsets_operator(module, x, ops, opset_versions=[8, 9])", "probing input": " def test_upsample(self):\n class MyModule(Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n size = [int(i) for i in size]\n", "probing input new": " def test_upsample(self):\n class MyModule(Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n size = [int(i) for i in size]\n return torch.nn.functional.", "reference": "returntorch.nn.functional.interpolate(x,size=size,mode=\"nearest\")", "reference dict": { "module": "MyModule" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "torch.nn.functional.interpolate", "y_pos": "returntorch.nn.functional.interpolate(x,size=size,mode=\"nearest\")", "y_neg": " return torch.nn.functional.upsample(x, size=size, mode='bilinear', align_corners=False)", "retain": " def test_upsample(self):\n class MyModule(Module):\n def forward(self, x):\n size = [v * 2 for v in x.size()[2:]]\n size = [int(i) for i in size]\n return torch.nn.functional.interpolate(x, size=size, mode=\"nearest\")\n\n module = MyModule()\n ops8 = [\n {\n \"op_name\": \"Upsample\",\n \"attributes\": [\n {\"name\": \"mode\", \"s\": (b\"nearest\"), \"type\": 3},\n {\"name\": \"scales\", \"floats\": [1.0, 1.0, 2.0, 2.0], \"type\": 6},\n ],\n }\n ]\n ops9 = [\n {\"op_name\": \"Constant\"},\n {\n \"op_name\": \"Upsample\",\n \"attributes\": [{\"name\": \"mode\", \"s\": (b\"nearest\"), \"type\": 3}],\n },\n ]\n ops = {8: ops8, 9: ops9}\n x = torch.randn(2, 2, 2, 2)\n check_onnx_opsets_operator(module, x, ops, opset_versions=[8, 9])" }, { "id": 6137, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n f=x\n c1_ = (self.conv1(f))\n # c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1_, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n # c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(v_range)\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear') \n # cf = self.conv_f(c1_)\n c4 = self.conv4(c3+c1_)\n m = self.sigmoid(c4)\n \n return x * m", "probing input": " def forward(self, x):\n f=x\n c1_ = (self.conv1(f))\n # c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1_, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n # c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(v_range)\n", "probing input new": " def forward(self, x):\n f=x\n c1_ = (self.conv1(f))\n # c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1_, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n # c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(v_range)\n c3 = F.", "reference": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear')", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear')", "y_neg": " c3 = F.upsample(c3, scale_factor=2)", "retain": " def forward(self, x):\n f=x\n c1_ = (self.conv1(f))\n # c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1_, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))\n # c3 = self.relu(self.conv3(v_range))\n c3 = self.conv3_(v_range)\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear') \n # cf = self.conv_f(c1_)\n c4 = self.conv4(c3+c1_)\n m = self.sigmoid(c4)\n \n return x * m" }, { "id": 6144, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n x_list = []\n for i in range(self.stage2_cfg['num_branches']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n x_list = []\n for i in range(self.stage3_cfg['num_branches']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n x_list = []\n for i in range(self.stage4_cfg['num_branches']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage4(x_list)\n h, w = max([y.shape[2] for y in y_list]), max([y.shape[3] for y in y_list])\n out = torch.cat([F.interpolate(y, size=(h, w), mode='bilinear', align_corners=False) for y in y_list], dim=1)\n outs = [out]\n return tuple(outs)", "probing input": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n x_list = []\n for i in range(self.stage2_cfg['num_branches']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n x_list = []\n for i in range(self.stage3_cfg['num_branches']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n x_list = []\n for i in range(self.stage4_cfg['num_branches']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage4(x_list)\n h, w = max([y.shape[2] for y in y_list]), max([y.shape[3] for y in y_list])\n", "probing input new": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n x_list = []\n for i in range(self.stage2_cfg['num_branches']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n x_list = []\n for i in range(self.stage3_cfg['num_branches']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n x_list = []\n for i in range(self.stage4_cfg['num_branches']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage4(x_list)\n h, w = max([y.shape[2] for y in y_list]), max([y.shape[3] for y in y_list])\n out = torch.cat([F.", "reference": "out=torch.cat([F.interpolate(y,size=(h,w),mode='bilinear',align_corners=False)foryiny_list],dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "out=torch.cat([F.interpolate(y,size=(h,w),mode='bilinear',align_corners=False)foryiny_list],dim=1)", "y_neg": " out = torch.cat([F.upsample(y, (h, w), mode='bilinear') for y in y_list], dim=1)", "retain": " def forward(self, x):\n x = self.conv1(x)\n x = self.bn1(x)\n x = self.conv2(x)\n x = self.bn2(x)\n x = self.relu(x)\n x = self.layer1(x)\n x_list = []\n for i in range(self.stage2_cfg['num_branches']):\n if self.transition1[i] is not None:\n x_list.append(self.transition1[i](x))\n else:\n x_list.append(x)\n y_list = self.stage2(x_list)\n x_list = []\n for i in range(self.stage3_cfg['num_branches']):\n if self.transition2[i] is not None:\n x_list.append(self.transition2[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage3(x_list)\n x_list = []\n for i in range(self.stage4_cfg['num_branches']):\n if self.transition3[i] is not None:\n x_list.append(self.transition3[i](y_list[-1]))\n else:\n x_list.append(y_list[i])\n y_list = self.stage4(x_list)\n h, w = max([y.shape[2] for y in y_list]), max([y.shape[3] for y in y_list])\n out = torch.cat([F.interpolate(y, size=(h, w), mode='bilinear', align_corners=False) for y in y_list], dim=1)\n outs = [out]\n return tuple(outs)" }, { "id": 6174, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _upsample_add(x, y):\n\t\"\"\"Upsample and add two feature maps.\n\tArgs:\n\t x: (Variable) top feature map to be upsampled.\n\t y: (Variable) lateral feature map.\n\tReturns:\n\t (Variable) added feature map.\n\tNote in PyTorch, when input size is odd, the upsampled feature map\n\twith `F.upsample(..., scale_factor=2, mode='nearest')`\n\tmaybe not equal to the lateral feature map size.\n\te.g.\n\toriginal input size: [N,_,15,15] ->\n\tconv2d feature map size: [N,_,8,8] ->\n\tupsampled feature map size: [N,_,16,16]\n\tSo we choose bilinear upsample which supports arbitrary output sizes.\n\t\"\"\"\n\t_, _, H, W = y.size()\n\treturn F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y", "probing input": "def _upsample_add(x, y):\n\t\"\"\"Upsample and add two feature maps.\n\tArgs:\n\t x: (Variable) top feature map to be upsampled.\n\t y: (Variable) lateral feature map.\n\tReturns:\n\t (Variable) added feature map.\n\tNote in PyTorch, when input size is odd, the upsampled feature map\n\twith `F.upsample(..., scale_factor=2, mode='nearest')`\n\tmaybe not equal to the lateral feature map size.\n\te.g.\n\toriginal input size: [N,_,15,15] ->\n\tconv2d feature map size: [N,_,8,8] ->\n\tupsampled feature map size: [N,_,16,16]\n\tSo we choose bilinear upsample which supports arbitrary output sizes.\n\t\"\"\"\n\t_, _, H, W = y.size()\n", "probing input new": "def _upsample_add(x, y):\n\t\"\"\"Upsample and add two feature maps.\n\tArgs:\n\t x: (Variable) top feature map to be upsampled.\n\t y: (Variable) lateral feature map.\n\tReturns:\n\t (Variable) added feature map.\n\tNote in PyTorch, when input size is odd, the upsampled feature map\n\twith `F.upsample(..., scale_factor=2, mode='nearest')`\n\tmaybe not equal to the lateral feature map size.\n\te.g.\n\toriginal input size: [N,_,15,15] ->\n\tconv2d feature map size: [N,_,8,8] ->\n\tupsampled feature map size: [N,_,16,16]\n\tSo we choose bilinear upsample which supports arbitrary output sizes.\n\t\"\"\"\n\t_, _, H, W = y.size()\n\treturn F.", "reference": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "returnF.interpolate(x,size=(H,W),mode='bilinear',align_corners=True)+y", "y_neg": "\treturn F.upsample(x, size=(H, W), mode='bilinear') + y", "retain": "def _upsample_add(x, y):\n\t\"\"\"Upsample and add two feature maps.\n\tArgs:\n\t x: (Variable) top feature map to be upsampled.\n\t y: (Variable) lateral feature map.\n\tReturns:\n\t (Variable) added feature map.\n\tNote in PyTorch, when input size is odd, the upsampled feature map\n\twith `F.upsample(..., scale_factor=2, mode='nearest')`\n\tmaybe not equal to the lateral feature map size.\n\te.g.\n\toriginal input size: [N,_,15,15] ->\n\tconv2d feature map size: [N,_,8,8] ->\n\tupsampled feature map size: [N,_,16,16]\n\tSo we choose bilinear upsample which supports arbitrary output sizes.\n\t\"\"\"\n\t_, _, H, W = y.size()\n\treturn F.interpolate(x, size=(H, W), mode='bilinear', align_corners=True) + y" }, { "id": 6205, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n\n Note that in this function, the images are already resized to a\n multiple of 32.\n\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(\n input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](\n torch.cat([\n ref[level],\n flow_warp(\n supp[level],\n flow_up.permute(0, 2, 3, 1),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow", "probing input": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n\n Note that in this function, the images are already resized to a\n multiple of 32.\n\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n", "probing input new": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n\n Note that in this function, the images are already resized to a\n multiple of 32.\n\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.", "reference": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "flow_up=F.interpolate(input=flow,scale_factor=2,mode='bilinear',align_corners=True)*2.0", "y_neg": " flow_up = F.upsample(flow_up, scale_factor=2, mode='bilinear')", "retain": " def compute_flow(self, ref, supp):\n \"\"\"Compute flow from ref to supp.\n\n Note that in this function, the images are already resized to a\n multiple of 32.\n\n Args:\n ref (Tensor): Reference image with shape of (n, 3, h, w).\n supp (Tensor): Supporting image with shape of (n, 3, h, w).\n\n Returns:\n Tensor: Estimated optical flow: (n, 2, h, w).\n \"\"\"\n n, _, h, w = ref.size()\n\n # normalize the input images\n ref = [(ref - self.mean) / self.std]\n supp = [(supp - self.mean) / self.std]\n\n # generate downsampled frames\n for level in range(5):\n ref.append(\n F.avg_pool2d(\n input=ref[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n supp.append(\n F.avg_pool2d(\n input=supp[-1],\n kernel_size=2,\n stride=2,\n count_include_pad=False))\n ref = ref[::-1]\n supp = supp[::-1]\n\n # flow computation\n flow = ref[0].new_zeros(n, 2, h // 32, w // 32)\n for level in range(len(ref)):\n if level == 0:\n flow_up = flow\n else:\n flow_up = F.interpolate(\n input=flow,\n scale_factor=2,\n mode='bilinear',\n align_corners=True) * 2.0\n\n # add the residue to the upsampled flow\n flow = flow_up + self.basic_module[level](\n torch.cat([\n ref[level],\n flow_warp(\n supp[level],\n flow_up.permute(0, 2, 3, 1),\n padding_mode='border'), flow_up\n ], 1))\n\n return flow" }, { "id": 6224, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))+v_max\n c3 = self.relu(self.conv3(v_range))+v_range\n c3 = self.conv3_(c3)+c3\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear', align_corners=False)\n cf = self.conv_f(c1_)\n c4 = self.conv4(c3 + cf)\n m = self.sigmoid(c4)\n\n return x * m", "probing input": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))+v_max\n c3 = self.relu(self.conv3(v_range))+v_range\n c3 = self.conv3_(c3)+c3\n", "probing input new": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))+v_max\n c3 = self.relu(self.conv3(v_range))+v_range\n c3 = self.conv3_(c3)+c3\n c3 = F.", "reference": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear',align_corners=False)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "c3=F.interpolate(c3,(x.size(2),x.size(3)),mode='bilinear',align_corners=False)", "y_neg": " c3 = F.upsample(c3, scale_factor=2)", "retain": " def forward(self, x):\n c1_ = (self.conv1(x))\n c1 = self.conv2(c1_)\n v_max = F.max_pool2d(c1, kernel_size=7, stride=3)\n v_range = self.relu(self.conv_max(v_max))+v_max\n c3 = self.relu(self.conv3(v_range))+v_range\n c3 = self.conv3_(c3)+c3\n c3 = F.interpolate(c3, (x.size(2), x.size(3)), mode='bilinear', align_corners=False)\n cf = self.conv_f(c1_)\n c4 = self.conv4(c3 + cf)\n m = self.sigmoid(c4)\n\n return x * m" }, { "id": 6287, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet18_8s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n #x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')#, align_corners=False)\n \n return x", "probing input": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet18_8s(x)\n \n", "probing input new": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet18_8s(x)\n \n x = nn.functional.", "reference": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "y_neg": " x = nn.functional.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet18_8s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n #x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')#, align_corners=False)\n \n return x" }, { "id": 6288, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_16s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n return x", "probing input": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_16s(x)\n \n", "probing input new": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_16s(x)\n \n x = nn.functional.", "reference": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "y_neg": " x = nn.functional.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_16s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n return x" }, { "id": 6289, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_32s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n return x", "probing input": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_32s(x)\n \n", "probing input new": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_32s(x)\n \n x = nn.functional.", "reference": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear')", "y_neg": " x = nn.functional.upsample(x, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, x):\n \n input_spatial_dim = x.size()[2:]\n \n x = self.resnet18_32s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear')\n \n return x" }, { "id": 6292, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet34_8s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear', align_corners=False)\n \n return x", "probing input": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet34_8s(x)\n \n", "probing input new": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet34_8s(x)\n \n x = nn.functional.", "reference": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear',align_corners=False)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "nn.functional.interpolate", "y_pos": "x=nn.functional.interpolate(input=x,size=input_spatial_dim,mode='bilinear',align_corners=False)", "y_neg": " x = nn.functional.upsample(x, size=input_spatial_dim, mode='bilinear', align_corners=False)", "retain": " def forward(self, x, feature_alignment=False):\n \n input_spatial_dim = x.size()[2:]\n \n if feature_alignment:\n \n x = adjust_input_image_size_for_proper_feature_alignment(x, output_stride=8)\n \n x = self.resnet34_8s(x)\n \n x = nn.functional.interpolate(input=x, size=input_spatial_dim, mode='bilinear', align_corners=False)\n \n return x" }, { "id": 6304, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n b, c, w, h = x.shape\n width = w\n num_dim = b*c*w*h\n tmp = x.permute(0, 2, 3, 1)\n\n tmp = tmp.reshape(num_dim//self.channels, self.channels)\n my_tmp = self.fc(tmp)\n tmp = tmp + my_tmp\n\n tmp = tmp.reshape(((num_dim//self.channels), self.num_group, self.num_per_group))\n tmp_T = tmp.permute((0,2,1))\n\n\n # tmp = self.BL(tmp_T, tmp_T)\n # tmp = tmp.reshape((b, self.width, self.width, c))\n # tmp = tmp.permute((0,3,1,2))\n\n\n tmp = torch.tanh(torch.bmm(tmp_T, tmp)/32)\n tmp = tmp.reshape((b, width, width, self.num_per_group*self.num_per_group))\n # tmp = F.upsample_bilinear(tmp, (width, c))\n tmp = F.interpolate(tmp, (width, c))\n tmp = tmp.permute((0,3,1,2))\n\n\n out = x + self.bn(tmp)\n return out", "probing input": " def forward(self, x):\n b, c, w, h = x.shape\n width = w\n num_dim = b*c*w*h\n tmp = x.permute(0, 2, 3, 1)\n\n tmp = tmp.reshape(num_dim//self.channels, self.channels)\n my_tmp = self.fc(tmp)\n tmp = tmp + my_tmp\n\n tmp = tmp.reshape(((num_dim//self.channels), self.num_group, self.num_per_group))\n tmp_T = tmp.permute((0,2,1))\n\n\n # tmp = self.BL(tmp_T, tmp_T)\n # tmp = tmp.reshape((b, self.width, self.width, c))\n # tmp = tmp.permute((0,3,1,2))\n\n\n tmp = torch.tanh(torch.bmm(tmp_T, tmp)/32)\n tmp = tmp.reshape((b, width, width, self.num_per_group*self.num_per_group))\n # tmp = F.upsample_bilinear(tmp, (width, c))\n", "probing input new": " def forward(self, x):\n b, c, w, h = x.shape\n width = w\n num_dim = b*c*w*h\n tmp = x.permute(0, 2, 3, 1)\n\n tmp = tmp.reshape(num_dim//self.channels, self.channels)\n my_tmp = self.fc(tmp)\n tmp = tmp + my_tmp\n\n tmp = tmp.reshape(((num_dim//self.channels), self.num_group, self.num_per_group))\n tmp_T = tmp.permute((0,2,1))\n\n\n # tmp = self.BL(tmp_T, tmp_T)\n # tmp = tmp.reshape((b, self.width, self.width, c))\n # tmp = tmp.permute((0,3,1,2))\n\n\n tmp = torch.tanh(torch.bmm(tmp_T, tmp)/32)\n tmp = tmp.reshape((b, width, width, self.num_per_group*self.num_per_group))\n # tmp = F.upsample_bilinear(tmp, (width, c))\n tmp = F.", "reference": "tmp=F.interpolate(tmp,(width,c))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.functional.upsample_nearest", "torch.nn.functional.upsample_bilinear", "torch.nn.functional.upsample" ], "replacement api": "torch.nn.functional.interpolate", "expected call": "F.interpolate", "y_pos": "tmp=F.interpolate(tmp,(width,c))", "y_neg": " tmp = F.upsample(tmp, scale_factor=2, mode='bilinear', align_corners=False)", "retain": " def forward(self, x):\n b, c, w, h = x.shape\n width = w\n num_dim = b*c*w*h\n tmp = x.permute(0, 2, 3, 1)\n\n tmp = tmp.reshape(num_dim//self.channels, self.channels)\n my_tmp = self.fc(tmp)\n tmp = tmp + my_tmp\n\n tmp = tmp.reshape(((num_dim//self.channels), self.num_group, self.num_per_group))\n tmp_T = tmp.permute((0,2,1))\n\n\n # tmp = self.BL(tmp_T, tmp_T)\n # tmp = tmp.reshape((b, self.width, self.width, c))\n # tmp = tmp.permute((0,3,1,2))\n\n\n tmp = torch.tanh(torch.bmm(tmp_T, tmp)/32)\n tmp = tmp.reshape((b, width, width, self.num_per_group*self.num_per_group))\n # tmp = F.upsample_bilinear(tmp, (width, c))\n tmp = F.interpolate(tmp, (width, c))\n tmp = tmp.permute((0,3,1,2))\n\n\n out = x + self.bn(tmp)\n return out" }, { "id": 6337, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size,\n dilation=1,\n causal=False,\n mode=\"SAME\",\n ):\n super(Conv, self).__init__()\n\n self.causal = causal\n self.mode = mode\n if self.causal and self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1)\n elif self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1) // 2\n else:\n self.padding = 0\n self.conv = nn.Conv1d(\n in_channels,\n out_channels,\n kernel_size,\n dilation=dilation,\n padding=self.padding,\n )\n self.conv = nn.utils.parametrizations.weight_norm(self.conv)\n nn.init.kaiming_normal_(self.conv.weight)", "probing input": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size,\n dilation=1,\n causal=False,\n mode=\"SAME\",\n ):\n super(Conv, self).__init__()\n\n self.causal = causal\n self.mode = mode\n if self.causal and self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1)\n elif self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1) // 2\n else:\n self.padding = 0\n self.conv = nn.Conv1d(\n in_channels,\n out_channels,\n kernel_size,\n dilation=dilation,\n padding=self.padding,\n )\n", "probing input new": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size,\n dilation=1,\n causal=False,\n mode=\"SAME\",\n ):\n super(Conv, self).__init__()\n\n self.causal = causal\n self.mode = mode\n if self.causal and self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1)\n elif self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1) // 2\n else:\n self.padding = 0\n self.conv = nn.Conv1d(\n in_channels,\n out_channels,\n kernel_size,\n dilation=dilation,\n padding=self.padding,\n )\n self.conv = nn.utils.", "reference": "self.conv=nn.utils.parametrizations.weight_norm(self.conv)", "reference dict": { "self.conv": "nn.Conv1d" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "self.conv=nn.utils.parametrizations.weight_norm(self.conv)", "y_neg": " self.conv = nn.utils.weight_norm(self.conv)", "retain": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size,\n dilation=1,\n causal=False,\n mode=\"SAME\",\n ):\n super(Conv, self).__init__()\n\n self.causal = causal\n self.mode = mode\n if self.causal and self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1)\n elif self.mode == \"SAME\":\n self.padding = dilation * (kernel_size - 1) // 2\n else:\n self.padding = 0\n self.conv = nn.Conv1d(\n in_channels,\n out_channels,\n kernel_size,\n dilation=dilation,\n padding=self.padding,\n )\n self.conv = nn.utils.parametrizations.weight_norm(self.conv)\n nn.init.kaiming_normal_(self.conv.weight)" }, { "id": 6343, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n weight_norm=True,\n ):\n super().__init__()\n assert kernel_size % 2 == 1\n assert hidden_channels % 2 == 0\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n\n self.in_layers = torch.nn.ModuleList()\n self.res_skip_layers = torch.nn.ModuleList()\n self.dropout = nn.Dropout(dropout_p)\n\n # init conditioning layer\n if c_in_channels > 0:\n cond_layer = torch.nn.Conv1d(c_in_channels, 2 * hidden_channels * num_layers, 1)\n self.cond_layer = torch.nn.utils.parametrizations.weight_norm(cond_layer, name=\"weight\")\n # intermediate layers\n for i in range(num_layers):\n dilation = dilation_rate**i\n padding = int((kernel_size * dilation - dilation) / 2)\n if i == 0:\n in_layer = torch.nn.Conv1d(\n in_channels, 2 * hidden_channels, kernel_size, dilation=dilation, padding=padding\n )\n else:\n in_layer = torch.nn.Conv1d(\n hidden_channels, 2 * hidden_channels, kernel_size, dilation=dilation, padding=padding\n )\n in_layer = torch.nn.utils.parametrizations.weight_norm(in_layer, name=\"weight\")\n self.in_layers.append(in_layer)\n\n if i < num_layers - 1:\n res_skip_channels = 2 * hidden_channels\n else:\n res_skip_channels = hidden_channels\n\n res_skip_layer = torch.nn.Conv1d(hidden_channels, res_skip_channels, 1)\n res_skip_layer = torch.nn.utils.parametrizations.weight_norm(res_skip_layer, name=\"weight\")\n self.res_skip_layers.append(res_skip_layer)\n # setup weight norm\n if not weight_norm:\n self.remove_weight_norm()", "probing input": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n weight_norm=True,\n ):\n super().__init__()\n assert kernel_size % 2 == 1\n assert hidden_channels % 2 == 0\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n\n self.in_layers = torch.nn.ModuleList()\n self.res_skip_layers = torch.nn.ModuleList()\n self.dropout = nn.Dropout(dropout_p)\n\n # init conditioning layer\n if c_in_channels > 0:\n cond_layer = torch.nn.Conv1d(c_in_channels, 2 * hidden_channels * num_layers, 1)\n", "probing input new": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n weight_norm=True,\n ):\n super().__init__()\n assert kernel_size % 2 == 1\n assert hidden_channels % 2 == 0\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n\n self.in_layers = torch.nn.ModuleList()\n self.res_skip_layers = torch.nn.ModuleList()\n self.dropout = nn.Dropout(dropout_p)\n\n # init conditioning layer\n if c_in_channels > 0:\n cond_layer = torch.nn.Conv1d(c_in_channels, 2 * hidden_channels * num_layers, 1)\n self.cond_layer = torch.nn.utils.", "reference": "self.cond_layer=torch.nn.utils.parametrizations.weight_norm(cond_layer,name=\"weight\")", "reference dict": { "self.in_layers": "torch.nn.ModuleList", "self.res_skip_layers": "torch.nn.ModuleList", "self.dropout": "nn.Dropout", "cond_layer": "torch.nn.Conv1d", "res_skip_layer": "torch.nn.Conv1d", "in_layer": "torch.nn.Conv1d" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "self.cond_layer=torch.nn.utils.parametrizations.weight_norm(cond_layer,name=\"weight\")", "y_neg": " self.cond_layer = torch.nn.utils.weight_norm(cond_layer) if weight_norm else cond_layer", "retain": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n weight_norm=True,\n ):\n super().__init__()\n assert kernel_size % 2 == 1\n assert hidden_channels % 2 == 0\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n\n self.in_layers = torch.nn.ModuleList()\n self.res_skip_layers = torch.nn.ModuleList()\n self.dropout = nn.Dropout(dropout_p)\n\n # init conditioning layer\n if c_in_channels > 0:\n cond_layer = torch.nn.Conv1d(c_in_channels, 2 * hidden_channels * num_layers, 1)\n self.cond_layer = torch.nn.utils.parametrizations.weight_norm(cond_layer, name=\"weight\")\n # intermediate layers\n for i in range(num_layers):\n dilation = dilation_rate**i\n padding = int((kernel_size * dilation - dilation) / 2)\n if i == 0:\n in_layer = torch.nn.Conv1d(\n in_channels, 2 * hidden_channels, kernel_size, dilation=dilation, padding=padding\n )\n else:\n in_layer = torch.nn.Conv1d(\n hidden_channels, 2 * hidden_channels, kernel_size, dilation=dilation, padding=padding\n )\n in_layer = torch.nn.utils.parametrizations.weight_norm(in_layer, name=\"weight\")\n self.in_layers.append(in_layer)\n\n if i < num_layers - 1:\n res_skip_channels = 2 * hidden_channels\n else:\n res_skip_channels = hidden_channels\n\n res_skip_layer = torch.nn.Conv1d(hidden_channels, res_skip_channels, 1)\n res_skip_layer = torch.nn.utils.parametrizations.weight_norm(res_skip_layer, name=\"weight\")\n self.res_skip_layers.append(res_skip_layer)\n # setup weight norm\n if not weight_norm:\n self.remove_weight_norm()" }, { "id": 6344, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size=1,\n stride=1,\n padding=None,\n dilation=1,\n bias=True,\n w_init_gain=\"linear\",\n use_weight_norm=False,\n ):\n super(ConvNorm, self).__init__() # pylint: disable=super-with-arguments\n if padding is None:\n assert kernel_size % 2 == 1\n padding = int(dilation * (kernel_size - 1) / 2)\n self.kernel_size = kernel_size\n self.dilation = dilation\n self.use_weight_norm = use_weight_norm\n conv_fn = nn.Conv1d\n self.conv = conv_fn(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=stride,\n padding=padding,\n dilation=dilation,\n bias=bias,\n )\n nn.init.xavier_uniform_(self.conv.weight, gain=nn.init.calculate_gain(w_init_gain))\n if self.use_weight_norm:\n self.conv = nn.utils.parametrizations.weight_norm(self.conv)", "probing input": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size=1,\n stride=1,\n padding=None,\n dilation=1,\n bias=True,\n w_init_gain=\"linear\",\n use_weight_norm=False,\n ):\n super(ConvNorm, self).__init__() # pylint: disable=super-with-arguments\n if padding is None:\n assert kernel_size % 2 == 1\n padding = int(dilation * (kernel_size - 1) / 2)\n self.kernel_size = kernel_size\n self.dilation = dilation\n self.use_weight_norm = use_weight_norm\n conv_fn = nn.Conv1d\n self.conv = conv_fn(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=stride,\n padding=padding,\n dilation=dilation,\n bias=bias,\n )\n nn.init.xavier_uniform_(self.conv.weight, gain=nn.init.calculate_gain(w_init_gain))\n if self.use_weight_norm:\n", "probing input new": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size=1,\n stride=1,\n padding=None,\n dilation=1,\n bias=True,\n w_init_gain=\"linear\",\n use_weight_norm=False,\n ):\n super(ConvNorm, self).__init__() # pylint: disable=super-with-arguments\n if padding is None:\n assert kernel_size % 2 == 1\n padding = int(dilation * (kernel_size - 1) / 2)\n self.kernel_size = kernel_size\n self.dilation = dilation\n self.use_weight_norm = use_weight_norm\n conv_fn = nn.Conv1d\n self.conv = conv_fn(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=stride,\n padding=padding,\n dilation=dilation,\n bias=bias,\n )\n nn.init.xavier_uniform_(self.conv.weight, gain=nn.init.calculate_gain(w_init_gain))\n if self.use_weight_norm:\n self.conv = nn.utils.", "reference": "self.conv=nn.utils.parametrizations.weight_norm(self.conv)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "self.conv=nn.utils.parametrizations.weight_norm(self.conv)", "y_neg": " self.conv = nn.utils.weight_norm(self.conv)", "retain": " def __init__(\n self,\n in_channels,\n out_channels,\n kernel_size=1,\n stride=1,\n padding=None,\n dilation=1,\n bias=True,\n w_init_gain=\"linear\",\n use_weight_norm=False,\n ):\n super(ConvNorm, self).__init__() # pylint: disable=super-with-arguments\n if padding is None:\n assert kernel_size % 2 == 1\n padding = int(dilation * (kernel_size - 1) / 2)\n self.kernel_size = kernel_size\n self.dilation = dilation\n self.use_weight_norm = use_weight_norm\n conv_fn = nn.Conv1d\n self.conv = conv_fn(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=stride,\n padding=padding,\n dilation=dilation,\n bias=bias,\n )\n nn.init.xavier_uniform_(self.conv.weight, gain=nn.init.calculate_gain(w_init_gain))\n if self.use_weight_norm:\n self.conv = nn.utils.parametrizations.weight_norm(self.conv)" }, { "id": 6345, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_dim,\n out_dim,\n n_layers=2,\n n_channels=256,\n kernel_size=3,\n p_dropout=0.1,\n lstm_type=\"bilstm\",\n use_linear=True,\n ):\n super(ConvLSTMLinear, self).__init__() # pylint: disable=super-with-arguments\n self.out_dim = out_dim\n self.lstm_type = lstm_type\n self.use_linear = use_linear\n self.dropout = nn.Dropout(p=p_dropout)\n\n convolutions = []\n for i in range(n_layers):\n conv_layer = ConvNorm(\n in_dim if i == 0 else n_channels,\n n_channels,\n kernel_size=kernel_size,\n stride=1,\n padding=int((kernel_size - 1) / 2),\n dilation=1,\n w_init_gain=\"relu\",\n )\n conv_layer = nn.utils.parametrizations.weight_norm(conv_layer.conv, name=\"weight\")\n convolutions.append(conv_layer)\n\n self.convolutions = nn.ModuleList(convolutions)\n\n if not self.use_linear:\n n_channels = out_dim\n\n if self.lstm_type != \"\":\n use_bilstm = False\n lstm_channels = n_channels\n if self.lstm_type == \"bilstm\":\n use_bilstm = True\n lstm_channels = int(n_channels // 2)\n\n self.bilstm = nn.LSTM(n_channels, lstm_channels, 1, batch_first=True, bidirectional=use_bilstm)\n lstm_norm_fn_pntr = nn.utils.spectral_norm\n self.bilstm = lstm_norm_fn_pntr(self.bilstm, \"weight_hh_l0\")\n if self.lstm_type == \"bilstm\":\n self.bilstm = lstm_norm_fn_pntr(self.bilstm, \"weight_hh_l0_reverse\")\n\n if self.use_linear:\n self.dense = nn.Linear(n_channels, out_dim)", "probing input": " def __init__(\n self,\n in_dim,\n out_dim,\n n_layers=2,\n n_channels=256,\n kernel_size=3,\n p_dropout=0.1,\n lstm_type=\"bilstm\",\n use_linear=True,\n ):\n super(ConvLSTMLinear, self).__init__() # pylint: disable=super-with-arguments\n self.out_dim = out_dim\n self.lstm_type = lstm_type\n self.use_linear = use_linear\n self.dropout = nn.Dropout(p=p_dropout)\n\n convolutions = []\n for i in range(n_layers):\n conv_layer = ConvNorm(\n in_dim if i == 0 else n_channels,\n n_channels,\n kernel_size=kernel_size,\n stride=1,\n padding=int((kernel_size - 1) / 2),\n dilation=1,\n w_init_gain=\"relu\",\n )\n", "probing input new": " def __init__(\n self,\n in_dim,\n out_dim,\n n_layers=2,\n n_channels=256,\n kernel_size=3,\n p_dropout=0.1,\n lstm_type=\"bilstm\",\n use_linear=True,\n ):\n super(ConvLSTMLinear, self).__init__() # pylint: disable=super-with-arguments\n self.out_dim = out_dim\n self.lstm_type = lstm_type\n self.use_linear = use_linear\n self.dropout = nn.Dropout(p=p_dropout)\n\n convolutions = []\n for i in range(n_layers):\n conv_layer = ConvNorm(\n in_dim if i == 0 else n_channels,\n n_channels,\n kernel_size=kernel_size,\n stride=1,\n padding=int((kernel_size - 1) / 2),\n dilation=1,\n w_init_gain=\"relu\",\n )\n conv_layer = nn.utils.", "reference": "conv_layer=nn.utils.parametrizations.weight_norm(conv_layer.conv,name=\"weight\")", "reference dict": { "self.dropout": "nn.Dropout", "self.convolutions": "nn.ModuleList", "conv_layer": "ConvNorm", "self.bilstm": "nn.LSTM", "self.dense": "nn.Linear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "conv_layer=nn.utils.parametrizations.weight_norm(conv_layer.conv,name=\"weight\")", "y_neg": " conv_layer = nn.utils.weight_norm(conv_layer)", "retain": " def __init__(\n self,\n in_dim,\n out_dim,\n n_layers=2,\n n_channels=256,\n kernel_size=3,\n p_dropout=0.1,\n lstm_type=\"bilstm\",\n use_linear=True,\n ):\n super(ConvLSTMLinear, self).__init__() # pylint: disable=super-with-arguments\n self.out_dim = out_dim\n self.lstm_type = lstm_type\n self.use_linear = use_linear\n self.dropout = nn.Dropout(p=p_dropout)\n\n convolutions = []\n for i in range(n_layers):\n conv_layer = ConvNorm(\n in_dim if i == 0 else n_channels,\n n_channels,\n kernel_size=kernel_size,\n stride=1,\n padding=int((kernel_size - 1) / 2),\n dilation=1,\n w_init_gain=\"relu\",\n )\n conv_layer = nn.utils.parametrizations.weight_norm(conv_layer.conv, name=\"weight\")\n convolutions.append(conv_layer)\n\n self.convolutions = nn.ModuleList(convolutions)\n\n if not self.use_linear:\n n_channels = out_dim\n\n if self.lstm_type != \"\":\n use_bilstm = False\n lstm_channels = n_channels\n if self.lstm_type == \"bilstm\":\n use_bilstm = True\n lstm_channels = int(n_channels // 2)\n\n self.bilstm = nn.LSTM(n_channels, lstm_channels, 1, batch_first=True, bidirectional=use_bilstm)\n lstm_norm_fn_pntr = nn.utils.spectral_norm\n self.bilstm = lstm_norm_fn_pntr(self.bilstm, \"weight_hh_l0\")\n if self.lstm_type == \"bilstm\":\n self.bilstm = lstm_norm_fn_pntr(self.bilstm, \"weight_hh_l0_reverse\")\n\n if self.use_linear:\n self.dense = nn.Linear(n_channels, out_dim)" }, { "id": 6346, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__( # pylint: disable=dangerous-default-value\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.ConvTranspose1d(\n in_channels,\n in_channels,\n 2 * stride,\n stride=stride,\n padding=stride // 2 + stride % 2,\n output_padding=stride % 2,\n )\n ),\n )\n\n self.conv_blocks = nn.ModuleList()\n for dilation in dilations:\n self.conv_blocks.append(\n nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.Conv1d(\n in_channels,\n in_channels,\n conv_kernel_size,\n padding=dilation * (conv_kernel_size - 1) // 2,\n dilation=dilation,\n )\n ),\n nn.LeakyReLU(lReLU_slope),\n )\n )", "probing input": " def __init__( # pylint: disable=dangerous-default-value\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n", "probing input new": " def __init__( # pylint: disable=dangerous-default-value\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.", "reference": "nn.utils.parametrizations.weight_norm(nn.ConvTranspose1d(in_channels,in_channels,2*stride,stride=stride,padding=stride//2+stride%2,output_padding=stride%2,)),", "reference dict": { "self.kernel_predictor": "KernelPredictor", "self.convt_pre": "nn.Sequential", "self.conv_blocks": "nn.ModuleList" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "nn.utils.parametrizations.weight_norm(nn.ConvTranspose1d(in_channels,in_channels,2*stride,stride=stride,padding=stride//2+stride%2,output_padding=stride%2,)),", "y_neg": " nn.utils.weight_norm(", "retain": " def __init__( # pylint: disable=dangerous-default-value\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.ConvTranspose1d(\n in_channels,\n in_channels,\n 2 * stride,\n stride=stride,\n padding=stride // 2 + stride % 2,\n output_padding=stride % 2,\n )\n ),\n )\n\n self.conv_blocks = nn.ModuleList()\n for dilation in dilations:\n self.conv_blocks.append(\n nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.Conv1d(\n in_channels,\n in_channels,\n conv_kernel_size,\n padding=dilation * (conv_kernel_size - 1) // 2,\n dilation=dilation,\n )\n ),\n nn.LeakyReLU(lReLU_slope),\n )\n )" }, { "id": 6347, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n sigmoid_scale=False,\n ):\n super().__init__()\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n self.sigmoid_scale = sigmoid_scale\n # input layer\n start = torch.nn.Conv1d(in_channels // 2, hidden_channels, 1)\n start = torch.nn.utils.parametrizations.weight_norm(start)\n self.start = start\n # output layer\n # Initializing last layer to 0 makes the affine coupling layers\n # do nothing at first. This helps with training stability\n end = torch.nn.Conv1d(hidden_channels, in_channels, 1)\n end.weight.data.zero_()\n end.bias.data.zero_()\n self.end = end\n # coupling layers\n self.wn = WN(hidden_channels, hidden_channels, kernel_size, dilation_rate, num_layers, c_in_channels, dropout_p)", "probing input": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n sigmoid_scale=False,\n ):\n super().__init__()\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n self.sigmoid_scale = sigmoid_scale\n # input layer\n start = torch.nn.Conv1d(in_channels // 2, hidden_channels, 1)\n", "probing input new": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n sigmoid_scale=False,\n ):\n super().__init__()\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n self.sigmoid_scale = sigmoid_scale\n # input layer\n start = torch.nn.Conv1d(in_channels // 2, hidden_channels, 1)\n start = torch.nn.utils.", "reference": "start=torch.nn.utils.parametrizations.weight_norm(start)", "reference dict": { "start": "torch.nn.Conv1d", "end": "torch.nn.Conv1d", "self.wn": "WN" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "start=torch.nn.utils.parametrizations.weight_norm(start)", "y_neg": " start = torch.nn.utils.weight_norm(start)", "retain": " def __init__(\n self,\n in_channels,\n hidden_channels,\n kernel_size,\n dilation_rate,\n num_layers,\n c_in_channels=0,\n dropout_p=0,\n sigmoid_scale=False,\n ):\n super().__init__()\n self.in_channels = in_channels\n self.hidden_channels = hidden_channels\n self.kernel_size = kernel_size\n self.dilation_rate = dilation_rate\n self.num_layers = num_layers\n self.c_in_channels = c_in_channels\n self.dropout_p = dropout_p\n self.sigmoid_scale = sigmoid_scale\n # input layer\n start = torch.nn.Conv1d(in_channels // 2, hidden_channels, 1)\n start = torch.nn.utils.parametrizations.weight_norm(start)\n self.start = start\n # output layer\n # Initializing last layer to 0 makes the affine coupling layers\n # do nothing at first. This helps with training stability\n end = torch.nn.Conv1d(hidden_channels, in_channels, 1)\n end.weight.data.zero_()\n end.bias.data.zero_()\n self.end = end\n # coupling layers\n self.wn = WN(hidden_channels, hidden_channels, kernel_size, dilation_rate, num_layers, c_in_channels, dropout_p)" }, { "id": 6348, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n embed_dim: int,\n kernel_size: int,\n groups: int,\n ):\n super().__init__()\n self.embed_dim = embed_dim\n self.kernel_size = kernel_size\n self.conv = nn.Conv1d(\n in_channels=embed_dim,\n out_channels=embed_dim,\n kernel_size=kernel_size,\n padding=kernel_size // 2,\n groups=groups,\n )\n\n self.conv = nn.utils.parametrizations.weight_norm(self.conv, name=\"weight\", dim=2)\n self.num_remove: int = 1 if kernel_size % 2 == 0 else 0", "probing input": " def __init__(\n self,\n embed_dim: int,\n kernel_size: int,\n groups: int,\n ):\n super().__init__()\n self.embed_dim = embed_dim\n self.kernel_size = kernel_size\n self.conv = nn.Conv1d(\n in_channels=embed_dim,\n out_channels=embed_dim,\n kernel_size=kernel_size,\n padding=kernel_size // 2,\n groups=groups,\n )\n\n", "probing input new": " def __init__(\n self,\n embed_dim: int,\n kernel_size: int,\n groups: int,\n ):\n super().__init__()\n self.embed_dim = embed_dim\n self.kernel_size = kernel_size\n self.conv = nn.Conv1d(\n in_channels=embed_dim,\n out_channels=embed_dim,\n kernel_size=kernel_size,\n padding=kernel_size // 2,\n groups=groups,\n )\n\n self.conv = nn.utils.", "reference": "self.conv=nn.utils.parametrizations.weight_norm(self.conv,name=\"weight\",dim=2)", "reference dict": { "self.conv": "nn.Conv1d" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "self.conv=nn.utils.parametrizations.weight_norm(self.conv,name=\"weight\",dim=2)", "y_neg": " self.conv = nn.utils.weight_norm(self.conv)", "retain": " def __init__(\n self,\n embed_dim: int,\n kernel_size: int,\n groups: int,\n ):\n super().__init__()\n self.embed_dim = embed_dim\n self.kernel_size = kernel_size\n self.conv = nn.Conv1d(\n in_channels=embed_dim,\n out_channels=embed_dim,\n kernel_size=kernel_size,\n padding=kernel_size // 2,\n groups=groups,\n )\n\n self.conv = nn.utils.parametrizations.weight_norm(self.conv, name=\"weight\", dim=2)\n self.num_remove: int = 1 if kernel_size % 2 == 0 else 0" }, { "id": 6349, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def apply_weight_norm(self):\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.parametrizations.weight_norm(m)\n\n self.apply(_apply_weight_norm)", "probing input": " def apply_weight_norm(self):\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n", "probing input new": " def apply_weight_norm(self):\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.", "reference": "torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " torch.nn.utils.weight_norm.weight_norm(m)", "retain": " def apply_weight_norm(self):\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.parametrizations.weight_norm(m)\n\n self.apply(_apply_weight_norm)" }, { "id": 6353, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def apply_weight_norm(self):\n \"\"\"Apply weight normalization module from all of the layers.\"\"\"\n\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.parametrizations.weight_norm(m)\n # print(f\"Weight norm is applied to {m}.\")\n\n self.apply(_apply_weight_norm)", "probing input": " def apply_weight_norm(self):\n \"\"\"Apply weight normalization module from all of the layers.\"\"\"\n\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n", "probing input new": " def apply_weight_norm(self):\n \"\"\"Apply weight normalization module from all of the layers.\"\"\"\n\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.", "reference": "torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " torch.nn.utils.weight_norm.weight_norm(m)", "retain": " def apply_weight_norm(self):\n \"\"\"Apply weight normalization module from all of the layers.\"\"\"\n\n def _apply_weight_norm(m):\n if isinstance(m, (torch.nn.Conv1d, torch.nn.Conv2d)):\n torch.nn.utils.parametrizations.weight_norm(m)\n # print(f\"Weight norm is applied to {m}.\")\n\n self.apply(_apply_weight_norm)" }, { "id": 6354, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.ConvTranspose1d(\n in_channels,\n in_channels,\n 2 * stride,\n stride=stride,\n padding=stride // 2 + stride % 2,\n output_padding=stride % 2,\n )\n ),\n )\n\n self.conv_blocks = nn.ModuleList()\n for dilation in dilations:\n self.conv_blocks.append(\n nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.Conv1d(\n in_channels,\n in_channels,\n conv_kernel_size,\n padding=dilation * (conv_kernel_size - 1) // 2,\n dilation=dilation,\n )\n ),\n nn.LeakyReLU(lReLU_slope),\n )\n )", "probing input": " def __init__(\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n", "probing input new": " def __init__(\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.", "reference": "nn.utils.parametrizations.weight_norm(nn.ConvTranspose1d(in_channels,in_channels,2*stride,stride=stride,padding=stride//2+stride%2,output_padding=stride%2,)),", "reference dict": { "self.kernel_predictor": "KernelPredictor", "self.convt_pre": "nn.Sequential", "self.conv_blocks": "nn.ModuleList" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "nn.utils.parametrizations.weight_norm", "y_pos": "nn.utils.parametrizations.weight_norm(nn.ConvTranspose1d(in_channels,in_channels,2*stride,stride=stride,padding=stride//2+stride%2,output_padding=stride%2,)),", "y_neg": " nn.utils.weight_norm(", "retain": " def __init__(\n self,\n in_channels,\n cond_channels,\n stride,\n dilations=[1, 3, 9, 27],\n lReLU_slope=0.2,\n conv_kernel_size=3,\n cond_hop_length=256,\n kpnet_hidden_channels=64,\n kpnet_conv_size=3,\n kpnet_dropout=0.0,\n ):\n super().__init__()\n\n self.cond_hop_length = cond_hop_length\n self.conv_layers = len(dilations)\n self.conv_kernel_size = conv_kernel_size\n\n self.kernel_predictor = KernelPredictor(\n cond_channels=cond_channels,\n conv_in_channels=in_channels,\n conv_out_channels=2 * in_channels,\n conv_layers=len(dilations),\n conv_kernel_size=conv_kernel_size,\n kpnet_hidden_channels=kpnet_hidden_channels,\n kpnet_conv_size=kpnet_conv_size,\n kpnet_dropout=kpnet_dropout,\n kpnet_nonlinear_activation_params={\"negative_slope\": lReLU_slope},\n )\n\n self.convt_pre = nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.ConvTranspose1d(\n in_channels,\n in_channels,\n 2 * stride,\n stride=stride,\n padding=stride // 2 + stride % 2,\n output_padding=stride % 2,\n )\n ),\n )\n\n self.conv_blocks = nn.ModuleList()\n for dilation in dilations:\n self.conv_blocks.append(\n nn.Sequential(\n nn.LeakyReLU(lReLU_slope),\n nn.utils.parametrizations.weight_norm(\n nn.Conv1d(\n in_channels,\n in_channels,\n conv_kernel_size,\n padding=dilation * (conv_kernel_size - 1) // 2,\n dilation=dilation,\n )\n ),\n nn.LeakyReLU(lReLU_slope),\n )\n )" }, { "id": 6356, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_weight_norm_pickle(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.parametrizations.weight_norm(m)\n with self.assertRaisesRegex(RuntimeError, 'state_dict'):\n pickle.dumps(m)", "probing input": " def test_weight_norm_pickle(self):\n m = nn.Linear(4, 5)\n", "probing input new": " def test_weight_norm_pickle(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.", "reference": "m=torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": { "m": "nn.Linear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "m=torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " m = torch.nn.utils.weight_norm(m)", "retain": " def test_weight_norm_pickle(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.parametrizations.weight_norm(m)\n with self.assertRaisesRegex(RuntimeError, 'state_dict'):\n pickle.dumps(m)" }, { "id": 6357, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_weight_norm_deepcopy(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.parametrizations.weight_norm(m)\n m2 = deepcopy(m)\n input1 = torch.randn(3, 4)\n self.assertEqual(m(input1), m2(input1))", "probing input": " def test_weight_norm_deepcopy(self):\n m = nn.Linear(4, 5)\n", "probing input new": " def test_weight_norm_deepcopy(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.", "reference": "m=torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": { "m": "nn.Linear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "m=torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " m = torch.nn.utils.weight_norm(m)", "retain": " def test_weight_norm_deepcopy(self):\n m = nn.Linear(4, 5)\n m = torch.nn.utils.parametrizations.weight_norm(m)\n m2 = deepcopy(m)\n input1 = torch.randn(3, 4)\n self.assertEqual(m(input1), m2(input1))" }, { "id": 6358, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input1 = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n\n # add weight normalization\n m = torch.nn.utils.parametrizations.weight_norm(m)\n self.assertEqual(m.parametrizations.weight.original1.size(), m.weight.size())\n self.assertEqual(m.parametrizations.weight.original0.size(), (5, 1))\n self.assertEqual(m(input1), expected_output)\n\n # remove weight norm\n torch.nn.utils.parametrize.remove_parametrizations(m, \"weight\")\n self.assertFalse(hasattr(m, \"parametrizations\"))\n self.assertEqual(m(input1), expected_output)\n\n # test with dim=1\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=1)\n self.assertEqual(m.parametrizations.weight.original1.size(), m.weight.size())\n self.assertEqual(m.parametrizations.weight.original0.size(), (1, 4))\n self.assertEqual(m(input1), expected_output)\n\n # test with dim=None\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=None)\n self.assertEqual(m(input1), expected_output)", "probing input": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input1 = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n\n # add weight normalization\n", "probing input new": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input1 = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n\n # add weight normalization\n m = torch.nn.utils.", "reference": "m=torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": { "m": "nn.Linear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "m=torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " m = torch.nn.utils.weight_norm(m)", "retain": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input1 = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n\n # add weight normalization\n m = torch.nn.utils.parametrizations.weight_norm(m)\n self.assertEqual(m.parametrizations.weight.original1.size(), m.weight.size())\n self.assertEqual(m.parametrizations.weight.original0.size(), (5, 1))\n self.assertEqual(m(input1), expected_output)\n\n # remove weight norm\n torch.nn.utils.parametrize.remove_parametrizations(m, \"weight\")\n self.assertFalse(hasattr(m, \"parametrizations\"))\n self.assertEqual(m(input1), expected_output)\n\n # test with dim=1\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=1)\n self.assertEqual(m.parametrizations.weight.original1.size(), m.weight.size())\n self.assertEqual(m.parametrizations.weight.original0.size(), (1, 4))\n self.assertEqual(m(input1), expected_output)\n\n # test with dim=None\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input1)\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=None)\n self.assertEqual(m(input1), expected_output)" }, { "id": 6360, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n\n # add weight normalization\n m = torch.nn.utils.parametrizations.weight_norm(m)\n self.assertEqual(\n m.parametrizations.weight.original1.size(), m.weight.size()\n )\n self.assertEqual(m.parametrizations.weight.original0.size(), (5, 1))\n self.assertEqual(m(input), expected_output)\n\n # remove weight norm\n torch.nn.utils.parametrize.remove_parametrizations(m, \"weight\")\n self.assertFalse(hasattr(m, \"parametrizations\"))\n self.assertEqual(m(input), expected_output)\n\n # test with dim=1\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=1)\n self.assertEqual(\n m.parametrizations.weight.original1.size(), m.weight.size()\n )\n self.assertEqual(m.parametrizations.weight.original0.size(), (1, 4))\n self.assertEqual(m(input), expected_output)\n\n # test with dim=None\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=None)\n self.assertEqual(m(input), expected_output)", "probing input": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n\n # add weight normalization\n", "probing input new": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n\n # add weight normalization\n m = torch.nn.utils.", "reference": "m=torch.nn.utils.parametrizations.weight_norm(m)", "reference dict": { "m": "nn.Linear" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.nn.utils.weight_norm" ], "replacement api": "torch.nn.utils.parametrizations.weight_norm", "expected call": "torch.nn.utils.parametrizations.weight_norm", "y_pos": "m=torch.nn.utils.parametrizations.weight_norm(m)", "y_neg": " m = torch.nn.utils.weight_norm(m)", "retain": " def test_weight_norm_parametrization(self, device):\n for dtype in [torch.float, torch.bfloat16]:\n input = torch.randn(3, 4, dtype=dtype, device=device)\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n\n # add weight normalization\n m = torch.nn.utils.parametrizations.weight_norm(m)\n self.assertEqual(\n m.parametrizations.weight.original1.size(), m.weight.size()\n )\n self.assertEqual(m.parametrizations.weight.original0.size(), (5, 1))\n self.assertEqual(m(input), expected_output)\n\n # remove weight norm\n torch.nn.utils.parametrize.remove_parametrizations(m, \"weight\")\n self.assertFalse(hasattr(m, \"parametrizations\"))\n self.assertEqual(m(input), expected_output)\n\n # test with dim=1\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=1)\n self.assertEqual(\n m.parametrizations.weight.original1.size(), m.weight.size()\n )\n self.assertEqual(m.parametrizations.weight.original0.size(), (1, 4))\n self.assertEqual(m(input), expected_output)\n\n # test with dim=None\n m = nn.Linear(4, 5, dtype=dtype, device=device)\n expected_output = m(input)\n m = torch.nn.utils.parametrizations.weight_norm(m, dim=None)\n self.assertEqual(m(input), expected_output)" }, { "id": 6361, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_ortho(n, m):\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q", "probing input": "def random_ortho(n, m):\n", "probing input new": "def random_ortho(n, m):\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(torch.randn(n,m))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(torch.randn(n,m))", "y_neg": " q, _ = torch.qr(torch.randn(m, n))", "retain": "def random_ortho(n, m):\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q" }, { "id": 6365, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, qr_uniform_q = False, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n\n # proposed by @Parskatt\n # to make sure Q is uniform https://arxiv.org/pdf/math-ph/0609050.pdf\n if qr_uniform_q:\n d = torch.diag(r, 0)\n q *= d.sign()\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, qr_uniform_q = False, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n", "probing input new": "def orthogonal_matrix_chunk(cols, qr_uniform_q = False, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, qr_uniform_q = False, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n\n # proposed by @Parskatt\n # to make sure Q is uniform https://arxiv.org/pdf/math-ph/0609050.pdf\n if qr_uniform_q:\n d = torch.diag(r, 0)\n q *= d.sign()\n return q.t()" }, { "id": 6366, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lstsq(b, A, method='qr', lam=1e-6, eps=1e-3):\n if method == 'qr':\n Q, R = torch.linalg.qr(A.T)\n X = b.T @ torch.linalg.pinv(R) @ Q.T\n\n return [X.T]\n elif method == 'cvxpylayers':\n from cvxpylayers.torch import CvxpyLayer\n assert b.shape[0] == A.shape[0]\n\n m, n = A.shape\n m, k = b.shape\n\n Acp = cp.Parameter((m, n))\n bcp = cp.Parameter((m, k))\n x = cp.Variable((n, k))\n obj = cp.sum_squares(Acp @ x - bcp) + lam * cp.pnorm(x, p=2)**2\n prob = cp.Problem(cp.Minimize(obj))\n prob_th = CvxpyLayer(prob, [Acp, bcp], [x])\n\n return prob_th(A, b, solver_args={'eps': eps})\n else:\n raise ValueError('Wrong value of method parameter, only qr and cvxpylayers are supported')", "probing input": "def lstsq(b, A, method='qr', lam=1e-6, eps=1e-3):\n if method == 'qr':\n", "probing input new": "def lstsq(b, A, method='qr', lam=1e-6, eps=1e-3):\n if method == 'qr':\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(A.T)", "reference dict": { "Acp": "cp.Parameter", "bcp": "cp.Parameter", "x": "cp.Variable", "prob": "cp.Problem", "prob_th": "CvxpyLayer" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(A.T)", "y_neg": " Q, R = torch.qr(A)", "retain": "def lstsq(b, A, method='qr', lam=1e-6, eps=1e-3):\n if method == 'qr':\n Q, R = torch.linalg.qr(A.T)\n X = b.T @ torch.linalg.pinv(R) @ Q.T\n\n return [X.T]\n elif method == 'cvxpylayers':\n from cvxpylayers.torch import CvxpyLayer\n assert b.shape[0] == A.shape[0]\n\n m, n = A.shape\n m, k = b.shape\n\n Acp = cp.Parameter((m, n))\n bcp = cp.Parameter((m, k))\n x = cp.Variable((n, k))\n obj = cp.sum_squares(Acp @ x - bcp) + lam * cp.pnorm(x, p=2)**2\n prob = cp.Problem(cp.Minimize(obj))\n prob_th = CvxpyLayer(prob, [Acp, bcp], [x])\n\n return prob_th(A, b, solver_args={'eps': eps})\n else:\n raise ValueError('Wrong value of method parameter, only qr and cvxpylayers are supported')" }, { "id": 6368, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block)\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n", "probing input new": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block)", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block)\n return q.t()" }, { "id": 6371, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, in_channel):\n super().__init__()\n\n weight = torch.randn(in_channel, in_channel)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(2).unsqueeze(3)\n self.weight = nn.Parameter(weight)", "probing input": " def __init__(self, in_channel):\n super().__init__()\n\n weight = torch.randn(in_channel, in_channel)\n", "probing input new": " def __init__(self, in_channel):\n super().__init__()\n\n weight = torch.randn(in_channel, in_channel)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(weight)", "reference dict": { "self.weight": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(weight)", "y_neg": " q, _ = torch.qr(weight)", "retain": " def __init__(self, in_channel):\n super().__init__()\n\n weight = torch.randn(in_channel, in_channel)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(2).unsqueeze(3)\n self.weight = nn.Parameter(weight)" }, { "id": 6372, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _rand_haar_slow(n_qubits: int) -> Tensor:\n \"\"\"\n Detailed in https://arxiv.org/pdf/math-ph/0609050.pdf.\n\n Textbook implementation, but very expensive. For 12 qubits it takes several seconds.\n For 1 qubit it seems to produce the same distribution as the measure above.\n \"\"\"\n N = 2**n_qubits\n A = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n B = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n Z = A + 1.0j * B\n Q, R = torch.linalg.qr(Z)\n Lambda = torch.diag(torch.diag(R) / torch.diag(R).abs())\n haar_unitary = torch.matmul(Q, Lambda)\n return torch.matmul(haar_unitary, zero_state(n_qubits).squeeze(0)).unsqueeze(0)", "probing input": "def _rand_haar_slow(n_qubits: int) -> Tensor:\n \"\"\"\n Detailed in https://arxiv.org/pdf/math-ph/0609050.pdf.\n\n Textbook implementation, but very expensive. For 12 qubits it takes several seconds.\n For 1 qubit it seems to produce the same distribution as the measure above.\n \"\"\"\n N = 2**n_qubits\n A = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n B = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n Z = A + 1.0j * B\n", "probing input new": "def _rand_haar_slow(n_qubits: int) -> Tensor:\n \"\"\"\n Detailed in https://arxiv.org/pdf/math-ph/0609050.pdf.\n\n Textbook implementation, but very expensive. For 12 qubits it takes several seconds.\n For 1 qubit it seems to produce the same distribution as the measure above.\n \"\"\"\n N = 2**n_qubits\n A = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n B = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n Z = A + 1.0j * B\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(Z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(Z)", "y_neg": " Q, R = torch.qr(Z)", "retain": "def _rand_haar_slow(n_qubits: int) -> Tensor:\n \"\"\"\n Detailed in https://arxiv.org/pdf/math-ph/0609050.pdf.\n\n Textbook implementation, but very expensive. For 12 qubits it takes several seconds.\n For 1 qubit it seems to produce the same distribution as the measure above.\n \"\"\"\n N = 2**n_qubits\n A = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n B = torch.zeros(N, N, dtype=DTYPE).normal_(0, 1)\n Z = A + 1.0j * B\n Q, R = torch.linalg.qr(Z)\n Lambda = torch.diag(torch.diag(R) / torch.diag(R).abs())\n haar_unitary = torch.matmul(Q, Lambda)\n return torch.matmul(haar_unitary, zero_state(n_qubits).squeeze(0)).unsqueeze(0)" }, { "id": 6374, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n size,\n dtype,\n ):\n super().__init__()\n self.size = size\n\n matrix = torch.randn((size, size), dtype=dtype)\n q, _ = torch.linalg.qr(matrix)\n self.weight = nn.Parameter(q)", "probing input": " def __init__(\n self,\n size,\n dtype,\n ):\n super().__init__()\n self.size = size\n\n matrix = torch.randn((size, size), dtype=dtype)\n", "probing input new": " def __init__(\n self,\n size,\n dtype,\n ):\n super().__init__()\n self.size = size\n\n matrix = torch.randn((size, size), dtype=dtype)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(matrix)", "reference dict": { "self.weight": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(matrix)", "y_neg": " q, _ = torch.qr(matrix)", "retain": " def __init__(\n self,\n size,\n dtype,\n ):\n super().__init__()\n self.size = size\n\n matrix = torch.randn((size, size), dtype=dtype)\n q, _ = torch.linalg.qr(matrix)\n self.weight = nn.Parameter(q)" }, { "id": 6375, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, c):\n super(Invertible1x1ConvLUS, self).__init__()\n # Sample a random orthonormal matrix to initialize weights\n W, _ = torch.linalg.qr(torch.randn(c, c))\n # Ensure determinant is 1.0 not -1.0\n if torch.det(W) < 0:\n W[:, 0] = -1*W[:, 0]\n p, lower, upper = torch.lu_unpack(*torch.lu(W))\n\n self.register_buffer('p', p)\n # diagonals of lower will always be 1s anyway\n lower = torch.tril(lower, -1)\n lower_diag = torch.diag(torch.eye(c, c))\n self.register_buffer('lower_diag', lower_diag)\n self.lower = nn.Parameter(lower)\n self.upper_diag = nn.Parameter(torch.diag(upper))\n self.upper = nn.Parameter(torch.triu(upper, 1))", "probing input": " def __init__(self, c):\n super(Invertible1x1ConvLUS, self).__init__()\n # Sample a random orthonormal matrix to initialize weights\n", "probing input new": " def __init__(self, c):\n super(Invertible1x1ConvLUS, self).__init__()\n # Sample a random orthonormal matrix to initialize weights\n W, _ = torch.", "reference": "W,_=torch.linalg.qr(torch.randn(c,c))", "reference dict": { "self.lower": "nn.Parameter", "self.upper_diag": "nn.Parameter", "self.upper": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "W,_=torch.linalg.qr(torch.randn(c,c))", "y_neg": " W, _ = torch.qr(torch.randn(c, c))", "retain": " def __init__(self, c):\n super(Invertible1x1ConvLUS, self).__init__()\n # Sample a random orthonormal matrix to initialize weights\n W, _ = torch.linalg.qr(torch.randn(c, c))\n # Ensure determinant is 1.0 not -1.0\n if torch.det(W) < 0:\n W[:, 0] = -1*W[:, 0]\n p, lower, upper = torch.lu_unpack(*torch.lu(W))\n\n self.register_buffer('p', p)\n # diagonals of lower will always be 1s anyway\n lower = torch.tril(lower, -1)\n lower_diag = torch.diag(torch.eye(c, c))\n self.register_buffer('lower_diag', lower_diag)\n self.lower = nn.Parameter(lower)\n self.upper_diag = nn.Parameter(torch.diag(upper))\n self.upper = nn.Parameter(torch.triu(upper, 1))" }, { "id": 6383, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some=True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n if TORCH_GE_1_8_0:\n", "probing input new": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n if TORCH_GE_1_8_0:\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some=True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6384, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n", "probing input new": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6390, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n\n with torch.no_grad():\n tensor.view_as(q).copy_(q)\n tensor.mul_(gain)\n return tensor", "probing input": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n", "probing input new": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n\n with torch.no_grad():\n tensor.view_as(q).copy_(q)\n tensor.mul_(gain)\n return tensor" }, { "id": 6391, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def hutchpp(A: lo.LinearOperator, m: int=102, *, _gen_data_on_device=None):\n n, ell = A.shape\n assert n == ell\n assert m % 3 == 0\n if n <= m:\n return exact_trace(A)\n k = m // 3\n S = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n G = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n\n BS = lo.operator_matrix_product(A, S)\n Q, _ = torch.linalg.qr(BS)\n G_prime = G - Q @ (Q.T @ G)\n exact = 0\n for i in range(Q.shape[1]):\n z = Q[:,i]\n exact = exact + (z * (A @ z)).sum()\n \n hutchinson = torch.empty(k, device=A.device)\n for i in range(k):\n z = G_prime[:,i]\n hutchinson[i] = (z * (A @ z)).sum()\n\n return exact + torch.mean(hutchinson), torch.std(hutchinson) / math.sqrt(m)", "probing input": "def hutchpp(A: lo.LinearOperator, m: int=102, *, _gen_data_on_device=None):\n n, ell = A.shape\n assert n == ell\n assert m % 3 == 0\n if n <= m:\n return exact_trace(A)\n k = m // 3\n S = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n G = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n\n BS = lo.operator_matrix_product(A, S)\n", "probing input new": "def hutchpp(A: lo.LinearOperator, m: int=102, *, _gen_data_on_device=None):\n n, ell = A.shape\n assert n == ell\n assert m % 3 == 0\n if n <= m:\n return exact_trace(A)\n k = m // 3\n S = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n G = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n\n BS = lo.operator_matrix_product(A, S)\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(BS)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(BS)", "y_neg": " Q, _ = torch.qr(BS)", "retain": "def hutchpp(A: lo.LinearOperator, m: int=102, *, _gen_data_on_device=None):\n n, ell = A.shape\n assert n == ell\n assert m % 3 == 0\n if n <= m:\n return exact_trace(A)\n k = m // 3\n S = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n G = _sample_dist('rademacher', (n, k), _gen_data_on_device, A.device)\n\n BS = lo.operator_matrix_product(A, S)\n Q, _ = torch.linalg.qr(BS)\n G_prime = G - Q @ (Q.T @ G)\n exact = 0\n for i in range(Q.shape[1]):\n z = Q[:,i]\n exact = exact + (z * (A @ z)).sum()\n \n hutchinson = torch.empty(k, device=A.device)\n for i in range(k):\n z = G_prime[:,i]\n hutchinson[i] = (z * (A @ z)).sum()\n\n return exact + torch.mean(hutchinson), torch.std(hutchinson) / math.sqrt(m)" }, { "id": 6394, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some = True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n", "probing input new": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some = True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6399, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_orth_rep(self, rep):\n \"\"\"\n Use QR decomposition to orthogonalise the representation but retain the subspace spanned by the columns. \n\n Args:\n rep (torch.tensor): (group.order, dim^2) tensor of representation\n\n Returns:\n torch.tensor: (group.order, dim^2) tensor with orthonormal columns en\n \"\"\"\n \n orth_rep = rep.reshape(self.order, self.dim * self.dim)\n\n # TODO: this is a hack to not double count in the cyclic group\n if self.group_acronym == 'C' and self.dim == 2:\n orth_rep = orth_rep[:, :2] \n orth_rep = torch.linalg.qr(orth_rep)[0]\n \n return orth_rep", "probing input": " def compute_orth_rep(self, rep):\n \"\"\"\n Use QR decomposition to orthogonalise the representation but retain the subspace spanned by the columns. \n\n Args:\n rep (torch.tensor): (group.order, dim^2) tensor of representation\n\n Returns:\n torch.tensor: (group.order, dim^2) tensor with orthonormal columns en\n \"\"\"\n \n orth_rep = rep.reshape(self.order, self.dim * self.dim)\n\n # TODO: this is a hack to not double count in the cyclic group\n if self.group_acronym == 'C' and self.dim == 2:\n orth_rep = orth_rep[:, :2] \n", "probing input new": " def compute_orth_rep(self, rep):\n \"\"\"\n Use QR decomposition to orthogonalise the representation but retain the subspace spanned by the columns. \n\n Args:\n rep (torch.tensor): (group.order, dim^2) tensor of representation\n\n Returns:\n torch.tensor: (group.order, dim^2) tensor with orthonormal columns en\n \"\"\"\n \n orth_rep = rep.reshape(self.order, self.dim * self.dim)\n\n # TODO: this is a hack to not double count in the cyclic group\n if self.group_acronym == 'C' and self.dim == 2:\n orth_rep = orth_rep[:, :2] \n orth_rep = torch.", "reference": "orth_rep=torch.linalg.qr(orth_rep)[0]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "orth_rep=torch.linalg.qr(orth_rep)[0]", "y_neg": " orth_rep = torch.qr(orth_rep).q", "retain": " def compute_orth_rep(self, rep):\n \"\"\"\n Use QR decomposition to orthogonalise the representation but retain the subspace spanned by the columns. \n\n Args:\n rep (torch.tensor): (group.order, dim^2) tensor of representation\n\n Returns:\n torch.tensor: (group.order, dim^2) tensor with orthonormal columns en\n \"\"\"\n \n orth_rep = rep.reshape(self.order, self.dim * self.dim)\n\n # TODO: this is a hack to not double count in the cyclic group\n if self.group_acronym == 'C' and self.dim == 2:\n orth_rep = orth_rep[:, :2] \n orth_rep = torch.linalg.qr(orth_rep)[0]\n \n return orth_rep" }, { "id": 6403, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_orthogonal(tensor):\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n \n return q", "probing input": "def make_orthogonal(tensor):\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n", "probing input new": "def make_orthogonal(tensor):\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def make_orthogonal(tensor):\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n \n return q" }, { "id": 6404, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_orthogonal_matrix(rows: int, cols: int) -> torch.Tensor:\n \"\"\"Returns a random orthogonal matrix of shape (rows, cols).\"\"\"\n q, _ = torch.linalg.qr(torch.randn(rows, cols))\n return q", "probing input": "def random_orthogonal_matrix(rows: int, cols: int) -> torch.Tensor:\n \"\"\"Returns a random orthogonal matrix of shape (rows, cols).\"\"\"\n", "probing input new": "def random_orthogonal_matrix(rows: int, cols: int) -> torch.Tensor:\n \"\"\"Returns a random orthogonal matrix of shape (rows, cols).\"\"\"\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(torch.randn(rows,cols))", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(torch.randn(rows,cols))", "y_neg": " q, _ = torch.qr(torch.randn(cols, rows))", "retain": "def random_orthogonal_matrix(rows: int, cols: int) -> torch.Tensor:\n \"\"\"Returns a random orthogonal matrix of shape (rows, cols).\"\"\"\n q, _ = torch.linalg.qr(torch.randn(rows, cols))\n return q" }, { "id": 6405, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_orthogonal_random_matrix(nrows, ncols, scaling=0, device=None, dtype=None):\n factory_kwargs = {'device': device, 'dtype': dtype}\n nblocks = int(math.ceil(nrows / ncols))\n # TD [2021-10-28]: Sometimes QR fails on CUDA\n unstructured_blocks = torch.randn((nblocks, ncols, ncols), device='cpu')\n q, r = torch.linalg.qr(unstructured_blocks)\n # To make sure Q is uniform from the Haar distribution https://arxiv.org/pdf/math-ph/0609050.pdf\n q *= rearrange(torch.diagonal(r, dim1=-2, dim2=-1).sign(), 'b c -> b 1 c')\n q = q.to(**factory_kwargs)\n # TD [2021-10-28] Idk why the transpose is necessary. I suspect it isn't.\n # https://github.com/google-research/google-research/blob/ea313c6e96acce6c863de41615c6cf4079b8ca94/performer/fast_attention/jax/fast_attention.py#L362\n q = rearrange(q, 'b c c1 -> b c1 c')\n g_ortho = rearrange(q, 'b c1 c -> (b c1) c')[:nrows]\n\n if scaling == 0:\n multiplier = torch.randn((nrows, ncols), **factory_kwargs).norm(dim=1)\n return rearrange(multiplier, 'r -> r 1') * g_ortho\n elif scaling == 1:\n return math.sqrt(ncols) * g_ortho\n else:\n raise ValueError(f'Invalid scaling {scaling}')", "probing input": "def gaussian_orthogonal_random_matrix(nrows, ncols, scaling=0, device=None, dtype=None):\n factory_kwargs = {'device': device, 'dtype': dtype}\n nblocks = int(math.ceil(nrows / ncols))\n # TD [2021-10-28]: Sometimes QR fails on CUDA\n unstructured_blocks = torch.randn((nblocks, ncols, ncols), device='cpu')\n", "probing input new": "def gaussian_orthogonal_random_matrix(nrows, ncols, scaling=0, device=None, dtype=None):\n factory_kwargs = {'device': device, 'dtype': dtype}\n nblocks = int(math.ceil(nrows / ncols))\n # TD [2021-10-28]: Sometimes QR fails on CUDA\n unstructured_blocks = torch.randn((nblocks, ncols, ncols), device='cpu')\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_blocks)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_blocks)", "y_neg": " q, r = torch.qr(unstructured_blocks, pivoting=True, eps=1e-10,", "retain": "def gaussian_orthogonal_random_matrix(nrows, ncols, scaling=0, device=None, dtype=None):\n factory_kwargs = {'device': device, 'dtype': dtype}\n nblocks = int(math.ceil(nrows / ncols))\n # TD [2021-10-28]: Sometimes QR fails on CUDA\n unstructured_blocks = torch.randn((nblocks, ncols, ncols), device='cpu')\n q, r = torch.linalg.qr(unstructured_blocks)\n # To make sure Q is uniform from the Haar distribution https://arxiv.org/pdf/math-ph/0609050.pdf\n q *= rearrange(torch.diagonal(r, dim1=-2, dim2=-1).sign(), 'b c -> b 1 c')\n q = q.to(**factory_kwargs)\n # TD [2021-10-28] Idk why the transpose is necessary. I suspect it isn't.\n # https://github.com/google-research/google-research/blob/ea313c6e96acce6c863de41615c6cf4079b8ca94/performer/fast_attention/jax/fast_attention.py#L362\n q = rearrange(q, 'b c c1 -> b c1 c')\n g_ortho = rearrange(q, 'b c1 c -> (b c1) c')[:nrows]\n\n if scaling == 0:\n multiplier = torch.randn((nrows, ncols), **factory_kwargs).norm(dim=1)\n return rearrange(multiplier, 'r -> r 1') * g_ortho\n elif scaling == 1:\n return math.sqrt(ncols) * g_ortho\n else:\n raise ValueError(f'Invalid scaling {scaling}')" }, { "id": 6408, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = th.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = th.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = th.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = th.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if th.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT", "probing input": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n", "probing input new": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.", "reference": "vT,_=th.linalg.qr(vT)", "reference dict": {}, "alias dict": { "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "th.linalg.qr", "y_pos": "vT,_=th.linalg.qr(vT)", "y_neg": " vT, _ = th.qr(vT)", "retain": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = th.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = th.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = th.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = th.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if th.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT" }, { "id": 6412, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def so_uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n\n # Make uniform (diag r >= 0)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n\n # Make them have positive determinant by multiplying the\n # first column by -1 (does not change the measure)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor", "probing input": "def so_uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n", "probing input new": "def so_uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(x)", "y_neg": " q, r = torch.qr(x)", "retain": "def so_uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n\n # Make uniform (diag r >= 0)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n\n # Make them have positive determinant by multiplying the\n # first column by -1 (does not change the measure)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor" }, { "id": 6413, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_orthogonal_matrix(size, device):\n \"\"\"\n Generate a random orthogonal matrix of the specified size.\n First, we generate a random matrix with entries from a standard distribution.\n Then, we use QR decomposition to obtain an orthogonal matrix.\n Finally, we multiply by a diagonal matrix with diag r to adjust the signs.\n \n Args:\n size (int): The size of the matrix (size x size).\n \n Returns:\n torch.Tensor: An orthogonal matrix of the specified size.\n \"\"\"\n torch.cuda.empty_cache()\n random_matrix = torch.randn(size, size, dtype=torch.float64).to(device)\n q, r = torch.linalg.qr(random_matrix)\n q *= torch.sign(torch.diag(r)).unsqueeze(0)\n return q", "probing input": "def random_orthogonal_matrix(size, device):\n \"\"\"\n Generate a random orthogonal matrix of the specified size.\n First, we generate a random matrix with entries from a standard distribution.\n Then, we use QR decomposition to obtain an orthogonal matrix.\n Finally, we multiply by a diagonal matrix with diag r to adjust the signs.\n \n Args:\n size (int): The size of the matrix (size x size).\n \n Returns:\n torch.Tensor: An orthogonal matrix of the specified size.\n \"\"\"\n torch.cuda.empty_cache()\n random_matrix = torch.randn(size, size, dtype=torch.float64).to(device)\n", "probing input new": "def random_orthogonal_matrix(size, device):\n \"\"\"\n Generate a random orthogonal matrix of the specified size.\n First, we generate a random matrix with entries from a standard distribution.\n Then, we use QR decomposition to obtain an orthogonal matrix.\n Finally, we multiply by a diagonal matrix with diag r to adjust the signs.\n \n Args:\n size (int): The size of the matrix (size x size).\n \n Returns:\n torch.Tensor: An orthogonal matrix of the specified size.\n \"\"\"\n torch.cuda.empty_cache()\n random_matrix = torch.randn(size, size, dtype=torch.float64).to(device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(random_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(random_matrix)", "y_neg": " q, r = torch.qr(random_matrix)", "retain": "def random_orthogonal_matrix(size, device):\n \"\"\"\n Generate a random orthogonal matrix of the specified size.\n First, we generate a random matrix with entries from a standard distribution.\n Then, we use QR decomposition to obtain an orthogonal matrix.\n Finally, we multiply by a diagonal matrix with diag r to adjust the signs.\n \n Args:\n size (int): The size of the matrix (size x size).\n \n Returns:\n torch.Tensor: An orthogonal matrix of the specified size.\n \"\"\"\n torch.cuda.empty_cache()\n random_matrix = torch.randn(size, size, dtype=torch.float64).to(device)\n q, r = torch.linalg.qr(random_matrix)\n q *= torch.sign(torch.diag(r)).unsqueeze(0)\n return q" }, { "id": 6416, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def retraction(A, ref):\n data = A + ref\n # Q, R = data.qr()\n Q,R = torch.linalg.qr(data)\n # To avoid (any possible) negative values in the output matrix, we multiply the negative values by -1\n sign = (R.diag().sign() + 0.5).sign().diag()\n out = Q.mm(sign)\n return out", "probing input": "def retraction(A, ref):\n data = A + ref\n # Q, R = data.qr()\n", "probing input new": "def retraction(A, ref):\n data = A + ref\n # Q, R = data.qr()\n Q,R = torch.", "reference": "Q,R=torch.linalg.qr(data)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(data)", "y_neg": " Q,R = torch.qr(data)", "retain": "def retraction(A, ref):\n data = A + ref\n # Q, R = data.qr()\n Q,R = torch.linalg.qr(data)\n # To avoid (any possible) negative values in the output matrix, we multiply the negative values by -1\n sign = (R.diag().sign() + 0.5).sign().diag()\n out = Q.mm(sign)\n return out" }, { "id": 6417, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _build_data_matricies(self):\n \"\"\"\n The data matrix is build column-wise to represent regression matrix for least\n squares solver. The data matrix is QR decomposed.\n \"\"\"\n\n self._b = self._data[self._order:]\n\n cols = [torch.ones(self._number_of_observations - self._order)]\n for i in range(self._order):\n col = self._data[(self._order - 1) - i: self._number_of_observations - i - 1]\n cols.append(col)\n\n A = torch.column_stack(cols)\n self._Q, self._R = torch.linalg.qr(A)", "probing input": " def _build_data_matricies(self):\n \"\"\"\n The data matrix is build column-wise to represent regression matrix for least\n squares solver. The data matrix is QR decomposed.\n \"\"\"\n\n self._b = self._data[self._order:]\n\n cols = [torch.ones(self._number_of_observations - self._order)]\n for i in range(self._order):\n col = self._data[(self._order - 1) - i: self._number_of_observations - i - 1]\n cols.append(col)\n\n A = torch.column_stack(cols)\n", "probing input new": " def _build_data_matricies(self):\n \"\"\"\n The data matrix is build column-wise to represent regression matrix for least\n squares solver. The data matrix is QR decomposed.\n \"\"\"\n\n self._b = self._data[self._order:]\n\n cols = [torch.ones(self._number_of_observations - self._order)]\n for i in range(self._order):\n col = self._data[(self._order - 1) - i: self._number_of_observations - i - 1]\n cols.append(col)\n\n A = torch.column_stack(cols)\n self._Q, self._R = torch.", "reference": "self._Q,self._R=torch.linalg.qr(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self._Q,self._R=torch.linalg.qr(A)", "y_neg": " self._Q, self._R = torch.qr(A)", "retain": " def _build_data_matricies(self):\n \"\"\"\n The data matrix is build column-wise to represent regression matrix for least\n squares solver. The data matrix is QR decomposed.\n \"\"\"\n\n self._b = self._data[self._order:]\n\n cols = [torch.ones(self._number_of_observations - self._order)]\n for i in range(self._order):\n col = self._data[(self._order - 1) - i: self._number_of_observations - i - 1]\n cols.append(col)\n\n A = torch.column_stack(cols)\n self._Q, self._R = torch.linalg.qr(A)" }, { "id": 6418, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n # if h_shape[1] > 512:\n # chunk_size = 10\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = th.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = th.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = th.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = th.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if th.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT", "probing input": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n # if h_shape[1] > 512:\n # chunk_size = 10\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n", "probing input new": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n # if h_shape[1] > 512:\n # chunk_size = 10\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.", "reference": "vT,_=th.linalg.qr(vT)", "reference dict": {}, "alias dict": { "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "th.linalg.qr", "y_pos": "vT,_=th.linalg.qr(vT)", "y_neg": " vT, _ = th.qr(vT)", "retain": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n print('h_shape : ', h_shape)\n\n # if h_shape[1] > 512:\n # chunk_size = 10\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = th.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = th.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = th.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = th.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = th.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = th.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = th.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = th.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if th.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT" }, { "id": 6420, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal(rows, cols, gain=1):\n r\"\"\"return a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013).\n Args:\n rows: rows\n cols: cols\n gain: optional scaling factor\n Examples:\n >>> orthogonal_(5, 3)\n \"\"\"\n flattened = torch.randn((rows, cols))\n if rows < cols: flattened = flattened.T\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n q *= d.sign()\n\n if rows < cols: q = q.T\n q *= gain\n return q", "probing input": "def orthogonal(rows, cols, gain=1):\n r\"\"\"return a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013).\n Args:\n rows: rows\n cols: cols\n gain: optional scaling factor\n Examples:\n >>> orthogonal_(5, 3)\n \"\"\"\n flattened = torch.randn((rows, cols))\n if rows < cols: flattened = flattened.T\n\n # Compute the qr factorization\n", "probing input new": "def orthogonal(rows, cols, gain=1):\n r\"\"\"return a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013).\n Args:\n rows: rows\n cols: cols\n gain: optional scaling factor\n Examples:\n >>> orthogonal_(5, 3)\n \"\"\"\n flattened = torch.randn((rows, cols))\n if rows < cols: flattened = flattened.T\n\n # Compute the qr factorization\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def orthogonal(rows, cols, gain=1):\n r\"\"\"return a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013).\n Args:\n rows: rows\n cols: cols\n gain: optional scaling factor\n Examples:\n >>> orthogonal_(5, 3)\n \"\"\"\n flattened = torch.randn((rows, cols))\n if rows < cols: flattened = flattened.T\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n q *= d.sign()\n\n if rows < cols: q = q.T\n q *= gain\n return q" }, { "id": 6423, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lr(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.linalg.qr(x2_flat)\n return (torch.linalg.norm(q2.T @ x1_flat)) ** 2 / (torch.linalg.norm(x1_flat)) ** 2", "probing input": "def lr(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n", "probing input new": "def lr(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.", "reference": "q2,r2=torch.linalg.qr(x2_flat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q2,r2=torch.linalg.qr(x2_flat)", "y_neg": " q2, r2 = torch.qr(x2_flat)", "retain": "def lr(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.linalg.qr(x2_flat)\n return (torch.linalg.norm(q2.T @ x1_flat)) ** 2 / (torch.linalg.norm(x1_flat)) ** 2" }, { "id": 6425, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # q, r = torch.qr(unstructured_block.cpu(), some=True)\n q, r = torch.linalg.qr(unstructured_block.cpu(), 'reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # q, r = torch.qr(unstructured_block.cpu(), some=True)\n", "probing input new": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # q, r = torch.qr(unstructured_block.cpu(), some=True)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),'reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),'reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # q, r = torch.qr(unstructured_block.cpu(), some=True)\n q, r = torch.linalg.qr(unstructured_block.cpu(), 'reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6429, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def create_random_ortho_matrix(n, seed=-1):\n dtype = torch.float64\n if seed > 0:\n torch.manual_seed(seed)\n a = torch.randn((n, n), dtype=dtype)\n q, r = torch.linalg.qr(a)\n return q", "probing input": "def create_random_ortho_matrix(n, seed=-1):\n dtype = torch.float64\n if seed > 0:\n torch.manual_seed(seed)\n a = torch.randn((n, n), dtype=dtype)\n", "probing input new": "def create_random_ortho_matrix(n, seed=-1):\n dtype = torch.float64\n if seed > 0:\n torch.manual_seed(seed)\n a = torch.randn((n, n), dtype=dtype)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(a)", "y_neg": " q, r = torch.qr(a, pivoting=True)", "retain": "def create_random_ortho_matrix(n, seed=-1):\n dtype = torch.float64\n if seed > 0:\n torch.manual_seed(seed)\n a = torch.randn((n, n), dtype=dtype)\n q, r = torch.linalg.qr(a)\n return q" }, { "id": 6431, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def randomised_SVD_jacobian(input, model, n_rank):\n\n model.eval()\n forward_maps = []\n for _ in range(n_rank):\n forward_maps.append(central_diff_approx(input, model))\n forward_map = torch.cat(forward_maps).transpose(-2, -1)\n q, _ = torch.linalg.qr(forward_map)\n b_t_ = []\n for l in range(q.size()[-1]):\n q_l = q[:, l].detach()\n out = model(input) @ q_l\n model.zero_grad()\n out.backward()\n b_l = agregate_flatten_weight_grad(model).detach()\n b_t_.append(b_l)\n b_matrix = torch.stack(b_t_, dim=0)\n u, s, vh = torch.svd_lowrank(b_matrix, q=n_rank, niter=2, M=None)\n v = vh.transpose(-2, -1).conj()\n return s, v", "probing input": "def randomised_SVD_jacobian(input, model, n_rank):\n\n model.eval()\n forward_maps = []\n for _ in range(n_rank):\n forward_maps.append(central_diff_approx(input, model))\n forward_map = torch.cat(forward_maps).transpose(-2, -1)\n", "probing input new": "def randomised_SVD_jacobian(input, model, n_rank):\n\n model.eval()\n forward_maps = []\n for _ in range(n_rank):\n forward_maps.append(central_diff_approx(input, model))\n forward_map = torch.cat(forward_maps).transpose(-2, -1)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(forward_map)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(forward_map)", "y_neg": " q, _ = torch.qr(forward_map)", "retain": "def randomised_SVD_jacobian(input, model, n_rank):\n\n model.eval()\n forward_maps = []\n for _ in range(n_rank):\n forward_maps.append(central_diff_approx(input, model))\n forward_map = torch.cat(forward_maps).transpose(-2, -1)\n q, _ = torch.linalg.qr(forward_map)\n b_t_ = []\n for l in range(q.size()[-1]):\n q_l = q[:, l].detach()\n out = model(input) @ q_l\n model.zero_grad()\n out.backward()\n b_l = agregate_flatten_weight_grad(model).detach()\n b_t_.append(b_l)\n b_matrix = torch.stack(b_t_, dim=0)\n u, s, vh = torch.svd_lowrank(b_matrix, q=n_rank, niter=2, M=None)\n v = vh.transpose(-2, -1).conj()\n return s, v" }, { "id": 6433, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_new_K(K1, K2, K3):\n # (m, R) -> (m, min(m, R)) -- q: q.T @ q = I, (min(m, R), R) -- r\n q1, r1 = torch.linalg.qr(K1)\n q3, r3 = torch.linalg.qr(torch.transpose(K3, -1, -2))\n middle_k = full_tt(r1, K2, torch.transpose(r3, -1, -2))\n return q1, middle_k, torch.transpose(q3, -1, -2)", "probing input": "def get_new_K(K1, K2, K3):\n # (m, R) -> (m, min(m, R)) -- q: q.T @ q = I, (min(m, R), R) -- r\n", "probing input new": "def get_new_K(K1, K2, K3):\n # (m, R) -> (m, min(m, R)) -- q: q.T @ q = I, (min(m, R), R) -- r\n q1, r1 = torch.", "reference": "q1,r1=torch.linalg.qr(K1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q1,r1=torch.linalg.qr(K1)", "y_neg": " q1, r1 = torch.qr(K1)", "retain": "def get_new_K(K1, K2, K3):\n # (m, R) -> (m, min(m, R)) -- q: q.T @ q = I, (min(m, R), R) -- r\n q1, r1 = torch.linalg.qr(K1)\n q3, r3 = torch.linalg.qr(torch.transpose(K3, -1, -2))\n middle_k = full_tt(r1, K2, torch.transpose(r3, -1, -2))\n return q1, middle_k, torch.transpose(q3, -1, -2)" }, { "id": 6435, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def inject_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.linalg.qr(V.reshape([num_classes, -1]).T)\n\n P = Q.matmul(Q.T)\n x_proj = P.matmul(x.view([-1, 3072]).T)\n\n x_poison = x - x_proj.T.view([-1, 3, 32, 32])\n\n for t in range(num_classes):\n x_poison[y == t] += epsilon * V[t]\n\n poisonset = torch.utils.data.TensorDataset(x_poison, y)\n poisonloader = torch.utils.data.DataLoader(\n poisonset, batch_size=batch_size, shuffle=shuffle, num_workers=num_workers, pin_memory=True\n )\n\n return poisonloader", "probing input": "def inject_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n", "probing input new": "def inject_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(V.reshape([num_classes,-1]).T)", "reference dict": { "poisonset": "torch.utils.data.TensorDataset", "poisonloader": "torch.utils.data.DataLoader" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(V.reshape([num_classes,-1]).T)", "y_neg": " Q, _ = torch.qr(x)", "retain": "def inject_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.linalg.qr(V.reshape([num_classes, -1]).T)\n\n P = Q.matmul(Q.T)\n x_proj = P.matmul(x.view([-1, 3072]).T)\n\n x_poison = x - x_proj.T.view([-1, 3, 32, 32])\n\n for t in range(num_classes):\n x_poison[y == t] += epsilon * V[t]\n\n poisonset = torch.utils.data.TensorDataset(x_poison, y)\n poisonloader = torch.utils.data.DataLoader(\n poisonset, batch_size=batch_size, shuffle=shuffle, num_workers=num_workers, pin_memory=True\n )\n\n return poisonloader" }, { "id": 6436, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def inject_reverse_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.linalg.qr(V.reshape([num_classes, -1]).T)\n\n P = Q.matmul(Q.T)\n x_proj = P.matmul(x.view([-1, 3072]).T)\n\n x_poison = x - x_proj.T.view([-1, 3, 32, 32])\n\n for t in range(num_classes):\n x_poison[y == t] -= epsilon * V[t]\n\n poisonset = torch.utils.data.TensorDataset(x_poison, y)\n poisonloader = torch.utils.data.DataLoader(\n poisonset, batch_size=batch_size, shuffle=shuffle, num_workers=num_workers, pin_memory=True\n )\n\n return poisonloader", "probing input": "def inject_reverse_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n", "probing input new": "def inject_reverse_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(V.reshape([num_classes,-1]).T)", "reference dict": { "poisonset": "torch.utils.data.TensorDataset", "poisonloader": "torch.utils.data.DataLoader" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(V.reshape([num_classes,-1]).T)", "y_neg": " Q, _ = torch.qr(x)", "retain": "def inject_reverse_perp_feature(\n trainset,\n epsilon,\n V,\n batch_size=128,\n num_workers=2,\n shuffle=True,\n):\n num_classes = V.shape[0]\n\n x = torch.from_numpy(trainset.data.transpose([0, 3, 1, 2])).type(torch.float) / 255.0\n y = torch.tensor(trainset.targets, dtype=torch.long)\n\n Q, _ = torch.linalg.qr(V.reshape([num_classes, -1]).T)\n\n P = Q.matmul(Q.T)\n x_proj = P.matmul(x.view([-1, 3072]).T)\n\n x_poison = x - x_proj.T.view([-1, 3, 32, 32])\n\n for t in range(num_classes):\n x_poison[y == t] -= epsilon * V[t]\n\n poisonset = torch.utils.data.TensorDataset(x_poison, y)\n poisonloader = torch.utils.data.DataLoader(\n poisonset, batch_size=batch_size, shuffle=shuffle, num_workers=num_workers, pin_memory=True\n )\n\n return poisonloader" }, { "id": 6438, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, d: int, x_min: float, x_max: float) -> None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.linalg.qr(M)\n self.register_buffer('Q', Q)", "probing input": " def __init__(self, d: int, x_min: float, x_max: float) -> None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n", "probing input new": " def __init__(self, d: int, x_min: float, x_max: float) -> None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(M)", "reference dict": { "stream": "zero.Stream", "progress": "zero.ProgressTracker" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(M)", "y_neg": " Q, _ = torch.qr(M)", "retain": " def __init__(self, d: int, x_min: float, x_max: float) -> None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.linalg.qr(M)\n self.register_buffer('Q', Q)" }, { "id": 6442, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr(x, mode=\"reduced\"):\n x = convert_to_tensor(x)\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n x = convert_to_tensor(x)\n return torch.linalg.qr(x, mode=mode)", "probing input": "def qr(x, mode=\"reduced\"):\n x = convert_to_tensor(x)\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n x = convert_to_tensor(x)\n", "probing input new": "def qr(x, mode=\"reduced\"):\n x = convert_to_tensor(x)\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n x = convert_to_tensor(x)\n return torch.", "reference": "returntorch.linalg.qr(x,mode=mode)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "returntorch.linalg.qr(x,mode=mode)", "y_neg": " return torch.qr(x)", "retain": "def qr(x, mode=\"reduced\"):\n x = convert_to_tensor(x)\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n x = convert_to_tensor(x)\n return torch.linalg.qr(x, mode=mode)" }, { "id": 6444, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device = None):\n from distutils.version import LooseVersion\n TORCH_GE_1_8_0 = LooseVersion(torch.__version__) >= LooseVersion('1.8.0')\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some = True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device = None):\n from distutils.version import LooseVersion\n TORCH_GE_1_8_0 = LooseVersion(torch.__version__) >= LooseVersion('1.8.0')\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n", "probing input new": "def orthogonal_matrix_chunk(cols, device = None):\n from distutils.version import LooseVersion\n TORCH_GE_1_8_0 = LooseVersion(torch.__version__) >= LooseVersion('1.8.0')\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device = None):\n from distutils.version import LooseVersion\n TORCH_GE_1_8_0 = LooseVersion(torch.__version__) >= LooseVersion('1.8.0')\n unstructured_block = torch.randn((cols, cols), device = device)\n if TORCH_GE_1_8_0:\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'reduced')\n else:\n q, r = torch.qr(unstructured_block.cpu(), some = True)\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6445, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __call__(self, x):\n M = torch.randn(3, 3)\n Q, __ = torch.linalg.qr(M)\n return x @ Q", "probing input": " def __call__(self, x):\n M = torch.randn(3, 3)\n", "probing input new": " def __call__(self, x):\n M = torch.randn(3, 3)\n Q, __ = torch.", "reference": "Q,__=torch.linalg.qr(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,__=torch.linalg.qr(M)", "y_neg": " Q, __ = torch.qr(M)", "retain": " def __call__(self, x):\n M = torch.randn(3, 3)\n Q, __ = torch.linalg.qr(M)\n return x @ Q" }, { "id": 6446, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random orthogonal matrices drawn from O(d) Haar distribution\n Adopted from scipy.stats.ortho_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = torch.randn(bsize, d, d, device=device, dtype=dtype)\n q, r = torch.linalg.qr(z)\n # The last two dimensions are the rows and columns of R matrices.\n # Extract the diagonals. Note that this eliminates a dimension.\n d = r.diagonal(offset=0, dim1=-2, dim2=-1)\n # Add back a dimension for proper broadcasting: we're dividing\n # each row of each R matrix by the diagonal of the R matrix.\n q *= (d/abs(d))[..., None, :] # to broadcast properly\n return q", "probing input": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random orthogonal matrices drawn from O(d) Haar distribution\n Adopted from scipy.stats.ortho_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = torch.randn(bsize, d, d, device=device, dtype=dtype)\n", "probing input new": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random orthogonal matrices drawn from O(d) Haar distribution\n Adopted from scipy.stats.ortho_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = torch.randn(bsize, d, d, device=device, dtype=dtype)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(z)", "y_neg": " q, r = torch.qr(z)", "retain": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random orthogonal matrices drawn from O(d) Haar distribution\n Adopted from scipy.stats.ortho_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = torch.randn(bsize, d, d, device=device, dtype=dtype)\n q, r = torch.linalg.qr(z)\n # The last two dimensions are the rows and columns of R matrices.\n # Extract the diagonals. Note that this eliminates a dimension.\n d = r.diagonal(offset=0, dim1=-2, dim2=-1)\n # Add back a dimension for proper broadcasting: we're dividing\n # each row of each R matrix by the diagonal of the R matrix.\n q *= (d/abs(d))[..., None, :] # to broadcast properly\n return q" }, { "id": 6447, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def generate_ps(self, inp, N, level=None):\n # print(inp.shape) # (218, 178, 3)\n if self.preprocess is not None:\n transp, mean, std = self.preprocess\n inp = inp.transpose(*transp)\n inp = (inp - mean) / std\n # print(inp.shape) # (3, 218, 178)\n\n C, H, W = inp.shape\n h_use, w_use = int(H / self.factor), int(W / self.factor)\n\n ps = []\n for _ in range(N):\n p_signal = torch.zeros_like(inp)\n for c in range(C):\n rv = torch.randn((h_use, w_use))\n rv_ortho, _ = torch.linalg.qr(rv, mode=\"complete\")\n p_signal[c, :h_use, :w_use] = rv_ortho\n p_img = RGB_signal_idct(p_signal.cpu().numpy())\n ps.append(p_img)\n ps = torch.from_numpy(np.stack(ps, axis=0), device=inp.device)\n\n if self.preprocess is not None:\n rev_transp = np.argsort(transp)\n ps = ps * std\n ps = ps.transpose(0, *(rev_transp + 1))\n # print(ps.shape) # (100, 218, 178, 3)\n return ps", "probing input": " def generate_ps(self, inp, N, level=None):\n # print(inp.shape) # (218, 178, 3)\n if self.preprocess is not None:\n transp, mean, std = self.preprocess\n inp = inp.transpose(*transp)\n inp = (inp - mean) / std\n # print(inp.shape) # (3, 218, 178)\n\n C, H, W = inp.shape\n h_use, w_use = int(H / self.factor), int(W / self.factor)\n\n ps = []\n for _ in range(N):\n p_signal = torch.zeros_like(inp)\n for c in range(C):\n rv = torch.randn((h_use, w_use))\n", "probing input new": " def generate_ps(self, inp, N, level=None):\n # print(inp.shape) # (218, 178, 3)\n if self.preprocess is not None:\n transp, mean, std = self.preprocess\n inp = inp.transpose(*transp)\n inp = (inp - mean) / std\n # print(inp.shape) # (3, 218, 178)\n\n C, H, W = inp.shape\n h_use, w_use = int(H / self.factor), int(W / self.factor)\n\n ps = []\n for _ in range(N):\n p_signal = torch.zeros_like(inp)\n for c in range(C):\n rv = torch.randn((h_use, w_use))\n rv_ortho, _ = torch.", "reference": "rv_ortho,_=torch.linalg.qr(rv,mode=\"complete\")", "reference dict": { "p_img": "RGB_signal_idct" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "rv_ortho,_=torch.linalg.qr(rv,mode=\"complete\")", "y_neg": " rv_ortho, _ = torch.qr(rv)", "retain": " def generate_ps(self, inp, N, level=None):\n # print(inp.shape) # (218, 178, 3)\n if self.preprocess is not None:\n transp, mean, std = self.preprocess\n inp = inp.transpose(*transp)\n inp = (inp - mean) / std\n # print(inp.shape) # (3, 218, 178)\n\n C, H, W = inp.shape\n h_use, w_use = int(H / self.factor), int(W / self.factor)\n\n ps = []\n for _ in range(N):\n p_signal = torch.zeros_like(inp)\n for c in range(C):\n rv = torch.randn((h_use, w_use))\n rv_ortho, _ = torch.linalg.qr(rv, mode=\"complete\")\n p_signal[c, :h_use, :w_use] = rv_ortho\n p_img = RGB_signal_idct(p_signal.cpu().numpy())\n ps.append(p_img)\n ps = torch.from_numpy(np.stack(ps, axis=0), device=inp.device)\n\n if self.preprocess is not None:\n rev_transp = np.argsort(transp)\n ps = ps * std\n ps = ps.transpose(0, *(rev_transp + 1))\n # print(ps.shape) # (100, 218, 178, 3)\n return ps" }, { "id": 6450, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device = None, dtype=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t().to(dtype)", "probing input": "def orthogonal_matrix_chunk(cols, device = None, dtype=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n", "probing input new": "def orthogonal_matrix_chunk(cols, device = None, dtype=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device = None, dtype=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='reduced')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t().to(dtype)" }, { "id": 6458, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk_batched(bsz, cols, device=None):\n unstructured_block = torch.randn((bsz, cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block, mode='reduced')\n return q.transpose(2, 1)", "probing input": "def orthogonal_matrix_chunk_batched(bsz, cols, device=None):\n unstructured_block = torch.randn((bsz, cols, cols), device=device)\n", "probing input new": "def orthogonal_matrix_chunk_batched(bsz, cols, device=None):\n unstructured_block = torch.randn((bsz, cols, cols), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block,mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block,mode='reduced')", "y_neg": " q, r = torch.qr(unstructured_block, pivoting=True)", "retain": "def orthogonal_matrix_chunk_batched(bsz, cols, device=None):\n unstructured_block = torch.randn((bsz, cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block, mode='reduced')\n return q.transpose(2, 1)" }, { "id": 6462, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def parallel_orthogonal_(tensor, gain=1):\n if tensor.ndimension() < 3:\n raise ValueError(\"Only tensors with 3 or more dimensions are supported\")\n\n n_parallel = tensor.size(0)\n rows = tensor.size(1)\n cols = tensor.numel() // n_parallel // rows\n flattened = tensor.new(n_parallel, rows, cols).normal_(0, 1)\n\n qs = []\n for flat_tensor in torch.unbind(flattened, dim=0):\n if rows < cols:\n flat_tensor.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flat_tensor)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n qs.append(q)\n\n qs = torch.stack(qs, dim=0)\n\n with torch.no_grad():\n tensor.view_as(qs).copy_(qs)\n tensor.mul_(gain)\n return tensor", "probing input": "def parallel_orthogonal_(tensor, gain=1):\n if tensor.ndimension() < 3:\n raise ValueError(\"Only tensors with 3 or more dimensions are supported\")\n\n n_parallel = tensor.size(0)\n rows = tensor.size(1)\n cols = tensor.numel() // n_parallel // rows\n flattened = tensor.new(n_parallel, rows, cols).normal_(0, 1)\n\n qs = []\n for flat_tensor in torch.unbind(flattened, dim=0):\n if rows < cols:\n flat_tensor.t_()\n\n # Compute the qr factorization\n", "probing input new": "def parallel_orthogonal_(tensor, gain=1):\n if tensor.ndimension() < 3:\n raise ValueError(\"Only tensors with 3 or more dimensions are supported\")\n\n n_parallel = tensor.size(0)\n rows = tensor.size(1)\n cols = tensor.numel() // n_parallel // rows\n flattened = tensor.new(n_parallel, rows, cols).normal_(0, 1)\n\n qs = []\n for flat_tensor in torch.unbind(flattened, dim=0):\n if rows < cols:\n flat_tensor.t_()\n\n # Compute the qr factorization\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flat_tensor)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flat_tensor)", "y_neg": " q, r = torch.qr(flat_tensor)", "retain": "def parallel_orthogonal_(tensor, gain=1):\n if tensor.ndimension() < 3:\n raise ValueError(\"Only tensors with 3 or more dimensions are supported\")\n\n n_parallel = tensor.size(0)\n rows = tensor.size(1)\n cols = tensor.numel() // n_parallel // rows\n flattened = tensor.new(n_parallel, rows, cols).normal_(0, 1)\n\n qs = []\n for flat_tensor in torch.unbind(flattened, dim=0):\n if rows < cols:\n flat_tensor.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flat_tensor)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n qs.append(q)\n\n qs = torch.stack(qs, dim=0)\n\n with torch.no_grad():\n tensor.view_as(qs).copy_(qs)\n tensor.mul_(gain)\n return tensor" }, { "id": 6463, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr(a: ArrayLike, mode=\"reduced\"):\n a = _atleast_float_1(a)\n result = torch.linalg.qr(a, mode=mode)\n if mode == \"r\":\n # match NumPy\n result = result.R\n return result", "probing input": "def qr(a: ArrayLike, mode=\"reduced\"):\n a = _atleast_float_1(a)\n", "probing input new": "def qr(a: ArrayLike, mode=\"reduced\"):\n a = _atleast_float_1(a)\n result = torch.", "reference": "result=torch.linalg.qr(a,mode=mode)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "result=torch.linalg.qr(a,mode=mode)", "y_neg": " result = torch.qr(a)", "retain": "def qr(a: ArrayLike, mode=\"reduced\"):\n a = _atleast_float_1(a)\n result = torch.linalg.qr(a, mode=mode)\n if mode == \"r\":\n # match NumPy\n result = result.R\n return result" }, { "id": 6465, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_orthogonal(size):\n \"\"\"\n Returns a random orthogonal matrix as a 2-dim tensor of shape [size, size].\n \"\"\"\n\n # Use the QR decomposition of a random Gaussian matrix.\n x = torch.randn(size, size)\n q, _ = torch.linalg.qr(x)\n return q", "probing input": "def random_orthogonal(size):\n \"\"\"\n Returns a random orthogonal matrix as a 2-dim tensor of shape [size, size].\n \"\"\"\n\n # Use the QR decomposition of a random Gaussian matrix.\n x = torch.randn(size, size)\n", "probing input new": "def random_orthogonal(size):\n \"\"\"\n Returns a random orthogonal matrix as a 2-dim tensor of shape [size, size].\n \"\"\"\n\n # Use the QR decomposition of a random Gaussian matrix.\n x = torch.randn(size, size)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(x)", "y_neg": " q, _ = torch.qr(x)", "retain": "def random_orthogonal(size):\n \"\"\"\n Returns a random orthogonal matrix as a 2-dim tensor of shape [size, size].\n \"\"\"\n\n # Use the QR decomposition of a random Gaussian matrix.\n x = torch.randn(size, size)\n q, _ = torch.linalg.qr(x)\n return q" }, { "id": 6467, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, device, u_weights=None, v_weights=None, p=2):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n \"\"\"\n d = Xs.shape[1]\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.linalg.qr(Z)\n \n return sliced_cost(Xs, Xt, U, p=p, u_weights=u_weights, v_weights=v_weights)", "probing input": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, device, u_weights=None, v_weights=None, p=2):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n \"\"\"\n d = Xs.shape[1]\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n", "probing input new": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, device, u_weights=None, v_weights=None, p=2):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n \"\"\"\n d = Xs.shape[1]\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.", "reference": "U,_=torch.linalg.qr(Z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "U,_=torch.linalg.qr(Z)", "y_neg": " U, _ = torch.qr(Z)", "retain": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, device, u_weights=None, v_weights=None, p=2):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n \"\"\"\n d = Xs.shape[1]\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.linalg.qr(Z)\n \n return sliced_cost(Xs, Xt, U, p=p, u_weights=u_weights, v_weights=v_weights)" }, { "id": 6468, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sliced_wasserstein_sphere_unif(Xs, num_projections, device):\n \"\"\"\n Compute the SSW2 on the sphere w.r.t. a uniform distribution.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n num_projections: int\n Number of projections\n device: str.\n \"\"\"\n n, d = Xs.shape\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.linalg.qr(Z)\n \n ## Projection on S^1\n ## Projection on plane\n Xps = torch.matmul(torch.transpose(U,1,2)[:,None], Xs[:,:,None]).reshape(num_projections, n, 2)\n ## Projection on sphere\n Xps = F.normalize(Xps, p=2, dim=-1)\n ## Get coords\n Xps = (torch.atan2(-Xps[:,:,1], -Xps[:,:,0])+np.pi)/(2*np.pi)\n \n return torch.mean(w2_unif_circle(Xps))", "probing input": "def sliced_wasserstein_sphere_unif(Xs, num_projections, device):\n \"\"\"\n Compute the SSW2 on the sphere w.r.t. a uniform distribution.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n num_projections: int\n Number of projections\n device: str.\n \"\"\"\n n, d = Xs.shape\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n", "probing input new": "def sliced_wasserstein_sphere_unif(Xs, num_projections, device):\n \"\"\"\n Compute the SSW2 on the sphere w.r.t. a uniform distribution.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n num_projections: int\n Number of projections\n device: str.\n \"\"\"\n n, d = Xs.shape\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.", "reference": "U,_=torch.linalg.qr(Z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "U,_=torch.linalg.qr(Z)", "y_neg": " U, _ = torch.qr(Z)", "retain": "def sliced_wasserstein_sphere_unif(Xs, num_projections, device):\n \"\"\"\n Compute the SSW2 on the sphere w.r.t. a uniform distribution.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n num_projections: int\n Number of projections\n device: str.\n \"\"\"\n n, d = Xs.shape\n \n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=device)\n U, _ = torch.linalg.qr(Z)\n \n ## Projection on S^1\n ## Projection on plane\n Xps = torch.matmul(torch.transpose(U,1,2)[:,None], Xs[:,:,None]).reshape(num_projections, n, 2)\n ## Projection on sphere\n Xps = F.normalize(Xps, p=2, dim=-1)\n ## Get coords\n Xps = (torch.atan2(-Xps[:,:,1], -Xps[:,:,0])+np.pi)/(2*np.pi)\n \n return torch.mean(w2_unif_circle(Xps))" }, { "id": 6472, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def sample_base(cls, batch_size, dim=None):\n z = torch.randn(batch_size, 3, 3, dtype=torch.cfloat)\n q, r = torch.linalg.qr(z)\n d = torch.diagonal(r, dim1=-2, dim2=-1)\n ph = d / d.abs()\n q = q @ torch.diag_embed(ph) @ q\n q = q / torch.det(q).pow(1/3)[..., None, None]\n return q", "probing input": " def sample_base(cls, batch_size, dim=None):\n z = torch.randn(batch_size, 3, 3, dtype=torch.cfloat)\n", "probing input new": " def sample_base(cls, batch_size, dim=None):\n z = torch.randn(batch_size, 3, 3, dtype=torch.cfloat)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(z)", "y_neg": " q, r = torch.qr(z)", "retain": " def sample_base(cls, batch_size, dim=None):\n z = torch.randn(batch_size, 3, 3, dtype=torch.cfloat)\n q, r = torch.linalg.qr(z)\n d = torch.diagonal(r, dim1=-2, dim2=-1)\n ph = d / d.abs()\n q = q @ torch.diag_embed(ph) @ q\n q = q / torch.det(q).pow(1/3)[..., None, None]\n return q" }, { "id": 6473, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _orthogonal_matrix(dim: int) -> Tensor:\n r\"\"\"Get an orthogonal matrix by applying QR decomposition.\"\"\"\n # Random matrix from normal distribution\n mat = torch.randn((dim, dim))\n # QR decomposition to two orthogonal matrices\n q, _ = torch.linalg.qr(mat.cpu(), mode='reduced')\n return q.t()", "probing input": "def _orthogonal_matrix(dim: int) -> Tensor:\n r\"\"\"Get an orthogonal matrix by applying QR decomposition.\"\"\"\n # Random matrix from normal distribution\n mat = torch.randn((dim, dim))\n # QR decomposition to two orthogonal matrices\n", "probing input new": "def _orthogonal_matrix(dim: int) -> Tensor:\n r\"\"\"Get an orthogonal matrix by applying QR decomposition.\"\"\"\n # Random matrix from normal distribution\n mat = torch.randn((dim, dim))\n # QR decomposition to two orthogonal matrices\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(mat.cpu(),mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(mat.cpu(),mode='reduced')", "y_neg": " q, _ = torch.qr(mat)", "retain": "def _orthogonal_matrix(dim: int) -> Tensor:\n r\"\"\"Get an orthogonal matrix by applying QR decomposition.\"\"\"\n # Random matrix from normal distribution\n mat = torch.randn((dim, dim))\n # QR decomposition to two orthogonal matrices\n q, _ = torch.linalg.qr(mat.cpu(), mode='reduced')\n return q.t()" }, { "id": 6476, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n if tensor.numel() == 0:\n # no-op\n return tensor\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n\n with torch.no_grad():\n tensor.view_as(q).copy_(q)\n tensor.mul_(gain)\n return tensor", "probing input": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n if tensor.numel() == 0:\n # no-op\n return tensor\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n", "probing input new": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n if tensor.numel() == 0:\n # no-op\n return tensor\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def orthogonal_(tensor, gain=1):\n r\"\"\"Fills the input `Tensor` with a (semi) orthogonal matrix, as\n described in `Exact solutions to the nonlinear dynamics of learning in deep\n linear neural networks` - Saxe, A. et al. (2013). The input tensor must have\n at least 2 dimensions, and for tensors with more than 2 dimensions the\n trailing dimensions are flattened.\n\n Args:\n tensor: an n-dimensional `torch.Tensor`, where :math:`n \\geq 2`\n gain: optional scaling factor\n\n Examples:\n >>> w = torch.empty(3, 5)\n >>> nn.init.orthogonal_(w)\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n if tensor.numel() == 0:\n # no-op\n return tensor\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n if rows < cols:\n flattened.t_()\n\n # Compute the qr factorization\n q, r = torch.linalg.qr(flattened)\n # Make Q uniform according to https://arxiv.org/pdf/math-ph/0609050.pdf\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n if rows < cols:\n q.t_()\n\n with torch.no_grad():\n tensor.view_as(q).copy_(q)\n tensor.mul_(gain)\n return tensor" }, { "id": 6480, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, D, d, params, names, seed=_DEFAULT_SEED):\n super().__init__(None, (D, d))\n self.info = (D, d, seed)\n self.P = torch.randn(D, d)\n self.P, _ = torch.linalg.qr(self.P, mode=\"reduced\")", "probing input": " def __init__(self, D, d, params, names, seed=_DEFAULT_SEED):\n super().__init__(None, (D, d))\n self.info = (D, d, seed)\n self.P = torch.randn(D, d)\n", "probing input new": " def __init__(self, D, d, params, names, seed=_DEFAULT_SEED):\n super().__init__(None, (D, d))\n self.info = (D, d, seed)\n self.P = torch.randn(D, d)\n self.P, _ = torch.", "reference": "self.P,_=torch.linalg.qr(self.P,mode=\"reduced\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.P,_=torch.linalg.qr(self.P,mode=\"reduced\")", "y_neg": " self.P, _ = torch.qr(self.P)", "retain": " def __init__(self, D, d, params, names, seed=_DEFAULT_SEED):\n super().__init__(None, (D, d))\n self.info = (D, d, seed)\n self.P = torch.randn(D, d)\n self.P, _ = torch.linalg.qr(self.P, mode=\"reduced\")" }, { "id": 6483, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_ortho(n: int, m: int) -> Tensor:\n \"\"\"Generate a random orthogonal matrix.\n\n Args:\n n: Number of rows in the output matrix\n m: Number of columns in the output matrix\n\n Returns:\n A random orthogonal matrix of size (n, m)\n \"\"\"\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q", "probing input": "def random_ortho(n: int, m: int) -> Tensor:\n \"\"\"Generate a random orthogonal matrix.\n\n Args:\n n: Number of rows in the output matrix\n m: Number of columns in the output matrix\n\n Returns:\n A random orthogonal matrix of size (n, m)\n \"\"\"\n", "probing input new": "def random_ortho(n: int, m: int) -> Tensor:\n \"\"\"Generate a random orthogonal matrix.\n\n Args:\n n: Number of rows in the output matrix\n m: Number of columns in the output matrix\n\n Returns:\n A random orthogonal matrix of size (n, m)\n \"\"\"\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(torch.randn(n,m))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(torch.randn(n,m))", "y_neg": " q, _ = torch.qr(torch.randn(m, n))", "retain": "def random_ortho(n: int, m: int) -> Tensor:\n \"\"\"Generate a random orthogonal matrix.\n\n Args:\n n: Number of rows in the output matrix\n m: Number of columns in the output matrix\n\n Returns:\n A random orthogonal matrix of size (n, m)\n \"\"\"\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q" }, { "id": 6484, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, num_channels, use_lu=False):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.linalg.qr(torch.randn(self.num_channels, self.num_channels))\n if use_lu:\n P, L, U = torch.lu_unpack(*Q.lu())\n self.register_buffer(\"P\", P) # remains fixed during optimization\n self.L = nn.Parameter(L) # lower triangular portion\n S = U.diag() # \"crop out\" the diagonal to its own parameter\n self.register_buffer(\"sign_S\", torch.sign(S))\n self.log_S = nn.Parameter(torch.log(torch.abs(S)))\n self.U = nn.Parameter(\n torch.triu(U, diagonal=1)\n ) # \"crop out\" diagonal, stored in S\n self.register_buffer(\"eye\", torch.diag(torch.ones(self.num_channels)))\n else:\n self.W = nn.Parameter(Q)", "probing input": " def __init__(self, num_channels, use_lu=False):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n", "probing input new": " def __init__(self, num_channels, use_lu=False):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(torch.randn(self.num_channels,self.num_channels))", "reference dict": { "self.L": "nn.Parameter", "self.log_S": "nn.Parameter", "self.U": "nn.Parameter", "self.W": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(torch.randn(self.num_channels,self.num_channels))", "y_neg": " Q, _ = torch.qr(torch.randn(num_channels, num_channels))", "retain": " def __init__(self, num_channels, use_lu=False):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.linalg.qr(torch.randn(self.num_channels, self.num_channels))\n if use_lu:\n P, L, U = torch.lu_unpack(*Q.lu())\n self.register_buffer(\"P\", P) # remains fixed during optimization\n self.L = nn.Parameter(L) # lower triangular portion\n S = U.diag() # \"crop out\" the diagonal to its own parameter\n self.register_buffer(\"sign_S\", torch.sign(S))\n self.log_S = nn.Parameter(torch.log(torch.abs(S)))\n self.U = nn.Parameter(\n torch.triu(U, diagonal=1)\n ) # \"crop out\" diagonal, stored in S\n self.register_buffer(\"eye\", torch.diag(torch.ones(self.num_channels)))\n else:\n self.W = nn.Parameter(Q)" }, { "id": 6485, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, num_channels, use_lu=True):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.linalg.qr(torch.randn(self.num_channels, self.num_channels))\n if use_lu:\n P, L, U = torch.lu_unpack(*Q.lu())\n self.register_buffer(\"P\", P) # remains fixed during optimization\n self.L = nn.Parameter(L) # lower triangular portion\n S = U.diag() # \"crop out\" the diagonal to its own parameter\n self.register_buffer(\"sign_S\", torch.sign(S))\n self.log_S = nn.Parameter(torch.log(torch.abs(S)))\n self.U = nn.Parameter(\n torch.triu(U, diagonal=1)\n ) # \"crop out\" diagonal, stored in S\n self.register_buffer(\"eye\", torch.diag(torch.ones(self.num_channels)))\n else:\n self.W = nn.Parameter(Q)", "probing input": " def __init__(self, num_channels, use_lu=True):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n", "probing input new": " def __init__(self, num_channels, use_lu=True):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(torch.randn(self.num_channels,self.num_channels))", "reference dict": { "self.L": "nn.Parameter", "self.log_S": "nn.Parameter", "self.U": "nn.Parameter", "self.W": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(torch.randn(self.num_channels,self.num_channels))", "y_neg": " Q, _ = torch.qr(torch.randn(num_channels, num_channels))", "retain": " def __init__(self, num_channels, use_lu=True):\n \"\"\"Constructor\n\n Args:\n num_channels: Number of channels of the data\n use_lu: Flag whether to parametrize weights through the LU decomposition\n \"\"\"\n super().__init__()\n self.num_channels = num_channels\n self.use_lu = use_lu\n Q, _ = torch.linalg.qr(torch.randn(self.num_channels, self.num_channels))\n if use_lu:\n P, L, U = torch.lu_unpack(*Q.lu())\n self.register_buffer(\"P\", P) # remains fixed during optimization\n self.L = nn.Parameter(L) # lower triangular portion\n S = U.diag() # \"crop out\" the diagonal to its own parameter\n self.register_buffer(\"sign_S\", torch.sign(S))\n self.log_S = nn.Parameter(torch.log(torch.abs(S)))\n self.U = nn.Parameter(\n torch.triu(U, diagonal=1)\n ) # \"crop out\" diagonal, stored in S\n self.register_buffer(\"eye\", torch.diag(torch.ones(self.num_channels)))\n else:\n self.W = nn.Parameter(Q)" }, { "id": 6489, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr(x, mode=\"reduced\"):\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n return torch.linalg.qr(x, mode=mode)", "probing input": "def qr(x, mode=\"reduced\"):\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n", "probing input new": "def qr(x, mode=\"reduced\"):\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n return torch.", "reference": "returntorch.linalg.qr(x,mode=mode)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "returntorch.linalg.qr(x,mode=mode)", "y_neg": " return torch.qr(x)", "retain": "def qr(x, mode=\"reduced\"):\n if mode not in {\"reduced\", \"complete\"}:\n raise ValueError(\n \"`mode` argument value not supported. \"\n \"Expected one of {'reduced', 'complete'}. \"\n f\"Received: mode={mode}\"\n )\n return torch.linalg.qr(x, mode=mode)" }, { "id": 6490, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def uniform_init_(tensor):\n \"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n if tensor.ndim < 2:\n raise ValueError('Only tensors with 2 or more dimensions are supported. Got a tensor of shape {}'.format(tuple(tensor.size())))\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor", "probing input": "def uniform_init_(tensor):\n \"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n if tensor.ndim < 2:\n raise ValueError('Only tensors with 2 or more dimensions are supported. Got a tensor of shape {}'.format(tuple(tensor.size())))\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n", "probing input new": "def uniform_init_(tensor):\n \"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n if tensor.ndim < 2:\n raise ValueError('Only tensors with 2 or more dimensions are supported. Got a tensor of shape {}'.format(tuple(tensor.size())))\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(x)", "reference dict": { "yaml": "MagicMock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(x)", "y_neg": " q, r = torch.qr(x)", "retain": "def uniform_init_(tensor):\n \"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n if tensor.ndim < 2:\n raise ValueError('Only tensors with 2 or more dimensions are supported. Got a tensor of shape {}'.format(tuple(tensor.size())))\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor" }, { "id": 6495, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr_retraction(tan_vec): # tan_vec, p-by-n, p <= n\n [p, n] = tan_vec.size()\n tan_vec.t_()\n q, r = torch.linalg.qr(tan_vec)\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph.expand_as(q)\n q.t_()\n\n return q", "probing input": "def qr_retraction(tan_vec): # tan_vec, p-by-n, p <= n\n [p, n] = tan_vec.size()\n tan_vec.t_()\n", "probing input new": "def qr_retraction(tan_vec): # tan_vec, p-by-n, p <= n\n [p, n] = tan_vec.size()\n tan_vec.t_()\n q, r = torch.", "reference": "q,r=torch.linalg.qr(tan_vec)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(tan_vec)", "y_neg": " q, r = torch.qr(tan_vec)", "retain": "def qr_retraction(tan_vec): # tan_vec, p-by-n, p <= n\n [p, n] = tan_vec.size()\n tan_vec.t_()\n q, r = torch.linalg.qr(tan_vec)\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph.expand_as(q)\n q.t_()\n\n return q" }, { "id": 6496, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random unitary matrices drawn from U(d) Haar distribution\n Adopted from scipy.stats.unitary_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = 1 / math.sqrt(2) * (\n torch.randn(bsize, d, d, device=device, dtype=dtype) +\n 1j * torch.randn(bsize, d, d, device=device, dtype=dtype)\n )\n q, r = torch.linalg.qr(z)\n # The last two dimensions are the rows and columns of R matrices.\n # Extract the diagonals. Note that this eliminates a dimension.\n d = r.diagonal(offset=0, dim1=-2, dim2=-1)\n # Add back a dimension for proper broadcasting: we're dividing\n # each row of each R matrix by the diagonal of the R matrix.\n q *= (d/abs(d))[..., None, :] # to broadcast properly\n return q", "probing input": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random unitary matrices drawn from U(d) Haar distribution\n Adopted from scipy.stats.unitary_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = 1 / math.sqrt(2) * (\n torch.randn(bsize, d, d, device=device, dtype=dtype) +\n 1j * torch.randn(bsize, d, d, device=device, dtype=dtype)\n )\n", "probing input new": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random unitary matrices drawn from U(d) Haar distribution\n Adopted from scipy.stats.unitary_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = 1 / math.sqrt(2) * (\n torch.randn(bsize, d, d, device=device, dtype=dtype) +\n 1j * torch.randn(bsize, d, d, device=device, dtype=dtype)\n )\n q, r = torch.", "reference": "q,r=torch.linalg.qr(z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(z)", "y_neg": " q, r = torch.qr(z)", "retain": "def samples_from_haar_distribution(d, bsize, device, dtype) -> torch.Tensor:\n \"\"\"Random unitary matrices drawn from U(d) Haar distribution\n Adopted from scipy.stats.unitary_group, which implements the algorithm described in\n Mezzadri, How to generate random matrices from the classical compact groups (2006)\n \"\"\"\n z = 1 / math.sqrt(2) * (\n torch.randn(bsize, d, d, device=device, dtype=dtype) +\n 1j * torch.randn(bsize, d, d, device=device, dtype=dtype)\n )\n q, r = torch.linalg.qr(z)\n # The last two dimensions are the rows and columns of R matrices.\n # Extract the diagonals. Note that this eliminates a dimension.\n d = r.diagonal(offset=0, dim1=-2, dim2=-1)\n # Add back a dimension for proper broadcasting: we're dividing\n # each row of each R matrix by the diagonal of the R matrix.\n q *= (d/abs(d))[..., None, :] # to broadcast properly\n return q" }, { "id": 6497, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, _train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base=False, _lr=0.001, _beta1=0.5, _nepoch=20, _batch_size=100, _embed_dim=1000, _num_layers=3, opt=None):\n super().__init__(_train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base, _lr, _beta1, _nepoch, _batch_size, _embed_dim, _num_layers, opt)\n self.opt = opt\n self.seedinfo = seedinfo\n \n self.lr = _lr\n self.beta1 = _beta1\n self.nepoch = _nepoch\n self.batch_size = _batch_size\n self.embed_dim = _embed_dim\n self.num_layers = _num_layers\n self.nclass = _nclass\n self.cuda = _cuda\n\n self.test_seen_feature = data_loader.test_seen_feature\n self.test_seen_label = data_loader.test_seen_label \n self.test_unseen_feature = data_loader.test_unseen_feature\n self.test_unseen_label = data_loader.test_unseen_label\n\n self.seenclasses = data_loader.seenclasses\n self.unseenclasses = data_loader.unseenclasses \n self.attribute = data_loader.attribute\n\n if self.opt.subspace_proj:\n base_weights_mat = torch.cat((self.model.fc.weight.data, self.model.fc.bias.data.unsqueeze(1)), 1)\n tr_base = torch.transpose(base_weights_mat, 0, 1)\n self.Q, self.R = torch.linalg.qr(tr_base, mode='reduced')\n \n if self.opt.cuda:\n self.target_weights = self.target_weights.cuda()\n \n if opt.class_reduction_ablation:\n perm = torch.randperm(len(self.seenclasses))\n assert opt.class_reduction_ablation in range(1, len(self.seenclasses)+1)\n perm = perm[:opt.class_reduction_ablation]\n training_attributes = self.attribute[self.seenclasses][perm]\n training_weights = self.target_weights[perm]\n\n if opt.single_autoencoder_baseline:\n if opt.class_reduction_ablation: \n att2weight_dataset = util.GenericDataset(opt, _input=training_attributes, _target=training_weights, cuda=self.cuda)\n self.loader = DataLoader(att2weight_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n att2weight_dataset = util.GenericDataset(opt, _input=self.attribute[self.seenclasses], _target=self.target_weights, cuda=self.cuda)\n self.loader = DataLoader(att2weight_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n if opt.class_reduction_ablation:\n combined_seen_dataset = util.GenericDataset(opt, _input=training_attributes, _target=training_weights, cuda=self.cuda)\n else:\n combined_seen_dataset = util.GenericDataset(opt, _input=self.attribute[self.seenclasses], _target=self.target_weights, cuda=self.cuda)\n placeholder_weights = torch.zeros(len(self.unseenclasses), self.target_weights.size(1))\n if self.cuda:\n placeholder_weights = placeholder_weights.cuda()\n if opt.class_reduction_ablation:\n combined_full_dataset = util.GenericDataset(opt, _input=torch.cat((training_attributes, self.attribute[self.unseenclasses])), _target=torch.cat((training_weights, placeholder_weights), dim=0), cuda=self.cuda)\n else:\n combined_full_dataset = util.GenericDataset(opt, _input=torch.cat((self.attribute[self.seenclasses], self.attribute[self.unseenclasses])), _target=torch.cat((self.target_weights, placeholder_weights), dim=0), cuda=self.cuda)\n if self.opt.include_unseen:\n self.loader = DataLoader(combined_full_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n self.loader = DataLoader(combined_seen_dataset, batch_size=self.batch_size, shuffle=True)\n\n self.AE_attribute = model.AUTOENCODER(self.opt, input_dim=self.attribute.size(1), embed_dim=self.embed_dim, num_layers=self.num_layers)\n self.AE_weight = model.AUTOENCODER(self.opt, input_dim=self.target_weights.size(1), embed_dim=self.embed_dim, num_layers=self.num_layers)\n \n self.AE_attribute.apply(util.weights_init)\n self.AE_weight.apply(util.weights_init)\n \n if self.opt.single_autoencoder_baseline:\n self.model = model.AUTOENCODER(self.opt, input_dim=self.attribute.size(1), embed_dim=self.embed_dim, output_dim=self.target_weights.size(1), num_layers=self.num_layers)\n else:\n self.model = model.JOINT_AUTOENCODER(self.opt, autoencoder1=self.AE_attribute, autoencoder2=self.AE_weight)\n\n if self.model:\n self.model.apply(util.weights_init)\n \n if opt.cos_sim_loss:\n self.criterion = util.cos_sim_loss(reduction='none')\n else:\n self.criterion = nn.MSELoss(reduction='none')\n self.mse_loss = nn.MSELoss(reduction='none')\n self.l1loss = nn.L1Loss(reduction='none')\n\n if opt.daegnn:\n dae_num_features = 2049 # Number of features from ResNet-101, 512 in original implementation.\n self.dae_meta_batch_size = 4 # Taken from original implementation\n if self.opt.single_autoencoder_baseline:\n self.dae_loader = DataLoader(att2weight_dataset, batch_size=len(self.seenclasses), shuffle=False)\n else:\n self.dae_loader = DataLoader(combined_seen_dataset, batch_size=len(self.seenclasses), shuffle=False)\n self.dae = WeightsDAE({\n 'gaussian_noise': 0.08,\n 'comp_reconstruction_loss': True,\n 'targets_as_input': False,\n 'dae_type': 'RelationNetBasedGNN',\n 'num_layers': 2,\n 'num_features_input': dae_num_features,\n 'num_features_output': 2 * dae_num_features,\n 'num_features_hidden': 3 * dae_num_features,\n 'update_dropout': 0.7,\n\n 'nun_features_msg': 3 * dae_num_features,\n 'aggregation_dropout': 0.7,\n 'topK_neighbors': 10,\n 'temperature': 5.0,\n 'learn_temperature': False,\n })\n self.dae_optimizer = optim.Adam(self.dae.parameters(), lr=_lr, betas=(_beta1, 0.999), weight_decay=0.0)\n \n if self.cuda:\n self.AE_attribute.cuda()\n self.AE_weight.cuda()\n if self.model:\n self.model.cuda()\n self.criterion.cuda()\n self.mse_loss.cuda()\n self.l1loss.cuda()\n if opt.daegnn:\n self.dae.cuda()\n\n self.unseen_model = model.LINEAR(self.test_seen_feature.size(1), len(self.unseenclasses))\n self.ext_model = model.LINEAR(self.test_seen_feature.size(1), len(self.seenclasses) + len(self.unseenclasses))\n self.ext_model.fc.weight.data[:len(self.seenclasses), :] = self.target_weights[:, :-1]\n self.ext_model.fc.bias.data[:len(self.seenclasses)] = self.target_weights[:, -1]\n \n if self.cuda:\n self.ext_model.cuda()\n self.unseen_model.cuda()\n\n self.lr = _lr\n self.beta1 = _beta1\n self.optimizer_attribute_AE = optim.Adam(self.AE_attribute.parameters(), lr=_lr, betas=(_beta1, 0.999))\n self.optimizer_weight_AE = optim.Adam(self.AE_weight.parameters(), lr=_lr, betas=(_beta1, 0.999))\n if self.model:\n self.weight_optimizer = optim.Adam(self.model.parameters(), lr=_lr, betas=(_beta1, 0.999), weight_decay=0.0)\n \n self.index_in_epoch = 0\n self.epochs_completed = 0", "probing input": " def __init__(self, _train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base=False, _lr=0.001, _beta1=0.5, _nepoch=20, _batch_size=100, _embed_dim=1000, _num_layers=3, opt=None):\n super().__init__(_train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base, _lr, _beta1, _nepoch, _batch_size, _embed_dim, _num_layers, opt)\n self.opt = opt\n self.seedinfo = seedinfo\n \n self.lr = _lr\n self.beta1 = _beta1\n self.nepoch = _nepoch\n self.batch_size = _batch_size\n self.embed_dim = _embed_dim\n self.num_layers = _num_layers\n self.nclass = _nclass\n self.cuda = _cuda\n\n self.test_seen_feature = data_loader.test_seen_feature\n self.test_seen_label = data_loader.test_seen_label \n self.test_unseen_feature = data_loader.test_unseen_feature\n self.test_unseen_label = data_loader.test_unseen_label\n\n self.seenclasses = data_loader.seenclasses\n self.unseenclasses = data_loader.unseenclasses \n self.attribute = data_loader.attribute\n\n if self.opt.subspace_proj:\n base_weights_mat = torch.cat((self.model.fc.weight.data, self.model.fc.bias.data.unsqueeze(1)), 1)\n tr_base = torch.transpose(base_weights_mat, 0, 1)\n", "probing input new": " def __init__(self, _train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base=False, _lr=0.001, _beta1=0.5, _nepoch=20, _batch_size=100, _embed_dim=1000, _num_layers=3, opt=None):\n super().__init__(_train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base, _lr, _beta1, _nepoch, _batch_size, _embed_dim, _num_layers, opt)\n self.opt = opt\n self.seedinfo = seedinfo\n \n self.lr = _lr\n self.beta1 = _beta1\n self.nepoch = _nepoch\n self.batch_size = _batch_size\n self.embed_dim = _embed_dim\n self.num_layers = _num_layers\n self.nclass = _nclass\n self.cuda = _cuda\n\n self.test_seen_feature = data_loader.test_seen_feature\n self.test_seen_label = data_loader.test_seen_label \n self.test_unseen_feature = data_loader.test_unseen_feature\n self.test_unseen_label = data_loader.test_unseen_label\n\n self.seenclasses = data_loader.seenclasses\n self.unseenclasses = data_loader.unseenclasses \n self.attribute = data_loader.attribute\n\n if self.opt.subspace_proj:\n base_weights_mat = torch.cat((self.model.fc.weight.data, self.model.fc.bias.data.unsqueeze(1)), 1)\n tr_base = torch.transpose(base_weights_mat, 0, 1)\n self.Q, self.R = torch.", "reference": "self.Q,self.R=torch.linalg.qr(tr_base,mode='reduced')", "reference dict": { "self.AE_attribute": "model.AUTOENCODER", "self.AE_weight": "model.AUTOENCODER", "self.mse_loss": "nn.MSELoss", "self.l1loss": "nn.L1Loss", "self.unseen_model": "model.LINEAR", "self.ext_model": "model.LINEAR", "self.optimizer_attribute_AE": "optim.Adam", "self.optimizer_weight_AE": "optim.Adam", "self.model": "model.JOINT_AUTOENCODER", "self.criterion": "nn.MSELoss", "self.dae": "WeightsDAE", "self.dae_optimizer": "optim.Adam", "self.weight_optimizer": "optim.Adam", "att2weight_dataset": "util.GenericDataset", "self.loader": "DataLoader", "combined_seen_dataset": "util.GenericDataset", "combined_full_dataset": "util.GenericDataset", "self.dae_loader": "DataLoader" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.Q,self.R=torch.linalg.qr(tr_base,mode='reduced')", "y_neg": " self.Q, self.R = torch.qr(tr_base)", "retain": " def __init__(self, _train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base=False, _lr=0.001, _beta1=0.5, _nepoch=20, _batch_size=100, _embed_dim=1000, _num_layers=3, opt=None):\n super().__init__(_train_X, _train_Y, data_loader, _nclass, _cuda, seedinfo, train_base, _lr, _beta1, _nepoch, _batch_size, _embed_dim, _num_layers, opt)\n self.opt = opt\n self.seedinfo = seedinfo\n \n self.lr = _lr\n self.beta1 = _beta1\n self.nepoch = _nepoch\n self.batch_size = _batch_size\n self.embed_dim = _embed_dim\n self.num_layers = _num_layers\n self.nclass = _nclass\n self.cuda = _cuda\n\n self.test_seen_feature = data_loader.test_seen_feature\n self.test_seen_label = data_loader.test_seen_label \n self.test_unseen_feature = data_loader.test_unseen_feature\n self.test_unseen_label = data_loader.test_unseen_label\n\n self.seenclasses = data_loader.seenclasses\n self.unseenclasses = data_loader.unseenclasses \n self.attribute = data_loader.attribute\n\n if self.opt.subspace_proj:\n base_weights_mat = torch.cat((self.model.fc.weight.data, self.model.fc.bias.data.unsqueeze(1)), 1)\n tr_base = torch.transpose(base_weights_mat, 0, 1)\n self.Q, self.R = torch.linalg.qr(tr_base, mode='reduced')\n \n if self.opt.cuda:\n self.target_weights = self.target_weights.cuda()\n \n if opt.class_reduction_ablation:\n perm = torch.randperm(len(self.seenclasses))\n assert opt.class_reduction_ablation in range(1, len(self.seenclasses)+1)\n perm = perm[:opt.class_reduction_ablation]\n training_attributes = self.attribute[self.seenclasses][perm]\n training_weights = self.target_weights[perm]\n\n if opt.single_autoencoder_baseline:\n if opt.class_reduction_ablation: \n att2weight_dataset = util.GenericDataset(opt, _input=training_attributes, _target=training_weights, cuda=self.cuda)\n self.loader = DataLoader(att2weight_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n att2weight_dataset = util.GenericDataset(opt, _input=self.attribute[self.seenclasses], _target=self.target_weights, cuda=self.cuda)\n self.loader = DataLoader(att2weight_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n if opt.class_reduction_ablation:\n combined_seen_dataset = util.GenericDataset(opt, _input=training_attributes, _target=training_weights, cuda=self.cuda)\n else:\n combined_seen_dataset = util.GenericDataset(opt, _input=self.attribute[self.seenclasses], _target=self.target_weights, cuda=self.cuda)\n placeholder_weights = torch.zeros(len(self.unseenclasses), self.target_weights.size(1))\n if self.cuda:\n placeholder_weights = placeholder_weights.cuda()\n if opt.class_reduction_ablation:\n combined_full_dataset = util.GenericDataset(opt, _input=torch.cat((training_attributes, self.attribute[self.unseenclasses])), _target=torch.cat((training_weights, placeholder_weights), dim=0), cuda=self.cuda)\n else:\n combined_full_dataset = util.GenericDataset(opt, _input=torch.cat((self.attribute[self.seenclasses], self.attribute[self.unseenclasses])), _target=torch.cat((self.target_weights, placeholder_weights), dim=0), cuda=self.cuda)\n if self.opt.include_unseen:\n self.loader = DataLoader(combined_full_dataset, batch_size=self.batch_size, shuffle=True)\n else:\n self.loader = DataLoader(combined_seen_dataset, batch_size=self.batch_size, shuffle=True)\n\n self.AE_attribute = model.AUTOENCODER(self.opt, input_dim=self.attribute.size(1), embed_dim=self.embed_dim, num_layers=self.num_layers)\n self.AE_weight = model.AUTOENCODER(self.opt, input_dim=self.target_weights.size(1), embed_dim=self.embed_dim, num_layers=self.num_layers)\n \n self.AE_attribute.apply(util.weights_init)\n self.AE_weight.apply(util.weights_init)\n \n if self.opt.single_autoencoder_baseline:\n self.model = model.AUTOENCODER(self.opt, input_dim=self.attribute.size(1), embed_dim=self.embed_dim, output_dim=self.target_weights.size(1), num_layers=self.num_layers)\n else:\n self.model = model.JOINT_AUTOENCODER(self.opt, autoencoder1=self.AE_attribute, autoencoder2=self.AE_weight)\n\n if self.model:\n self.model.apply(util.weights_init)\n \n if opt.cos_sim_loss:\n self.criterion = util.cos_sim_loss(reduction='none')\n else:\n self.criterion = nn.MSELoss(reduction='none')\n self.mse_loss = nn.MSELoss(reduction='none')\n self.l1loss = nn.L1Loss(reduction='none')\n\n if opt.daegnn:\n dae_num_features = 2049 # Number of features from ResNet-101, 512 in original implementation.\n self.dae_meta_batch_size = 4 # Taken from original implementation\n if self.opt.single_autoencoder_baseline:\n self.dae_loader = DataLoader(att2weight_dataset, batch_size=len(self.seenclasses), shuffle=False)\n else:\n self.dae_loader = DataLoader(combined_seen_dataset, batch_size=len(self.seenclasses), shuffle=False)\n self.dae = WeightsDAE({\n 'gaussian_noise': 0.08,\n 'comp_reconstruction_loss': True,\n 'targets_as_input': False,\n 'dae_type': 'RelationNetBasedGNN',\n 'num_layers': 2,\n 'num_features_input': dae_num_features,\n 'num_features_output': 2 * dae_num_features,\n 'num_features_hidden': 3 * dae_num_features,\n 'update_dropout': 0.7,\n\n 'nun_features_msg': 3 * dae_num_features,\n 'aggregation_dropout': 0.7,\n 'topK_neighbors': 10,\n 'temperature': 5.0,\n 'learn_temperature': False,\n })\n self.dae_optimizer = optim.Adam(self.dae.parameters(), lr=_lr, betas=(_beta1, 0.999), weight_decay=0.0)\n \n if self.cuda:\n self.AE_attribute.cuda()\n self.AE_weight.cuda()\n if self.model:\n self.model.cuda()\n self.criterion.cuda()\n self.mse_loss.cuda()\n self.l1loss.cuda()\n if opt.daegnn:\n self.dae.cuda()\n\n self.unseen_model = model.LINEAR(self.test_seen_feature.size(1), len(self.unseenclasses))\n self.ext_model = model.LINEAR(self.test_seen_feature.size(1), len(self.seenclasses) + len(self.unseenclasses))\n self.ext_model.fc.weight.data[:len(self.seenclasses), :] = self.target_weights[:, :-1]\n self.ext_model.fc.bias.data[:len(self.seenclasses)] = self.target_weights[:, -1]\n \n if self.cuda:\n self.ext_model.cuda()\n self.unseen_model.cuda()\n\n self.lr = _lr\n self.beta1 = _beta1\n self.optimizer_attribute_AE = optim.Adam(self.AE_attribute.parameters(), lr=_lr, betas=(_beta1, 0.999))\n self.optimizer_weight_AE = optim.Adam(self.AE_weight.parameters(), lr=_lr, betas=(_beta1, 0.999))\n if self.model:\n self.weight_optimizer = optim.Adam(self.model.parameters(), lr=_lr, betas=(_beta1, 0.999), weight_decay=0.0)\n \n self.index_in_epoch = 0\n self.epochs_completed = 0" }, { "id": 6498, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def tangent_basis(normal_vec):\n A = torch.eye(normal_vec.shape[0]).to(normal_vec.device, normal_vec.dtype)\n A[:, 0] = normal_vec\n Q, R = torch.linalg.qr(A)\n norms = torch.linalg.norm(normal_vec)\n Q[:, 0] = normal_vec / torch.linalg.norm(normal_vec)\n return Q.nan_to_num()", "probing input": "def tangent_basis(normal_vec):\n A = torch.eye(normal_vec.shape[0]).to(normal_vec.device, normal_vec.dtype)\n A[:, 0] = normal_vec\n", "probing input new": "def tangent_basis(normal_vec):\n A = torch.eye(normal_vec.shape[0]).to(normal_vec.device, normal_vec.dtype)\n A[:, 0] = normal_vec\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(A)", "y_neg": " Q, R = torch.qr(A)", "retain": "def tangent_basis(normal_vec):\n A = torch.eye(normal_vec.shape[0]).to(normal_vec.device, normal_vec.dtype)\n A[:, 0] = normal_vec\n Q, R = torch.linalg.qr(A)\n norms = torch.linalg.norm(normal_vec)\n Q[:, 0] = normal_vec / torch.linalg.norm(normal_vec)\n return Q.nan_to_num()" }, { "id": 6499, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_rotation_matrix(batch_size: int, ndim=3, generator=None) -> torch.Tensor:\n z = torch.randn((batch_size, ndim, ndim), generator=generator)\n q, r = torch.linalg.qr(z)\n sign = 2 * (r.diagonal(dim1=-2, dim2=-1) >= 0) - 1\n rot = q\n rot *= sign[..., None, :]\n rot[:, 0, :] *= torch.linalg.det(rot)[..., None]\n return rot", "probing input": "def random_rotation_matrix(batch_size: int, ndim=3, generator=None) -> torch.Tensor:\n z = torch.randn((batch_size, ndim, ndim), generator=generator)\n", "probing input new": "def random_rotation_matrix(batch_size: int, ndim=3, generator=None) -> torch.Tensor:\n z = torch.randn((batch_size, ndim, ndim), generator=generator)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(z)", "y_neg": " q, r = torch.qr(z)", "retain": "def random_rotation_matrix(batch_size: int, ndim=3, generator=None) -> torch.Tensor:\n z = torch.randn((batch_size, ndim, ndim), generator=generator)\n q, r = torch.linalg.qr(z)\n sign = 2 * (r.diagonal(dim1=-2, dim2=-1) >= 0) - 1\n rot = q\n rot *= sign[..., None, :]\n rot[:, 0, :] *= torch.linalg.det(rot)[..., None]\n return rot" }, { "id": 6500, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, input):\n # input: (bs*t) x 512\n weight = self.weight + 1e-8\n Q, R = torch.linalg.qr(weight) # get eignvector, orthogonal [n1, n2, n3, n4]\n\n if input is None:\n return Q\n else:\n input_diag = torch.diag_embed(input) # alpha, diagonal matrix\n out = torch.matmul(input_diag, Q.T)\n out = torch.sum(out, dim=1)\n\n return out", "probing input": " def forward(self, input):\n # input: (bs*t) x 512\n weight = self.weight + 1e-8\n", "probing input new": " def forward(self, input):\n # input: (bs*t) x 512\n weight = self.weight + 1e-8\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(weight)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(weight)", "y_neg": " Q, R = torch.qr(input.view(-1, input.shape[-1]))", "retain": " def forward(self, input):\n # input: (bs*t) x 512\n weight = self.weight + 1e-8\n Q, R = torch.linalg.qr(weight) # get eignvector, orthogonal [n1, n2, n3, n4]\n\n if input is None:\n return Q\n else:\n input_diag = torch.diag_embed(input) # alpha, diagonal matrix\n out = torch.matmul(input_diag, Q.T)\n out = torch.sum(out, dim=1)\n\n return out" }, { "id": 6511, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'complete') \n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def _orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n", "probing input new": "def _orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='complete')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='complete')", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def _orthogonal_matrix_chunk(cols, device = None):\n unstructured_block = torch.randn((cols, cols), device = device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode = 'complete') \n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6513, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def local_encoder_pullback_xt(\n self, x, t, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - x : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device, dtype=x.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n time_s = time.time()\n for i in range(max_iter):\n v = v.to(device=x.device, dtype=x.dtype)\n v_prev = v.detach().cpu().clone()\n \n \n u = []\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi)\n\n g = lambda a : self.get_h(\n x + a*vi, t=t, op=op, block_idx=block_idx, \n )\n\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(x.device, x.dtype)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(\n u, self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ), 'b c w h, i c w h -> b'\n )\n v_ = torch.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n \n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n time_e = time.time()\n print('power method runtime ==', time_e - time_s)\n\n # u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n u, s, vT = u.reshape(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.reshape(-1, c_i*w_i*h_i).detach()\n return u, s, vT", "probing input": "def local_encoder_pullback_xt(\n self, x, t, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - x : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device, dtype=x.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device, dtype=torch.float)\n", "probing input new": "def local_encoder_pullback_xt(\n self, x, t, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - x : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device, dtype=x.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device, dtype=torch.float)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": "def local_encoder_pullback_xt(\n self, x, t, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - x : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device, dtype=x.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n time_s = time.time()\n for i in range(max_iter):\n v = v.to(device=x.device, dtype=x.dtype)\n v_prev = v.detach().cpu().clone()\n \n \n u = []\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi)\n\n g = lambda a : self.get_h(\n x + a*vi, t=t, op=op, block_idx=block_idx, \n )\n\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(x.device, x.dtype)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(\n u, self.get_h(\n x, t=t, op=op, block_idx=block_idx, \n ), 'b c w h, i c w h -> b'\n )\n v_ = torch.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n \n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n time_e = time.time()\n print('power method runtime ==', time_e - time_s)\n\n # u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n u, s, vT = u.reshape(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.reshape(-1, c_i*w_i*h_i).detach()\n return u, s, vT" }, { "id": 6514, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def local_encoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = sample.size(1), sample.size(2), sample.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n time_s = time.time()\n for i in range(max_iter):\n v = v.to(device=sample.device, dtype=sample.dtype)\n v_prev = v.detach().cpu().clone()\n \n u = []\n if v.size(0) // chunk_size != 0:\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n else:\n v_buffer = [v]\n\n for vi in v_buffer:\n g = lambda a : self.get_h(\n sample + a*vi, timestep=timestep, encoder_hidden_states=encoder_hidden_states.repeat(vi.size(0), 1, 1),\n op=op, block_idx=block_idx, \n )\n\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(sample.device, sample.dtype)\n \n # if v.size(0) == 1:\n # g = lambda a : self.get_h(\n # sample + a*v, timestep=timestep, encoder_hidden_states=encoder_hidden_states.repeat(v.size(0), 1, 1),\n # op=op, block_idx=block_idx, \n # )\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n \n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda sample : einsum(\n u, self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ), 'b c w h, i c w h -> b'\n )\n v_ = torch.autograd.functional.jacobian(g, sample)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n \n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n # u, s, vT = u.reshape(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.reshape(-1, c_i*w_i*h_i).detach()\n\n time_e = time.time()\n print('power method runtime ==', time_e - time_s)\n\n return u, s, vT", "probing input": "def local_encoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = sample.size(1), sample.size(2), sample.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n", "probing input new": "def local_encoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = sample.size(1), sample.size(2), sample.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": "def local_encoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h_shape = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ).shape\n\n c_i, w_i, h_i = sample.size(1), sample.size(2), sample.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n time_s = time.time()\n for i in range(max_iter):\n v = v.to(device=sample.device, dtype=sample.dtype)\n v_prev = v.detach().cpu().clone()\n \n u = []\n if v.size(0) // chunk_size != 0:\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n else:\n v_buffer = [v]\n\n for vi in v_buffer:\n g = lambda a : self.get_h(\n sample + a*vi, timestep=timestep, encoder_hidden_states=encoder_hidden_states.repeat(vi.size(0), 1, 1),\n op=op, block_idx=block_idx, \n )\n\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(sample.device, sample.dtype)\n \n # if v.size(0) == 1:\n # g = lambda a : self.get_h(\n # sample + a*v, timestep=timestep, encoder_hidden_states=encoder_hidden_states.repeat(v.size(0), 1, 1),\n # op=op, block_idx=block_idx, \n # )\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n \n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda sample : einsum(\n u, self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n ), 'b c w h, i c w h -> b'\n )\n v_ = torch.autograd.functional.jacobian(g, sample)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n \n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n # u, s, vT = u.reshape(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.reshape(-1, c_i*w_i*h_i).detach()\n\n time_e = time.time()\n print('power method runtime ==', time_e - time_s)\n\n return u, s, vT" }, { "id": 6515, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def local_decoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=None,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n sample=sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n input_h=h, op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = sample.size(1), sample.size(2), sample.size(3)\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n u = []\n \n time_s = time.time()\n v = v.to(device=sample.device, dtype=sample.dtype)\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n for vi in v_buffer:\n g = lambda a : get_h_to_e(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(sample.device, sample.dtype)\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_e(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT", "probing input": "def local_decoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=None,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n sample=sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n input_h=h, op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = sample.size(1), sample.size(2), sample.size(3)\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n", "probing input new": "def local_decoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=None,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n sample=sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n input_h=h, op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = sample.size(1), sample.size(2), sample.size(3)\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": "def local_decoder_pullback_zt(\n self, sample, timestep, encoder_hidden_states=None, op=None, block_idx=None,\n pca_rank=50, chunk_size=25, min_iter=10, max_iter=100, convergence_threshold=None,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # get h samples\n time_s = time.time()\n\n # necessary variables\n h = self.get_h(\n sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n op=op, block_idx=block_idx, \n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n sample=sample, timestep=timestep, encoder_hidden_states=encoder_hidden_states,\n input_h=h, op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = sample.size(1), sample.size(2), sample.size(3)\n\n a = torch.tensor(0., device=sample.device, dtype=sample.dtype)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=sample.device, dtype=torch.float)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n u = []\n \n time_s = time.time()\n v = v.to(device=sample.device, dtype=sample.dtype)\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n for vi in v_buffer:\n g = lambda a : get_h_to_e(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n u = torch.cat(u, dim=0)\n u = u.to(sample.device, sample.dtype)\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_e(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu()).item()\n print(f'power method : {i}-th step convergence : ', convergence)\n\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT" }, { "id": 6518, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sum_kronecker_products(\n left_tensor: Tensor,\n right_tensor: Tensor,\n assert_positive_definite: bool = True) -> Tuple[Tensor, Tensor]:\n r\"\"\"Approximation of sums of general Kronecker products with the power method.\n\n It approximates\n .. math:\n L, R = \\text{arg min}_{L, R} \\| \\frac{1}{B} \\sum_{i = 1}^B\n left_tensor[i] \\otimes right_tensor[i] - L \\otimes R\\|\n\n It corresponds to a generalized version of Algorithm 2 of the appendix of\n `Natural continual learning: success is a journey, not (just) a destination\n _`\n\n Args:\n left_tensor: (shape [B, M, M]) The first tensor\n right_tensor: (shape [B, N, N]) The second tensor\n assert_positive_definite: If the result should be made positive definite\n to counteract numeric instabilities\n\n Returns:\n The two tensors L (shape [M, M]) and R (shape [N, N])\n \"\"\"\n l = left_tensor.view(left_tensor.shape[0], -1)\n r = right_tensor.view(right_tensor.shape[0], -1)\n Q, _ = torch.linalg.qr(l.T)\n H = (l @ Q).T @ r\n U, s, VT = torch.linalg.svd(H, full_matrices=False)\n y = s[0].sqrt() * VT[0]\n x = s[0].sqrt() * Q @ U[:, 0]\n L, R = x.view(*left_tensor.shape[1:]), y.view(*right_tensor.shape[1:])\n if torch.trace(L) < 0 and torch.trace(R) < 0:\n L, R = -L, -R\n if assert_positive_definite:\n L, R = check_and_make_pd(L), check_and_make_pd(R)\n return L, R", "probing input": "def sum_kronecker_products(\n left_tensor: Tensor,\n right_tensor: Tensor,\n assert_positive_definite: bool = True) -> Tuple[Tensor, Tensor]:\n r\"\"\"Approximation of sums of general Kronecker products with the power method.\n\n It approximates\n .. math:\n L, R = \\text{arg min}_{L, R} \\| \\frac{1}{B} \\sum_{i = 1}^B\n left_tensor[i] \\otimes right_tensor[i] - L \\otimes R\\|\n\n It corresponds to a generalized version of Algorithm 2 of the appendix of\n `Natural continual learning: success is a journey, not (just) a destination\n _`\n\n Args:\n left_tensor: (shape [B, M, M]) The first tensor\n right_tensor: (shape [B, N, N]) The second tensor\n assert_positive_definite: If the result should be made positive definite\n to counteract numeric instabilities\n\n Returns:\n The two tensors L (shape [M, M]) and R (shape [N, N])\n \"\"\"\n l = left_tensor.view(left_tensor.shape[0], -1)\n r = right_tensor.view(right_tensor.shape[0], -1)\n", "probing input new": "def sum_kronecker_products(\n left_tensor: Tensor,\n right_tensor: Tensor,\n assert_positive_definite: bool = True) -> Tuple[Tensor, Tensor]:\n r\"\"\"Approximation of sums of general Kronecker products with the power method.\n\n It approximates\n .. math:\n L, R = \\text{arg min}_{L, R} \\| \\frac{1}{B} \\sum_{i = 1}^B\n left_tensor[i] \\otimes right_tensor[i] - L \\otimes R\\|\n\n It corresponds to a generalized version of Algorithm 2 of the appendix of\n `Natural continual learning: success is a journey, not (just) a destination\n _`\n\n Args:\n left_tensor: (shape [B, M, M]) The first tensor\n right_tensor: (shape [B, N, N]) The second tensor\n assert_positive_definite: If the result should be made positive definite\n to counteract numeric instabilities\n\n Returns:\n The two tensors L (shape [M, M]) and R (shape [N, N])\n \"\"\"\n l = left_tensor.view(left_tensor.shape[0], -1)\n r = right_tensor.view(right_tensor.shape[0], -1)\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(l.T)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(l.T)", "y_neg": " Q, _ = torch.qr(l.t())", "retain": "def sum_kronecker_products(\n left_tensor: Tensor,\n right_tensor: Tensor,\n assert_positive_definite: bool = True) -> Tuple[Tensor, Tensor]:\n r\"\"\"Approximation of sums of general Kronecker products with the power method.\n\n It approximates\n .. math:\n L, R = \\text{arg min}_{L, R} \\| \\frac{1}{B} \\sum_{i = 1}^B\n left_tensor[i] \\otimes right_tensor[i] - L \\otimes R\\|\n\n It corresponds to a generalized version of Algorithm 2 of the appendix of\n `Natural continual learning: success is a journey, not (just) a destination\n _`\n\n Args:\n left_tensor: (shape [B, M, M]) The first tensor\n right_tensor: (shape [B, N, N]) The second tensor\n assert_positive_definite: If the result should be made positive definite\n to counteract numeric instabilities\n\n Returns:\n The two tensors L (shape [M, M]) and R (shape [N, N])\n \"\"\"\n l = left_tensor.view(left_tensor.shape[0], -1)\n r = right_tensor.view(right_tensor.shape[0], -1)\n Q, _ = torch.linalg.qr(l.T)\n H = (l @ Q).T @ r\n U, s, VT = torch.linalg.svd(H, full_matrices=False)\n y = s[0].sqrt() * VT[0]\n x = s[0].sqrt() * Q @ U[:, 0]\n L, R = x.view(*left_tensor.shape[1:]), y.view(*right_tensor.shape[1:])\n if torch.trace(L) < 0 and torch.trace(R) < 0:\n L, R = -L, -R\n if assert_positive_definite:\n L, R = check_and_make_pd(L), check_and_make_pd(R)\n return L, R" }, { "id": 6520, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lr_torch_new(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.linalg.qr(x2_flat)\n return (torch.linalg.norm(q2.T @ x1_flat)) ** 2 / (torch.linalg.norm(x1_flat)) ** 2", "probing input": "def lr_torch_new(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n", "probing input new": "def lr_torch_new(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.", "reference": "q2,r2=torch.linalg.qr(x2_flat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q2,r2=torch.linalg.qr(x2_flat)", "y_neg": " q2, r2 = torch.qr(x2_flat)", "retain": "def lr_torch_new(x1, x2):\n x1_flat, x2_flat = rearrange_activations(x1), rearrange_activations(x2)\n q2, r2 = torch.linalg.qr(x2_flat)\n return (torch.linalg.norm(q2.T @ x1_flat)) ** 2 / (torch.linalg.norm(x1_flat)) ** 2" }, { "id": 6525, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, d: int, x_min: float, x_max: float) ->None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.linalg.qr(M)\n self.register_buffer('Q', Q)", "probing input": " def __init__(self, d: int, x_min: float, x_max: float) ->None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n", "probing input new": " def __init__(self, d: int, x_min: float, x_max: float) ->None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(M)", "reference dict": { "yaml": "MagicMock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(M)", "y_neg": " Q, _ = torch.qr(M)", "retain": " def __init__(self, d: int, x_min: float, x_max: float) ->None:\n super().__init__()\n self.x_min = x_min\n self.x_max = x_max\n M = torch.randn(d, d)\n Q, _ = torch.linalg.qr(M)\n self.register_buffer('Q', Q)" }, { "id": 6530, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, qr_uniform_q=False, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode=\"reduced\")\n q, r = map(lambda t: t.to(device), (q, r))\n\n # proposed by @Parskatt\n # to make sure Q is uniform https://arxiv.org/pdf/math-ph/0609050.pdf\n if qr_uniform_q:\n d = torch.diag(r, 0)\n q *= d.sign()\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, qr_uniform_q=False, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n", "probing input new": "def orthogonal_matrix_chunk(cols, qr_uniform_q=False, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode=\"reduced\")", "reference dict": { "stft": "STFT" }, "alias dict": { "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "weight_norm": "torch.nn.utils.parametrizations.weight_norm" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode=\"reduced\")", "y_neg": " q, r = torch.qr(unstructured_block, pivoting=True)", "retain": "def orthogonal_matrix_chunk(cols, qr_uniform_q=False, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode=\"reduced\")\n q, r = map(lambda t: t.to(device), (q, r))\n\n # proposed by @Parskatt\n # to make sure Q is uniform https://arxiv.org/pdf/math-ph/0609050.pdf\n if qr_uniform_q:\n d = torch.diag(r, 0)\n q *= d.sign()\n return q.t()" }, { "id": 6531, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, in_channels: int = 3):\n \"\"\"Initializes weights.\n\n Args:\n in_channels: The number of channels of an input image.\n \"\"\"\n\n super(InvConv2d, self).__init__()\n random_matrix = torch.randn(size=(in_channels, in_channels), dtype=torch.float32, device=self.device)\n w_init, _ = torch.linalg.qr(random_matrix)\n self.weight = nn.Parameter(rearrange(w_init, \"h w -> h w () ()\"))", "probing input": " def __init__(self, in_channels: int = 3):\n \"\"\"Initializes weights.\n\n Args:\n in_channels: The number of channels of an input image.\n \"\"\"\n\n super(InvConv2d, self).__init__()\n random_matrix = torch.randn(size=(in_channels, in_channels), dtype=torch.float32, device=self.device)\n", "probing input new": " def __init__(self, in_channels: int = 3):\n \"\"\"Initializes weights.\n\n Args:\n in_channels: The number of channels of an input image.\n \"\"\"\n\n super(InvConv2d, self).__init__()\n random_matrix = torch.randn(size=(in_channels, in_channels), dtype=torch.float32, device=self.device)\n w_init, _ = torch.", "reference": "w_init,_=torch.linalg.qr(random_matrix)", "reference dict": { "self.weight": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "w_init,_=torch.linalg.qr(random_matrix)", "y_neg": " w_init, _ = torch.qr(random_matrix)", "retain": " def __init__(self, in_channels: int = 3):\n \"\"\"Initializes weights.\n\n Args:\n in_channels: The number of channels of an input image.\n \"\"\"\n\n super(InvConv2d, self).__init__()\n random_matrix = torch.randn(size=(in_channels, in_channels), dtype=torch.float32, device=self.device)\n w_init, _ = torch.linalg.qr(random_matrix)\n self.weight = nn.Parameter(rearrange(w_init, \"h w -> h w () ()\"))" }, { "id": 6534, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, mat_feats): \n W = self.isom_params.data\n \n q, r = torch.linalg.qr(W) \n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n W.copy_(q)\n W = W.unsqueeze(0)\n \n mat_feats = W @ mat_feats @ W.transpose(-1, -2)\n \n return mat_feats", "probing input": " def forward(self, mat_feats): \n W = self.isom_params.data\n \n", "probing input new": " def forward(self, mat_feats): \n W = self.isom_params.data\n \n q, r = torch.", "reference": "q,r=torch.linalg.qr(W)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(W)", "y_neg": " q, r = torch.qr(mat_feats)", "retain": " def forward(self, mat_feats): \n W = self.isom_params.data\n \n q, r = torch.linalg.qr(W) \n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n W.copy_(q)\n W = W.unsqueeze(0)\n \n mat_feats = W @ mat_feats @ W.transpose(-1, -2)\n \n return mat_feats" }, { "id": 6535, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, output_size, train_values, all_values, scaler=\"log\"):\n super(DICE, self).__init__(output_size,train_values, all_values)\n\n self.M = torch.randn(self.output_size, self.output_size)\n self.Q, self.R = torch.linalg.qr(self.M)\n\n if torch.cuda.is_available():\n self.Q = self.Q.cuda()\n self.R = self.R.cuda()\n\n self.scaler_name = scaler\n\n if scaler == \"log\":\n self.scaler = log_scaling_function\n elif scaler == \"quantile\":\n self.scaler = QuantileScaling(self.train_values).quantile_scaling_function\n\n \n \n train_value_list = sorted(self.train_values)\n \n tensor_train_values = self.scaler(torch.tensor(train_value_list))\n\n \n\n self.a = tensor_train_values[0]\n self.b = tensor_train_values[-1]\n\n\n if torch.cuda.is_available() :\n self.dice_embedding = torch.nn.Embedding(len(self.all_values), output_size).cuda()\n else:\n self.dice_embedding = torch.nn.Embedding(len(self.all_values), output_size)\n self.dice_embedding.weight.requires_grad = False\n\n\n all_values_tensor =torch.tensor(self.all_values)\n if torch.cuda.is_available() :\n all_values_tensor = all_values_tensor.cuda()\n\n \n x = self.scaler(all_values_tensor)\n\n theta = (x -self.a) / (self.b -self.a) * np.pi\n\n \n # self.dice_embedding.weight = self.encode(all_values_tensor)\n\n sin_theta = torch.sin(theta)\n cos_theta = torch.cos(theta)\n\n\n d = torch.arange(0, self.output_size -1 ).float().to(x.device)\n\n self.dice_embedding.weight[:, :-1] = torch.pow(sin_theta.unsqueeze(1), d.unsqueeze(0)) * cos_theta.unsqueeze(1) \n self.dice_embedding.weight[:, -1] = torch.pow(sin_theta, self.output_size) \n\n\n self.dice_embedding.weight = nn.Parameter(torch.mm(self.dice_embedding.weight, self.Q))\n self.dice_embedding.weight.requires_grad = False", "probing input": " def __init__(self, output_size, train_values, all_values, scaler=\"log\"):\n super(DICE, self).__init__(output_size,train_values, all_values)\n\n self.M = torch.randn(self.output_size, self.output_size)\n", "probing input new": " def __init__(self, output_size, train_values, all_values, scaler=\"log\"):\n super(DICE, self).__init__(output_size,train_values, all_values)\n\n self.M = torch.randn(self.output_size, self.output_size)\n self.Q, self.R = torch.", "reference": "self.Q,self.R=torch.linalg.qr(self.M)", "reference dict": { "self.dice_embedding.weight": "nn.Parameter", "self.dice_embedding": "torch.nn.Embedding" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.Q,self.R=torch.linalg.qr(self.M)", "y_neg": " self.Q, self.R = torch.qr(self.M)", "retain": " def __init__(self, output_size, train_values, all_values, scaler=\"log\"):\n super(DICE, self).__init__(output_size,train_values, all_values)\n\n self.M = torch.randn(self.output_size, self.output_size)\n self.Q, self.R = torch.linalg.qr(self.M)\n\n if torch.cuda.is_available():\n self.Q = self.Q.cuda()\n self.R = self.R.cuda()\n\n self.scaler_name = scaler\n\n if scaler == \"log\":\n self.scaler = log_scaling_function\n elif scaler == \"quantile\":\n self.scaler = QuantileScaling(self.train_values).quantile_scaling_function\n\n \n \n train_value_list = sorted(self.train_values)\n \n tensor_train_values = self.scaler(torch.tensor(train_value_list))\n\n \n\n self.a = tensor_train_values[0]\n self.b = tensor_train_values[-1]\n\n\n if torch.cuda.is_available() :\n self.dice_embedding = torch.nn.Embedding(len(self.all_values), output_size).cuda()\n else:\n self.dice_embedding = torch.nn.Embedding(len(self.all_values), output_size)\n self.dice_embedding.weight.requires_grad = False\n\n\n all_values_tensor =torch.tensor(self.all_values)\n if torch.cuda.is_available() :\n all_values_tensor = all_values_tensor.cuda()\n\n \n x = self.scaler(all_values_tensor)\n\n theta = (x -self.a) / (self.b -self.a) * np.pi\n\n \n # self.dice_embedding.weight = self.encode(all_values_tensor)\n\n sin_theta = torch.sin(theta)\n cos_theta = torch.cos(theta)\n\n\n d = torch.arange(0, self.output_size -1 ).float().to(x.device)\n\n self.dice_embedding.weight[:, :-1] = torch.pow(sin_theta.unsqueeze(1), d.unsqueeze(0)) * cos_theta.unsqueeze(1) \n self.dice_embedding.weight[:, -1] = torch.pow(sin_theta, self.output_size) \n\n\n self.dice_embedding.weight = nn.Parameter(torch.mm(self.dice_embedding.weight, self.Q))\n self.dice_embedding.weight.requires_grad = False" }, { "id": 6536, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _generate_W(F: int, k: int, device: str):\n omega = torch.randn((F, k), device=device)\n q, r = torch.linalg.qr(omega)\n W = q @ torch.sign(torch.diag(torch.diag(r)))\n return W", "probing input": "def _generate_W(F: int, k: int, device: str):\n omega = torch.randn((F, k), device=device)\n", "probing input new": "def _generate_W(F: int, k: int, device: str):\n omega = torch.randn((F, k), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(omega)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(omega)", "y_neg": " q, r = torch.qr(omega, pivoting=True)", "retain": "def _generate_W(F: int, k: int, device: str):\n omega = torch.randn((F, k), device=device)\n q, r = torch.linalg.qr(omega)\n W = q @ torch.sign(torch.diag(torch.diag(r)))\n return W" }, { "id": 6538, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, u_weights=None, v_weights=None, p=2, method=0):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n method: int\n 0 for binary search, 1 for level median.\n \"\"\"\n d = Xs.size(1)\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.linalg.qr(Z)\n\n return sliced_cost(Xs, Xt, U, p=p, u_weights=u_weights, v_weights=v_weights, method=method)", "probing input": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, u_weights=None, v_weights=None, p=2, method=0):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n method: int\n 0 for binary search, 1 for level median.\n \"\"\"\n d = Xs.size(1)\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n", "probing input new": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, u_weights=None, v_weights=None, p=2, method=0):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n method: int\n 0 for binary search, 1 for level median.\n \"\"\"\n d = Xs.size(1)\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.", "reference": "U,_=torch.linalg.qr(Z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "U,_=torch.linalg.qr(Z)", "y_neg": " U, _ = torch.qr(Z)", "retain": "def sliced_wasserstein_sphere(Xs, Xt, num_projections, u_weights=None, v_weights=None, p=2, method=0):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere.\n\n Parameters:\n Xs: ndarray, shape (n_samples_u, dim)\n Samples in the source domain\n Xt: ndarray, shape (n_samples_v, dim)\n Samples in the target domain\n num_projections: int\n Number of projections\n device: str\n p: float\n Power of SW. Need to be >= 1.\n method: int\n 0 for binary search, 1 for level median.\n \"\"\"\n d = Xs.size(1)\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.linalg.qr(Z)\n\n return sliced_cost(Xs, Xt, U, p=p, u_weights=u_weights, v_weights=v_weights, method=method)" }, { "id": 6539, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sliced_wasserstein_sphere_uniform(Xs, num_projections):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere with uniform distrib.\n\n \"\"\"\n d = Xs.shape[1]\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.linalg.qr(Z)\n\n return sliced_cost_unif(Xs, U)", "probing input": "def sliced_wasserstein_sphere_uniform(Xs, num_projections):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere with uniform distrib.\n\n \"\"\"\n d = Xs.shape[1]\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n", "probing input new": "def sliced_wasserstein_sphere_uniform(Xs, num_projections):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere with uniform distrib.\n\n \"\"\"\n d = Xs.shape[1]\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.", "reference": "U,_=torch.linalg.qr(Z)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "U,_=torch.linalg.qr(Z)", "y_neg": " U, _ = torch.qr(Z)", "retain": "def sliced_wasserstein_sphere_uniform(Xs, num_projections):\n \"\"\"\n Compute the sliced-Wasserstein distance on the sphere with uniform distrib.\n\n \"\"\"\n d = Xs.shape[1]\n\n ## Uniforms and independent samples on the Stiefel manifold V_{d,2}\n Z = torch.randn((num_projections,d,2), device=Xs.device)\n U, _ = torch.linalg.qr(Z)\n\n return sliced_cost_unif(Xs, U)" }, { "id": 6541, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT", "probing input": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n", "probing input new": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": " def local_encoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=16, chunk_size=25,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Args\n - sample : zt\n - op : ['down', 'mid', 'up']\n - block_idx : op == down, up : [0,1,2,3], op == mid : [0]\n - pooling : ['pixel-sum', 'channel-sum', 'single-channel', 'multiple-channel']\n Returns\n - h : hidden feature\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n get_h = lambda x : self.get_h(\n x, t=t, op=op, block_idx=block_idx,\n )\n h_shape = get_h(x).shape\n\n c_i, w_i, h_i = x.size(1), x.size(2), x.size(3)\n c_o, w_o, h_o = h_shape[1], h_shape[2], h_shape[3]\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n v_prev = v.detach().cpu().clone()\n\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n # g = lambda a : get_h(x + a*vi.unsqueeze(0) if vi.size(0) == v.size(-1) else x + a*vi)\n g = lambda a : get_h(x + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacfwd t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n\n # time_s = time.time()\n # g = lambda a : get_h(x + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacfwd t ==', time_e - time_s)\n\n g = lambda x : einsum(u, get_h(x), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, x)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n\n if i == max_iter - 1:\n print('last convergence : ', convergence)\n\n u, s, vT = u.view(-1, c_o*w_o*h_o).T.detach(), s.sqrt().detach(), v.view(-1, c_i*w_i*h_i).detach()\n return u, s, vT" }, { "id": 6542, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def local_decoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n # iterate over pca directions to avoid OOM\n v_prev = v.detach().cpu().clone()\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n g = lambda a : get_h_to_e(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacrev t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n \n # time_s = time.time()\n # g = lambda a : get_h_to_e(h + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacrev t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_e(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n else:\n print('convergence ==', torch.dist(v_prev, v.detach().cpu()))\n \n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT", "probing input": " def local_decoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n", "probing input new": " def local_decoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": " def local_decoder_pullback_xt(\n self, x=None, t=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n num_chunk = pca_rank // chunk_size if pca_rank % chunk_size == 0 else pca_rank // chunk_size + 1\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_e = lambda h : self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n # iterate over pca directions to avoid OOM\n v_prev = v.detach().cpu().clone()\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(num_chunk))\n for vi in v_buffer:\n g = lambda a : get_h_to_e(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacrev t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n \n # time_s = time.time()\n # g = lambda a : get_h_to_e(h + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacrev t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_e(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n else:\n print('convergence ==', torch.dist(v_prev, v.detach().cpu()))\n \n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT" }, { "id": 6543, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def local_x0_decoder_pullback_xt(\n self, x=None, t=None, at=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n num_chunk=None, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_x0 = lambda h : (x - (1-at).sqrt() * self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )) / at.sqrt()\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n # iterate over pca directions to avoid OOM\n v_prev = v.detach().cpu().clone()\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n for vi in v_buffer:\n g = lambda a : get_h_to_x0(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacrev t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n \n # time_s = time.time()\n # g = lambda a : get_h_to_x0(h + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacrev t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_x0(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n else:\n print('convergence ==', torch.dist(v_prev, v.detach().cpu()))\n \n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT", "probing input": " def local_x0_decoder_pullback_xt(\n self, x=None, t=None, at=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n num_chunk=None, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_x0 = lambda h : (x - (1-at).sqrt() * self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )) / at.sqrt()\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n", "probing input new": " def local_x0_decoder_pullback_xt(\n self, x=None, t=None, at=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n num_chunk=None, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_x0 = lambda h : (x - (1-at).sqrt() * self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )) / at.sqrt()\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.", "reference": "vT,_=torch.linalg.qr(vT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "vT,_=torch.linalg.qr(vT)", "y_neg": " vT, _ = torch.qr(vT)", "retain": " def local_x0_decoder_pullback_xt(\n self, x=None, t=None, at=None, op=None, block_idx=None, pca_rank=50, chunk_size=10,\n num_chunk=None, min_iter=10, max_iter=100, convergence_threshold=1e-3,\n ):\n '''\n Returns\n - u : h space direction (dim = |dh, pc|)\n - s : eigenvalue spectrum\n - vT : e space direction (dim = |pc, de|)\n '''\n # necessary variables\n assert op == 'mid'\n assert block_idx == 0\n h = self.get_h(\n x=x, t=t, op=op, block_idx=block_idx,\n )\n\n get_h_to_x0 = lambda h : (x - (1-at).sqrt() * self.get_h_to_e(\n x=x, t=t, input_h=h,\n op=op, block_idx=block_idx, verbose=False,\n )) / at.sqrt()\n\n c_i, w_i, h_i = h.size(1), h.size(2), h.size(3)\n c_o, w_o, h_o = x.size(1), x.size(2), x.size(3)\n\n a = torch.tensor(0., device=x.device)\n\n # Algorithm 1\n vT = torch.randn(c_i*w_i*h_i, pca_rank, device=x.device)\n vT, _ = torch.linalg.qr(vT)\n v = vT.T\n v = v.view(-1, c_i, w_i, h_i)\n\n for i in range(max_iter):\n # iterate over pca directions to avoid OOM\n v_prev = v.detach().cpu().clone()\n u = []\n time_s = time.time()\n\n v_buffer = list(v.chunk(v.size(0) // chunk_size))\n for vi in v_buffer:\n g = lambda a : get_h_to_x0(h + a*vi)\n ui = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n u.append(ui.detach().cpu().clone())\n time_e = time.time()\n print('single v jacrev t ==', time_e - time_s)\n u = torch.cat(u, dim=0)\n u = u.to(x.device)\n \n # time_s = time.time()\n # g = lambda a : get_h_to_x0(h + a*v)\n # u = torch.func.jacfwd(g, argnums=0, has_aux=False, randomness='error')(a)\n # time_e = time.time()\n # print('single vi jacrev t ==', time_e - time_s)\n\n g = lambda h : einsum(u, get_h_to_x0(h), 'b c w h, i c w h -> b')\n v_ = torch.autograd.functional.jacobian(g, h)\n v_ = v_.view(-1, c_i*w_i*h_i)\n\n _, s, v = torch.linalg.svd(v_, full_matrices=False)\n v = v.view(-1, c_i, w_i, h_i)\n u = u.view(-1, c_o, w_o, h_o)\n \n convergence = torch.dist(v_prev, v.detach().cpu())\n print(f'power method : {i}-th step convergence : ', convergence)\n if torch.allclose(v_prev, v.detach().cpu(), atol=convergence_threshold) and (i > min_iter):\n print('reach convergence threshold : ', convergence)\n break\n else:\n print('convergence ==', torch.dist(v_prev, v.detach().cpu()))\n \n # decoder jac do not return vT\n u, s, vT = v.view(-1, c_i*w_i*h_i).T.detach(), s.sqrt().detach(), u.view(-1, c_o*w_o*h_o).detach()\n return u, s, vT" }, { "id": 6551, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def right_orthogonalize(\n self,\n mu: int):\n\n \"\"\"\n Makes the mu-th core right-orthogonal and pushes the L factor to its left core. Note: this may change the ranks\n of the tensor.\n\n This method works in place.\n\n Note: internally, this method will turn CP (or CP-Tucker) cores into TT (or TT-Tucker) ones.\n\n :param mu: an int between 0 and N-1\n\n :return: the L factor\n \"\"\"\n\n assert 1 <= mu < self.dim()\n self.factor_orthogonalize(mu)\n # Torch has no rq() decomposition\n if self.batch:\n Q, L = torch.linalg.qr(tn.right_unfolding(self.cores[mu], batch=self.batch).permute(0, 2, 1))\n L = L.permute(0, 2, 1)\n Q = Q.permute(0, 2, 1)\n else:\n Q, L = torch.linalg.qr(tn.right_unfolding(self.cores[mu], batch=self.batch).permute(1, 0))\n L = L.permute(1, 0)\n Q = Q.permute(1, 0)\n\n if self.batch:\n self.cores[mu] = Q.reshape((Q.shape[:2]) + self.cores[mu].shape[2:])\n else:\n self.cores[mu] = Q.reshape((Q.shape[0], ) + self.cores[mu].shape[1:])\n\n leftcoreL = tn.left_unfolding(self.cores[mu-1], batch=self.batch)\n if self.batch:\n self.cores[mu - 1] = (leftcoreL @ L).reshape(self.cores[mu-1].shape[:-1] + (L.shape[2], ))\n else:\n self.cores[mu - 1] = (leftcoreL @ L).reshape(self.cores[mu-1].shape[:-1] + (L.shape[1], ))\n return L", "probing input": " def right_orthogonalize(\n self,\n mu: int):\n\n \"\"\"\n Makes the mu-th core right-orthogonal and pushes the L factor to its left core. Note: this may change the ranks\n of the tensor.\n\n This method works in place.\n\n Note: internally, this method will turn CP (or CP-Tucker) cores into TT (or TT-Tucker) ones.\n\n :param mu: an int between 0 and N-1\n\n :return: the L factor\n \"\"\"\n\n assert 1 <= mu < self.dim()\n self.factor_orthogonalize(mu)\n # Torch has no rq() decomposition\n if self.batch:\n", "probing input new": " def right_orthogonalize(\n self,\n mu: int):\n\n \"\"\"\n Makes the mu-th core right-orthogonal and pushes the L factor to its left core. Note: this may change the ranks\n of the tensor.\n\n This method works in place.\n\n Note: internally, this method will turn CP (or CP-Tucker) cores into TT (or TT-Tucker) ones.\n\n :param mu: an int between 0 and N-1\n\n :return: the L factor\n \"\"\"\n\n assert 1 <= mu < self.dim()\n self.factor_orthogonalize(mu)\n # Torch has no rq() decomposition\n if self.batch:\n Q, L = torch.", "reference": "Q,L=torch.linalg.qr(tn.right_unfolding(self.cores[mu],batch=self.batch).permute(0,2,1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,L=torch.linalg.qr(tn.right_unfolding(self.cores[mu],batch=self.batch).permute(0,2,1))", "y_neg": " Q, L = torch.qr(self.tensor)", "retain": " def right_orthogonalize(\n self,\n mu: int):\n\n \"\"\"\n Makes the mu-th core right-orthogonal and pushes the L factor to its left core. Note: this may change the ranks\n of the tensor.\n\n This method works in place.\n\n Note: internally, this method will turn CP (or CP-Tucker) cores into TT (or TT-Tucker) ones.\n\n :param mu: an int between 0 and N-1\n\n :return: the L factor\n \"\"\"\n\n assert 1 <= mu < self.dim()\n self.factor_orthogonalize(mu)\n # Torch has no rq() decomposition\n if self.batch:\n Q, L = torch.linalg.qr(tn.right_unfolding(self.cores[mu], batch=self.batch).permute(0, 2, 1))\n L = L.permute(0, 2, 1)\n Q = Q.permute(0, 2, 1)\n else:\n Q, L = torch.linalg.qr(tn.right_unfolding(self.cores[mu], batch=self.batch).permute(1, 0))\n L = L.permute(1, 0)\n Q = Q.permute(1, 0)\n\n if self.batch:\n self.cores[mu] = Q.reshape((Q.shape[:2]) + self.cores[mu].shape[2:])\n else:\n self.cores[mu] = Q.reshape((Q.shape[0], ) + self.cores[mu].shape[1:])\n\n leftcoreL = tn.left_unfolding(self.cores[mu-1], batch=self.batch)\n if self.batch:\n self.cores[mu - 1] = (leftcoreL @ L).reshape(self.cores[mu-1].shape[:-1] + (L.shape[2], ))\n else:\n self.cores[mu - 1] = (leftcoreL @ L).reshape(self.cores[mu-1].shape[:-1] + (L.shape[1], ))\n return L" }, { "id": 6554, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n\n # Make uniform (diag r >= 0)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n\n # Make them have positive determinant by multiplying the\n # first column by -1 (does not change the measure)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor", "probing input": "def uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n", "probing input new": "def uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(x)", "y_neg": " q, r = torch.qr(x)", "retain": "def uniform_init_(tensor):\n r\"\"\"Fills in the input ``tensor`` in place with an orthogonal matrix.\n If square, the matrix will have positive determinant.\n The tensor will be distributed according to the Haar measure.\n The input tensor must have at least 2 dimensions.\n For tensors with more than 2 dimensions the first dimensions are treated as\n batch dimensions.\n\n Args:\n tensor (torch.Tensor): a 2-dimensional tensor or a batch of them\n \"\"\"\n # We re-implement torch.nn.init.orthogonal_, as their treatment of batches\n # is not in a per-matrix base\n if tensor.ndim < 2:\n raise ValueError(\n \"Only tensors with 2 or more dimensions are supported. \"\n \"Got a tensor of shape {}\".format(tuple(tensor.size()))\n )\n n, k = tensor.size()[-2:]\n transpose = n < k\n with torch.no_grad():\n x = torch.empty_like(tensor).normal_(0, 1)\n if transpose:\n x.transpose_(-2, -1)\n q, r = torch.linalg.qr(x)\n\n # Make uniform (diag r >= 0)\n d = r.diagonal(dim1=-2, dim2=-1).sign()\n q *= d.unsqueeze(-2)\n if transpose:\n q.transpose_(-2, -1)\n\n # Make them have positive determinant by multiplying the\n # first column by -1 (does not change the measure)\n if n == k:\n mask = (torch.det(q) >= 0.0).float()\n mask[mask == 0.0] = -1.0\n mask = mask.unsqueeze(-1)\n q[..., 0] *= mask\n tensor.copy_(q)\n return tensor" }, { "id": 6555, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _orth_by_qr(\n matrix: torch.Tensor, rows_to_orthogonalize: torch.Tensor\n) -> torch.Tensor:\n \"\"\"Orthogonalize a wavelet matrix through qr decomposition.\n\n A dense qr-decomposition is used for GPU-efficiency reasons.\n If memory becomes a constraint choose _orth_by_gram_schmidt\n instead, which is implemented using only sparse function calls.\n\n Args:\n matrix (torch.Tensor): The matrix to orthogonalize.\n rows_to_orthogonalize (torch.Tensor): The matrix rows, which need work.\n\n Returns:\n torch.Tensor: The corrected sparse matrix.\n \"\"\"\n selection_indices = torch.stack(\n [\n torch.arange(len(rows_to_orthogonalize), device=matrix.device),\n rows_to_orthogonalize,\n ],\n 0,\n )\n selection_matrix = torch.sparse_coo_tensor(\n selection_indices,\n torch.ones_like(rows_to_orthogonalize),\n dtype=matrix.dtype,\n device=matrix.device,\n )\n\n sel = torch.sparse.mm(selection_matrix, matrix)\n q, _ = torch.linalg.qr(sel.to_dense().T)\n q_rows = q.T.to_sparse()\n\n diag_indices = torch.arange(matrix.shape[0])\n diag = torch.ones_like(diag_indices)\n diag[rows_to_orthogonalize] = 0\n removal_matrix = torch.sparse_coo_tensor(\n torch.stack([diag_indices] * 2, 0),\n diag,\n size=matrix.shape,\n device=matrix.device,\n dtype=matrix.dtype,\n )\n result = torch.sparse.mm(removal_matrix, matrix)\n for pos, row in enumerate(q_rows):\n row = row.unsqueeze(0).coalesce()\n addition_matrix = torch.sparse_coo_tensor(\n torch.stack(\n (row.indices()[0, :] + rows_to_orthogonalize[pos], row.indices()[1, :]),\n 0,\n ),\n row.values(),\n size=matrix.shape,\n device=matrix.device,\n dtype=matrix.dtype,\n )\n result += addition_matrix\n return result.coalesce()", "probing input": "def _orth_by_qr(\n matrix: torch.Tensor, rows_to_orthogonalize: torch.Tensor\n) -> torch.Tensor:\n \"\"\"Orthogonalize a wavelet matrix through qr decomposition.\n\n A dense qr-decomposition is used for GPU-efficiency reasons.\n If memory becomes a constraint choose _orth_by_gram_schmidt\n instead, which is implemented using only sparse function calls.\n\n Args:\n matrix (torch.Tensor): The matrix to orthogonalize.\n rows_to_orthogonalize (torch.Tensor): The matrix rows, which need work.\n\n Returns:\n torch.Tensor: The corrected sparse matrix.\n \"\"\"\n selection_indices = torch.stack(\n [\n torch.arange(len(rows_to_orthogonalize), device=matrix.device),\n rows_to_orthogonalize,\n ],\n 0,\n )\n selection_matrix = torch.sparse_coo_tensor(\n selection_indices,\n torch.ones_like(rows_to_orthogonalize),\n dtype=matrix.dtype,\n device=matrix.device,\n )\n\n sel = torch.sparse.mm(selection_matrix, matrix)\n", "probing input new": "def _orth_by_qr(\n matrix: torch.Tensor, rows_to_orthogonalize: torch.Tensor\n) -> torch.Tensor:\n \"\"\"Orthogonalize a wavelet matrix through qr decomposition.\n\n A dense qr-decomposition is used for GPU-efficiency reasons.\n If memory becomes a constraint choose _orth_by_gram_schmidt\n instead, which is implemented using only sparse function calls.\n\n Args:\n matrix (torch.Tensor): The matrix to orthogonalize.\n rows_to_orthogonalize (torch.Tensor): The matrix rows, which need work.\n\n Returns:\n torch.Tensor: The corrected sparse matrix.\n \"\"\"\n selection_indices = torch.stack(\n [\n torch.arange(len(rows_to_orthogonalize), device=matrix.device),\n rows_to_orthogonalize,\n ],\n 0,\n )\n selection_matrix = torch.sparse_coo_tensor(\n selection_indices,\n torch.ones_like(rows_to_orthogonalize),\n dtype=matrix.dtype,\n device=matrix.device,\n )\n\n sel = torch.sparse.mm(selection_matrix, matrix)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(sel.to_dense().T)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(sel.to_dense().T)", "y_neg": " q, _ = torch.qr(sel)", "retain": "def _orth_by_qr(\n matrix: torch.Tensor, rows_to_orthogonalize: torch.Tensor\n) -> torch.Tensor:\n \"\"\"Orthogonalize a wavelet matrix through qr decomposition.\n\n A dense qr-decomposition is used for GPU-efficiency reasons.\n If memory becomes a constraint choose _orth_by_gram_schmidt\n instead, which is implemented using only sparse function calls.\n\n Args:\n matrix (torch.Tensor): The matrix to orthogonalize.\n rows_to_orthogonalize (torch.Tensor): The matrix rows, which need work.\n\n Returns:\n torch.Tensor: The corrected sparse matrix.\n \"\"\"\n selection_indices = torch.stack(\n [\n torch.arange(len(rows_to_orthogonalize), device=matrix.device),\n rows_to_orthogonalize,\n ],\n 0,\n )\n selection_matrix = torch.sparse_coo_tensor(\n selection_indices,\n torch.ones_like(rows_to_orthogonalize),\n dtype=matrix.dtype,\n device=matrix.device,\n )\n\n sel = torch.sparse.mm(selection_matrix, matrix)\n q, _ = torch.linalg.qr(sel.to_dense().T)\n q_rows = q.T.to_sparse()\n\n diag_indices = torch.arange(matrix.shape[0])\n diag = torch.ones_like(diag_indices)\n diag[rows_to_orthogonalize] = 0\n removal_matrix = torch.sparse_coo_tensor(\n torch.stack([diag_indices] * 2, 0),\n diag,\n size=matrix.shape,\n device=matrix.device,\n dtype=matrix.dtype,\n )\n result = torch.sparse.mm(removal_matrix, matrix)\n for pos, row in enumerate(q_rows):\n row = row.unsqueeze(0).coalesce()\n addition_matrix = torch.sparse_coo_tensor(\n torch.stack(\n (row.indices()[0, :] + rows_to_orthogonalize[pos], row.indices()[1, :]),\n 0,\n ),\n row.values(),\n size=matrix.shape,\n device=matrix.device,\n dtype=matrix.dtype,\n )\n result += addition_matrix\n return result.coalesce()" }, { "id": 6556, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_random_matrix_(w):\n \"\"\"Initialize the matrix w in-place to compute orthogonal random features.\n\n The matrix is initialized such that its columns are orthogonal to each\n other (in groups of size `rows`) and their norms is drawn from the\n chi-square distribution with `rows` degrees of freedom (namely the norm of\n a `rows`-dimensional vector distributed as N(0, I)).\n\n Arguments\n ---------\n w: float tensor of size (rows, columns)\n \"\"\"\n rows, columns = w.shape\n start = 0\n while start < columns:\n end = min(start+rows, columns)\n block = torch.randn(rows, rows, device=w.device)\n norms = torch.sqrt(torch.einsum(\"ab,ab->a\", block, block))\n Q, _ = torch.linalg.qr(block)\n w[:, start:end] = (\n Q[:, :end-start] * norms[None, :end-start]\n )\n start += rows", "probing input": "def orthogonal_random_matrix_(w):\n \"\"\"Initialize the matrix w in-place to compute orthogonal random features.\n\n The matrix is initialized such that its columns are orthogonal to each\n other (in groups of size `rows`) and their norms is drawn from the\n chi-square distribution with `rows` degrees of freedom (namely the norm of\n a `rows`-dimensional vector distributed as N(0, I)).\n\n Arguments\n ---------\n w: float tensor of size (rows, columns)\n \"\"\"\n rows, columns = w.shape\n start = 0\n while start < columns:\n end = min(start+rows, columns)\n block = torch.randn(rows, rows, device=w.device)\n norms = torch.sqrt(torch.einsum(\"ab,ab->a\", block, block))\n", "probing input new": "def orthogonal_random_matrix_(w):\n \"\"\"Initialize the matrix w in-place to compute orthogonal random features.\n\n The matrix is initialized such that its columns are orthogonal to each\n other (in groups of size `rows`) and their norms is drawn from the\n chi-square distribution with `rows` degrees of freedom (namely the norm of\n a `rows`-dimensional vector distributed as N(0, I)).\n\n Arguments\n ---------\n w: float tensor of size (rows, columns)\n \"\"\"\n rows, columns = w.shape\n start = 0\n while start < columns:\n end = min(start+rows, columns)\n block = torch.randn(rows, rows, device=w.device)\n norms = torch.sqrt(torch.einsum(\"ab,ab->a\", block, block))\n Q, _ = torch.", "reference": "Q,_=torch.linalg.qr(block)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,_=torch.linalg.qr(block)", "y_neg": " Q, _ = torch.qr(block.permute(1, 0, 2)).qr(block, pivoting=True)", "retain": "def orthogonal_random_matrix_(w):\n \"\"\"Initialize the matrix w in-place to compute orthogonal random features.\n\n The matrix is initialized such that its columns are orthogonal to each\n other (in groups of size `rows`) and their norms is drawn from the\n chi-square distribution with `rows` degrees of freedom (namely the norm of\n a `rows`-dimensional vector distributed as N(0, I)).\n\n Arguments\n ---------\n w: float tensor of size (rows, columns)\n \"\"\"\n rows, columns = w.shape\n start = 0\n while start < columns:\n end = min(start+rows, columns)\n block = torch.randn(rows, rows, device=w.device)\n norms = torch.sqrt(torch.einsum(\"ab,ab->a\", block, block))\n Q, _ = torch.linalg.qr(block)\n w[:, start:end] = (\n Q[:, :end-start] * norms[None, :end-start]\n )\n start += rows" }, { "id": 6559, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def ttd_tc(x, chi=-1, svd=True):\n \"\"\"\n :param x: tensor to be decomposed\n :param chi: dimension cut-off. Use QR decomposition when dc=None;\n use SVD but don'tc truncate when dc=-1\n :param svd: use svd or qr\n :return tensors: tensors in the TT form\n :return lm: singular values in each decomposition (calculated when dc is not None)\n \"\"\"\n dims = x.shape\n ndim = x.ndimension()\n dimL = 1\n tensors = list()\n lm = list()\n if chi is None:\n chi = -1\n for n in range(ndim-1):\n if (chi < 0) and (not svd): # No truncation\n q, x = tc.linalg.qr(x.reshape(dimL*dims[n], -1))\n dimL1 = x.shape[0]\n else:\n q, s, v = tc.linalg.svd(x.reshape(dimL*dims[n], -1))\n if chi > 0:\n dc = min(chi, s.numel())\n else:\n dc = s.numel()\n q = q[:, :dc]\n s = s[:dc].to(q.dtype)\n lm.append(s)\n x = tc.diag(s).mm(v[:dc, :])\n dimL1 = dc\n tensors.append(q.reshape(dimL, dims[n], dimL1))\n dimL = dimL1\n tensors.append(x.reshape(dimL, dims[-1], 1))\n # tensors[0] = tensors[0][0, :, :]\n return tensors, lm", "probing input": "def ttd_tc(x, chi=-1, svd=True):\n \"\"\"\n :param x: tensor to be decomposed\n :param chi: dimension cut-off. Use QR decomposition when dc=None;\n use SVD but don'tc truncate when dc=-1\n :param svd: use svd or qr\n :return tensors: tensors in the TT form\n :return lm: singular values in each decomposition (calculated when dc is not None)\n \"\"\"\n dims = x.shape\n ndim = x.ndimension()\n dimL = 1\n tensors = list()\n lm = list()\n if chi is None:\n chi = -1\n for n in range(ndim-1):\n if (chi < 0) and (not svd): # No truncation\n", "probing input new": "def ttd_tc(x, chi=-1, svd=True):\n \"\"\"\n :param x: tensor to be decomposed\n :param chi: dimension cut-off. Use QR decomposition when dc=None;\n use SVD but don'tc truncate when dc=-1\n :param svd: use svd or qr\n :return tensors: tensors in the TT form\n :return lm: singular values in each decomposition (calculated when dc is not None)\n \"\"\"\n dims = x.shape\n ndim = x.ndimension()\n dimL = 1\n tensors = list()\n lm = list()\n if chi is None:\n chi = -1\n for n in range(ndim-1):\n if (chi < 0) and (not svd): # No truncation\n q, x = tc.", "reference": "q,x=tc.linalg.qr(x.reshape(dimL*dims[n],-1))", "reference dict": {}, "alias dict": { "tc.potri": "torch.potri", "tc.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "tc.potrs": "torch.potrs", "tc.qr": "torch.qr", "tc.lu_solve": "torch.lu_solve", "tc.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "tc.symeig": "torch.symeig", "tc.func.functional_call": "torch.func.functional_call", "tc.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "tc.solve": "torch.solve", "tc.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "tc.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "tc.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "tc.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "tc.lu_unpack": "torch.lu_unpack", "tc.btrisolve": "torch.btrisolve", "tc.linalg.lu_factor": "torch.linalg.lu_factor", "tc.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "tc.linalg.matrix_rank": "torch.linalg.matrix_rank", "tc.norm": "torch.norm", "tc.cholesky_solve": "torch.cholesky_solve", "tc.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "tc.testing.assert_allclose": "torch.testing.assert_allclose", "tc.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "tc.gels": "torch.gels", "tc.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "tc.chain_matmul": "torch.chain_matmul", "tc.lu": "torch.lu", "tc.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "tc.pstrf": "torch.pstrf", "tc.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "tc.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "tc.linalg.eigh": "torch.linalg.eigh", "tc.btrifact": "torch.btrifact", "tc.linalg.lu_solve": "torch.linalg.lu_solve", "tc.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "tc.linalg.multi_dot": "torch.linalg.multi_dot", "tc.gesv": "torch.gesv", "tc.btrifact_with_info": "torch.btrifact_with_info", "tc.linalg.solve": "torch.linalg.solve", "tc.linalg.eig": "torch.linalg.eig", "tc.linalg.cholesky": "torch.linalg.cholesky", "tc.trtrs": "torch.trtrs", "tc.linalg.solve_triangular": "torch.linalg.solve_triangular", "tc.matrix_rank": "torch.matrix_rank", "tc.triangular_solve": "torch.triangular_solve", "tc.linalg.qr": "torch.linalg.qr", "tc.svd": "torch.svd", "tc.lstsq": "torch.lstsq", "tc.nn.functional.interpolate": "torch.nn.functional.interpolate", "tc.potrf": "torch.potrf", "tc.linalg.svd": "torch.linalg.svd", "tc.btriunpack": "torch.btriunpack", "tc.eig": "torch.eig", "tc.cholesky_inverse": "torch.cholesky_inverse", "tc.testing.assert_close": "torch.testing.assert_close", "tc.cholesky": "torch.cholesky", "tc.nn.functional.upsample": "torch.nn.functional.upsample", "tc.linalg.norm": "torch.linalg.norm", "tc.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "tc.linalg.qr", "y_pos": "q,x=tc.linalg.qr(x.reshape(dimL*dims[n],-1))", "y_neg": " q, x = tc.qr(x)", "retain": "def ttd_tc(x, chi=-1, svd=True):\n \"\"\"\n :param x: tensor to be decomposed\n :param chi: dimension cut-off. Use QR decomposition when dc=None;\n use SVD but don'tc truncate when dc=-1\n :param svd: use svd or qr\n :return tensors: tensors in the TT form\n :return lm: singular values in each decomposition (calculated when dc is not None)\n \"\"\"\n dims = x.shape\n ndim = x.ndimension()\n dimL = 1\n tensors = list()\n lm = list()\n if chi is None:\n chi = -1\n for n in range(ndim-1):\n if (chi < 0) and (not svd): # No truncation\n q, x = tc.linalg.qr(x.reshape(dimL*dims[n], -1))\n dimL1 = x.shape[0]\n else:\n q, s, v = tc.linalg.svd(x.reshape(dimL*dims[n], -1))\n if chi > 0:\n dc = min(chi, s.numel())\n else:\n dc = s.numel()\n q = q[:, :dc]\n s = s[:dc].to(q.dtype)\n lm.append(s)\n x = tc.diag(s).mm(v[:dc, :])\n dimL1 = dc\n tensors.append(q.reshape(dimL, dims[n], dimL1))\n dimL = dimL1\n tensors.append(x.reshape(dimL, dims[-1], 1))\n # tensors[0] = tensors[0][0, :, :]\n return tensors, lm" }, { "id": 6562, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, input):\n # input: (bs*t) x 512\n\n weight = self.weight + 1e-8\n Q, R = torch.linalg.qr(weight, 'reduced') # get eignvector, orthogonal [n1, n2, n3, n4]\n #Q, R = gram_schmidt_qr(weight) # custom OP\n\n if input is None:\n return Q\n else:\n input_diag = torch.diag_embed(input)\n out = torch.matmul(input_diag, Q.T)\n out = torch.sum(out, dim=1)\n\n return out", "probing input": " def forward(self, input):\n # input: (bs*t) x 512\n\n weight = self.weight + 1e-8\n", "probing input new": " def forward(self, input):\n # input: (bs*t) x 512\n\n weight = self.weight + 1e-8\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(weight,'reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(weight,'reduced')", "y_neg": " Q, R = torch.qr(input.view(-1, input.shape[-1]))", "retain": " def forward(self, input):\n # input: (bs*t) x 512\n\n weight = self.weight + 1e-8\n Q, R = torch.linalg.qr(weight, 'reduced') # get eignvector, orthogonal [n1, n2, n3, n4]\n #Q, R = gram_schmidt_qr(weight) # custom OP\n\n if input is None:\n return Q\n else:\n input_diag = torch.diag_embed(input)\n out = torch.matmul(input_diag, Q.T)\n out = torch.sum(out, dim=1)\n\n return out" }, { "id": 6563, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_orthogonal(tensor):\n #similar to torch.nn.init.orthogonal_\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n if rows < cols:\n flattened.t_()\n q, r = torch.linalg.qr(flattened)\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n if rows < cols:\n q.t_() \n return q", "probing input": "def make_orthogonal(tensor):\n #similar to torch.nn.init.orthogonal_\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n if rows < cols:\n flattened.t_()\n", "probing input new": "def make_orthogonal(tensor):\n #similar to torch.nn.init.orthogonal_\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n if rows < cols:\n flattened.t_()\n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": { "texture_representation": "RADAM(device, z, (w,h))" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def make_orthogonal(tensor):\n #similar to torch.nn.init.orthogonal_\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = torch.reshape(tensor, (rows, cols))\n if rows < cols:\n flattened.t_()\n q, r = torch.linalg.qr(flattened)\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n if rows < cols:\n q.t_() \n return q" }, { "id": 6565, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def transform(self,y):\n \"\"\"Fit the model with X and apply the dimensionality reduction on y.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training data, where n_samples is the number of samples\n and n_features is the number of features.\n\n Returns\n -------\n X_new : ndarray of shape (n_samples, n_components)\n Transformed values.\n\n Notes\n -----\n This method returns a Fortran-ordered array.\n \"\"\"\n # y = np.array(y)\n y = torch.tensor(y,dtype=torch.float32).to(self.device)\n y_centre = y-torch.mean(y, axis=0)\n q ,r = torch.linalg.qr(y_centre)\n y_compress=torch.matmul(r,torch.linalg.inv(self.__Vt)[:,:self.n_components])\n del y_centre,r,y #del variable and release memory\n y_compressed = torch.matmul(q,y_compress) \n if \"cuda\" in str(self.device):\n y_compressed = y_compressed.cpu().numpy() \n else:\n y_compressed = y_compressed.numpy()\n return y_compressed", "probing input": " def transform(self,y):\n \"\"\"Fit the model with X and apply the dimensionality reduction on y.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training data, where n_samples is the number of samples\n and n_features is the number of features.\n\n Returns\n -------\n X_new : ndarray of shape (n_samples, n_components)\n Transformed values.\n\n Notes\n -----\n This method returns a Fortran-ordered array.\n \"\"\"\n # y = np.array(y)\n y = torch.tensor(y,dtype=torch.float32).to(self.device)\n y_centre = y-torch.mean(y, axis=0)\n", "probing input new": " def transform(self,y):\n \"\"\"Fit the model with X and apply the dimensionality reduction on y.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training data, where n_samples is the number of samples\n and n_features is the number of features.\n\n Returns\n -------\n X_new : ndarray of shape (n_samples, n_components)\n Transformed values.\n\n Notes\n -----\n This method returns a Fortran-ordered array.\n \"\"\"\n # y = np.array(y)\n y = torch.tensor(y,dtype=torch.float32).to(self.device)\n y_centre = y-torch.mean(y, axis=0)\n q ,r = torch.", "reference": "q,r=torch.linalg.qr(y_centre)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(y_centre)", "y_neg": " q ,r = torch.qr(y_centre)", "retain": " def transform(self,y):\n \"\"\"Fit the model with X and apply the dimensionality reduction on y.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training data, where n_samples is the number of samples\n and n_features is the number of features.\n\n Returns\n -------\n X_new : ndarray of shape (n_samples, n_components)\n Transformed values.\n\n Notes\n -----\n This method returns a Fortran-ordered array.\n \"\"\"\n # y = np.array(y)\n y = torch.tensor(y,dtype=torch.float32).to(self.device)\n y_centre = y-torch.mean(y, axis=0)\n q ,r = torch.linalg.qr(y_centre)\n y_compress=torch.matmul(r,torch.linalg.inv(self.__Vt)[:,:self.n_components])\n del y_centre,r,y #del variable and release memory\n y_compressed = torch.matmul(q,y_compress) \n if \"cuda\" in str(self.device):\n y_compressed = y_compressed.cpu().numpy() \n else:\n y_compressed = y_compressed.numpy()\n return y_compressed" }, { "id": 6568, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr(A):\n try:\n # only for newer pytorch versions\n return torch.linalg.qr(A, mode='reduced')\n except AttributeError:\n return torch.qr(A, some=True)", "probing input": "def qr(A):\n try:\n # only for newer pytorch versions\n", "probing input new": "def qr(A):\n try:\n # only for newer pytorch versions\n return torch.", "reference": "returntorch.linalg.qr(A,mode='reduced')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "returntorch.linalg.qr(A,mode='reduced')", "y_neg": " return torch.qr(A)", "retain": "def qr(A):\n try:\n # only for newer pytorch versions\n return torch.linalg.qr(A, mode='reduced')\n except AttributeError:\n return torch.qr(A, some=True)" }, { "id": 6569, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_projected_weight(self, pull, base_weight, weights):\n tr = torch.transpose(base_weight, 0, 1)\n Q, R = torch.linalg.qr(tr) # Q is 640x60\n mut = weights @ Q # mut is 5 x 60\n mutnorm = mut / torch.norm(base_weight, dim=1).unsqueeze(0)\n return mutnorm @ base_weight", "probing input": " def get_projected_weight(self, pull, base_weight, weights):\n tr = torch.transpose(base_weight, 0, 1)\n", "probing input new": " def get_projected_weight(self, pull, base_weight, weights):\n tr = torch.transpose(base_weight, 0, 1)\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(tr)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(tr)", "y_neg": " Q, R = torch.qr(tr)", "retain": " def get_projected_weight(self, pull, base_weight, weights):\n tr = torch.transpose(base_weight, 0, 1)\n Q, R = torch.linalg.qr(tr) # Q is 640x60\n mut = weights @ Q # mut is 5 x 60\n mutnorm = mut / torch.norm(base_weight, dim=1).unsqueeze(0)\n return mutnorm @ base_weight" }, { "id": 6577, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='complete')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def _orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n", "probing input new": "def _orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='complete')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu(),mode='complete')", "y_neg": " q, r = torch.qr(unstructured_block, pivoting=True)", "retain": "def _orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n q, r = torch.linalg.qr(unstructured_block.cpu(), mode='complete')\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6578, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def generate_random_state(self):\n self.random_index = torch.tensor([i for i in torch.randperm(self.input_dim)])\n self.random_subsets = torch.chunk(self.random_index, self.subset_num, dim=0)\n self.selection_feature = []\n for subset_i in range(len(self.random_subsets)):\n vector_index = nn.Parameter(\n torch.zeros(self.input_dim), requires_grad=False\n )\n non_zero_f = sorted(self.random_subsets[subset_i])\n for j in range(len(non_zero_f)):\n channel = non_zero_f[j]\n vector_index[channel] = 1\n self.selection_feature.append(vector_index)\n self.selection_feature = nn.Parameter(\n torch.stack(self.selection_feature, dim=0), requires_grad=False\n )\n self.shuffle_index1 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.shuffle_index2 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.matrix = torch.randn(self.input_dim, self.input_dim)\n self.q, self.r = torch.linalg.qr(self.matrix)\n self.q[:, -1] = 0\n self.q = nn.Parameter(self.q, requires_grad=False)", "probing input": " def generate_random_state(self):\n self.random_index = torch.tensor([i for i in torch.randperm(self.input_dim)])\n self.random_subsets = torch.chunk(self.random_index, self.subset_num, dim=0)\n self.selection_feature = []\n for subset_i in range(len(self.random_subsets)):\n vector_index = nn.Parameter(\n torch.zeros(self.input_dim), requires_grad=False\n )\n non_zero_f = sorted(self.random_subsets[subset_i])\n for j in range(len(non_zero_f)):\n channel = non_zero_f[j]\n vector_index[channel] = 1\n self.selection_feature.append(vector_index)\n self.selection_feature = nn.Parameter(\n torch.stack(self.selection_feature, dim=0), requires_grad=False\n )\n self.shuffle_index1 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.shuffle_index2 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.matrix = torch.randn(self.input_dim, self.input_dim)\n", "probing input new": " def generate_random_state(self):\n self.random_index = torch.tensor([i for i in torch.randperm(self.input_dim)])\n self.random_subsets = torch.chunk(self.random_index, self.subset_num, dim=0)\n self.selection_feature = []\n for subset_i in range(len(self.random_subsets)):\n vector_index = nn.Parameter(\n torch.zeros(self.input_dim), requires_grad=False\n )\n non_zero_f = sorted(self.random_subsets[subset_i])\n for j in range(len(non_zero_f)):\n channel = non_zero_f[j]\n vector_index[channel] = 1\n self.selection_feature.append(vector_index)\n self.selection_feature = nn.Parameter(\n torch.stack(self.selection_feature, dim=0), requires_grad=False\n )\n self.shuffle_index1 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.shuffle_index2 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.matrix = torch.randn(self.input_dim, self.input_dim)\n self.q, self.r = torch.", "reference": "self.q,self.r=torch.linalg.qr(self.matrix)", "reference dict": { "self.selection_feature": "nn.Parameter", "self.shuffle_index1": "nn.Parameter", "self.shuffle_index2": "nn.Parameter", "self.q": "nn.Parameter", "vector_index": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.q,self.r=torch.linalg.qr(self.matrix)", "y_neg": " self.q, self.r = torch.qr(self.matrix)", "retain": " def generate_random_state(self):\n self.random_index = torch.tensor([i for i in torch.randperm(self.input_dim)])\n self.random_subsets = torch.chunk(self.random_index, self.subset_num, dim=0)\n self.selection_feature = []\n for subset_i in range(len(self.random_subsets)):\n vector_index = nn.Parameter(\n torch.zeros(self.input_dim), requires_grad=False\n )\n non_zero_f = sorted(self.random_subsets[subset_i])\n for j in range(len(non_zero_f)):\n channel = non_zero_f[j]\n vector_index[channel] = 1\n self.selection_feature.append(vector_index)\n self.selection_feature = nn.Parameter(\n torch.stack(self.selection_feature, dim=0), requires_grad=False\n )\n self.shuffle_index1 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.shuffle_index2 = nn.Parameter(\n torch.randperm(self.input_dim), requires_grad=False\n )\n self.matrix = torch.randn(self.input_dim, self.input_dim)\n self.q, self.r = torch.linalg.qr(self.matrix)\n self.q[:, -1] = 0\n self.q = nn.Parameter(self.q, requires_grad=False)" }, { "id": 6581, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _decay_helper(\n svals,\n shape=(100, 100),\n rank=10,\n decay=0.5,\n symmetric=True,\n seed=0b1110101001010101011,\n dtype=torch.float64,\n device=\"cpu\",\n ):\n \"\"\"Given singular values, produces a random matrix.\n\n Helper method for the polynomial and exp-decay matrices. Given the\n singular values, it samples the left- and right- singular spaces,\n and returns the final matrix.\n \"\"\"\n min_shape = min(shape)\n # build singular bases using QR subgroup algorithm (Diaconis). QR is not\n # fastest, but these are test matrices so speed is not crucial.\n G_left = gaussian_noise(\n (shape[0], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed,\n dtype=dtype,\n device=device,\n )\n U, _ = torch.linalg.qr(G_left)\n del G_left\n #\n if symmetric:\n result = U @ torch.diag(svals) @ U.T\n else:\n G_right = gaussian_noise(\n (shape[1], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed + 1,\n dtype=dtype,\n device=device,\n )\n V, _ = torch.linalg.qr(G_right)\n result = U @ torch.diag(svals) @ V.T\n #\n return result", "probing input": " def _decay_helper(\n svals,\n shape=(100, 100),\n rank=10,\n decay=0.5,\n symmetric=True,\n seed=0b1110101001010101011,\n dtype=torch.float64,\n device=\"cpu\",\n ):\n \"\"\"Given singular values, produces a random matrix.\n\n Helper method for the polynomial and exp-decay matrices. Given the\n singular values, it samples the left- and right- singular spaces,\n and returns the final matrix.\n \"\"\"\n min_shape = min(shape)\n # build singular bases using QR subgroup algorithm (Diaconis). QR is not\n # fastest, but these are test matrices so speed is not crucial.\n G_left = gaussian_noise(\n (shape[0], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed,\n dtype=dtype,\n device=device,\n )\n", "probing input new": " def _decay_helper(\n svals,\n shape=(100, 100),\n rank=10,\n decay=0.5,\n symmetric=True,\n seed=0b1110101001010101011,\n dtype=torch.float64,\n device=\"cpu\",\n ):\n \"\"\"Given singular values, produces a random matrix.\n\n Helper method for the polynomial and exp-decay matrices. Given the\n singular values, it samples the left- and right- singular spaces,\n and returns the final matrix.\n \"\"\"\n min_shape = min(shape)\n # build singular bases using QR subgroup algorithm (Diaconis). QR is not\n # fastest, but these are test matrices so speed is not crucial.\n G_left = gaussian_noise(\n (shape[0], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed,\n dtype=dtype,\n device=device,\n )\n U, _ = torch.", "reference": "U,_=torch.linalg.qr(G_left)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "U,_=torch.linalg.qr(G_left)", "y_neg": " U, _ = torch.qr(G_left)", "retain": " def _decay_helper(\n svals,\n shape=(100, 100),\n rank=10,\n decay=0.5,\n symmetric=True,\n seed=0b1110101001010101011,\n dtype=torch.float64,\n device=\"cpu\",\n ):\n \"\"\"Given singular values, produces a random matrix.\n\n Helper method for the polynomial and exp-decay matrices. Given the\n singular values, it samples the left- and right- singular spaces,\n and returns the final matrix.\n \"\"\"\n min_shape = min(shape)\n # build singular bases using QR subgroup algorithm (Diaconis). QR is not\n # fastest, but these are test matrices so speed is not crucial.\n G_left = gaussian_noise(\n (shape[0], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed,\n dtype=dtype,\n device=device,\n )\n U, _ = torch.linalg.qr(G_left)\n del G_left\n #\n if symmetric:\n result = U @ torch.diag(svals) @ U.T\n else:\n G_right = gaussian_noise(\n (shape[1], min_shape),\n mean=0.0,\n std=1.0,\n seed=seed + 1,\n dtype=dtype,\n device=device,\n )\n V, _ = torch.linalg.qr(G_right)\n result = U @ torch.diag(svals) @ V.T\n #\n return result" }, { "id": 6582, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, dim):\n super().__init__()\n\n weight = torch.randn(dim, dim)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(0)\n self.weight = nn.Parameter(weight)", "probing input": " def __init__(self, dim):\n super().__init__()\n\n weight = torch.randn(dim, dim)\n", "probing input new": " def __init__(self, dim):\n super().__init__()\n\n weight = torch.randn(dim, dim)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(weight)", "reference dict": { "self.weight": "nn.Parameter" }, "alias dict": { "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(weight)", "y_neg": " q, _ = torch.qr(weight)", "retain": " def __init__(self, dim):\n super().__init__()\n\n weight = torch.randn(dim, dim)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(0)\n self.weight = nn.Parameter(weight)" }, { "id": 6585, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "user_weights = np.reshape(np.ones(nr_of_users*nr_of_samples_per_batch),(nr_of_samples_per_batch,nr_of_users,1))\nuser_weights = torch.as_tensor(user_weights)\nuser_weights_for_regular_WMMSE = np.ones(nr_of_users)\n#Q = torch.randn(32,32,dtype=torch.float)\nQ = torch.rand(32,32,dtype=torch.float)\nq, _ = torch.linalg.qr(Q)", "probing input": "user_weights = np.reshape(np.ones(nr_of_users*nr_of_samples_per_batch),(nr_of_samples_per_batch,nr_of_users,1))\nuser_weights = torch.as_tensor(user_weights)\nuser_weights_for_regular_WMMSE = np.ones(nr_of_users)\n#Q = torch.randn(32,32,dtype=torch.float)\nQ = torch.rand(32,32,dtype=torch.float)\n", "probing input new": "user_weights = np.reshape(np.ones(nr_of_users*nr_of_samples_per_batch),(nr_of_samples_per_batch,nr_of_users,1))\nuser_weights = torch.as_tensor(user_weights)\nuser_weights_for_regular_WMMSE = np.ones(nr_of_users)\n#Q = torch.randn(32,32,dtype=torch.float)\nQ = torch.rand(32,32,dtype=torch.float)\nq, _ = torch.", "reference": "q,_=torch.linalg.qr(Q)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(Q)", "y_neg": "q, _ = torch.qr(Q)", "retain": "user_weights = np.reshape(np.ones(nr_of_users*nr_of_samples_per_batch),(nr_of_samples_per_batch,nr_of_users,1))\nuser_weights = torch.as_tensor(user_weights)\nuser_weights_for_regular_WMMSE = np.ones(nr_of_users)\n#Q = torch.randn(32,32,dtype=torch.float)\nQ = torch.rand(32,32,dtype=torch.float)\nq, _ = torch.linalg.qr(Q)" }, { "id": 6586, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_ortho(n, m, std):\n q, _ = torch.linalg.qr(torch.randn(n, m) * std)\n return q", "probing input": "def random_ortho(n, m, std):\n", "probing input new": "def random_ortho(n, m, std):\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(torch.randn(n,m)*std)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(torch.randn(n,m)*std)", "y_neg": " q, _ = torch.qr(torch.randn(m, n))", "retain": "def random_ortho(n, m, std):\n q, _ = torch.linalg.qr(torch.randn(n, m) * std)\n return q" }, { "id": 6587, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "bad = torch.qr()\ngood = torch.linalg.qr()", "probing input": "bad = torch.qr()\n", "probing input new": "bad = torch.qr()\ngood = torch.", "reference": "good=torch.linalg.qr()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "tt.potri": "torch.potri", "tt.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "tt.potrs": "torch.potrs", "tt.qr": "torch.qr", "tt.lu_solve": "torch.lu_solve", "tt.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "tt.symeig": "torch.symeig", "tt.func.functional_call": "torch.func.functional_call", "tt.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "tt.solve": "torch.solve", "tt.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "tt.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "tt.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "tt.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "tt.lu_unpack": "torch.lu_unpack", "tt.btrisolve": "torch.btrisolve", "tt.linalg.lu_factor": "torch.linalg.lu_factor", "tt.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "tt.linalg.matrix_rank": "torch.linalg.matrix_rank", "tt.norm": "torch.norm", "tt.cholesky_solve": "torch.cholesky_solve", "tt.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "tt.testing.assert_allclose": "torch.testing.assert_allclose", "tt.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "tt.gels": "torch.gels", "tt.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "tt.chain_matmul": "torch.chain_matmul", "tt.lu": "torch.lu", "tt.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "tt.pstrf": "torch.pstrf", "tt.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "tt.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "tt.linalg.eigh": "torch.linalg.eigh", "tt.btrifact": "torch.btrifact", "tt.linalg.lu_solve": "torch.linalg.lu_solve", "tt.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "tt.linalg.multi_dot": "torch.linalg.multi_dot", "tt.gesv": "torch.gesv", "tt.btrifact_with_info": "torch.btrifact_with_info", "tt.linalg.solve": "torch.linalg.solve", "tt.linalg.eig": "torch.linalg.eig", "tt.linalg.cholesky": "torch.linalg.cholesky", "tt.trtrs": "torch.trtrs", "tt.linalg.solve_triangular": "torch.linalg.solve_triangular", "tt.matrix_rank": "torch.matrix_rank", "tt.triangular_solve": "torch.triangular_solve", "tt.linalg.qr": "torch.linalg.qr", "tt.svd": "torch.svd", "tt.lstsq": "torch.lstsq", "tt.nn.functional.interpolate": "torch.nn.functional.interpolate", "tt.potrf": "torch.potrf", "tt.linalg.svd": "torch.linalg.svd", "tt.btriunpack": "torch.btriunpack", "tt.eig": "torch.eig", "tt.cholesky_inverse": "torch.cholesky_inverse", "tt.testing.assert_close": "torch.testing.assert_close", "tt.cholesky": "torch.cholesky", "tt.nn.functional.upsample": "torch.nn.functional.upsample", "tt.linalg.norm": "torch.linalg.norm", "tt.linalg.lstsq": "torch.linalg.lstsq", "linalg.qr": "torch.linalg.qr", "linalg.lu_factor": "torch.linalg.lu_factor", "linalg.matrix_rank": "torch.linalg.matrix_rank", "linalg.eigh": "torch.linalg.eigh", "linalg.svd": "torch.linalg.svd", "linalg.lu_solve": "torch.linalg.lu_solve", "linalg.multi_dot": "torch.linalg.multi_dot", "linalg.solve": "torch.linalg.solve", "linalg.eig": "torch.linalg.eig", "linalg.cholesky": "torch.linalg.cholesky", "linalg.norm": "torch.linalg.norm", "linalg.lstsq": "torch.linalg.lstsq", "linalg.solve_triangular": "torch.linalg.solve_triangular", "qr": "torch.qr", "old_qr": "torch.qr", "new_qr": "torch.linalg.qr" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "good=torch.linalg.qr()", "y_neg": "good = torch.qr(rcond=1e-6)", "retain": "bad = torch.qr()\ngood = torch.linalg.qr()" }, { "id": 6592, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_unitary(n, device: Optional[torch.device] = None):\n \"\"\"\n Returns random unitary matrix from the Haar measure of size n x n.\n \n Unitary matrix is created as described in this `paper\n `_.\n \"\"\"\n mat = torch.randn(n, n, device=device)\n q, r = torch.linalg.qr(mat)\n d = torch.diagonal(r)\n ph = d / d.abs()\n q = q @ torch.diag(ph)\n return q", "probing input": "def random_unitary(n, device: Optional[torch.device] = None):\n \"\"\"\n Returns random unitary matrix from the Haar measure of size n x n.\n \n Unitary matrix is created as described in this `paper\n `_.\n \"\"\"\n mat = torch.randn(n, n, device=device)\n", "probing input new": "def random_unitary(n, device: Optional[torch.device] = None):\n \"\"\"\n Returns random unitary matrix from the Haar measure of size n x n.\n \n Unitary matrix is created as described in this `paper\n `_.\n \"\"\"\n mat = torch.randn(n, n, device=device)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(mat)", "y_neg": " q, r = torch.qr(mat)", "retain": "def random_unitary(n, device: Optional[torch.device] = None):\n \"\"\"\n Returns random unitary matrix from the Haar measure of size n x n.\n \n Unitary matrix is created as described in this `paper\n `_.\n \"\"\"\n mat = torch.randn(n, n, device=device)\n q, r = torch.linalg.qr(mat)\n d = torch.diagonal(r)\n ph = d / d.abs()\n q = q @ torch.diag(ph)\n return q" }, { "id": 6594, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # Originally used the deprecated torch.qr(unstructured_block.cpu())\n q, r = torch.linalg.qr(unstructured_block.cpu())\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()", "probing input": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # Originally used the deprecated torch.qr(unstructured_block.cpu())\n", "probing input new": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # Originally used the deprecated torch.qr(unstructured_block.cpu())\n q, r = torch.", "reference": "q,r=torch.linalg.qr(unstructured_block.cpu())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(unstructured_block.cpu())", "y_neg": " q, r = torch.qr(unstructured_block)", "retain": "def orthogonal_matrix_chunk(cols, device=None):\n unstructured_block = torch.randn((cols, cols), device=device)\n # Originally used the deprecated torch.qr(unstructured_block.cpu())\n q, r = torch.linalg.qr(unstructured_block.cpu())\n q, r = map(lambda t: t.to(device), (q, r))\n return q.t()" }, { "id": 6596, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n\n if orthonormal:\n self.scramble, _ = torch.linalg.qr(torch.randn(self.dim, self.dim))\n else:\n self.scramble = 10 * torch.randn(self.dim, self.dim)", "probing input": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n\n if orthonormal:\n", "probing input new": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n\n if orthonormal:\n self.scramble, _ = torch.", "reference": "self.scramble,_=torch.linalg.qr(torch.randn(self.dim,self.dim))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.scramble,_=torch.linalg.qr(torch.randn(self.dim,self.dim))", "y_neg": " self.scramble, _ = torch.qr(torch.randn(dim_inv, dim_spu))", "retain": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n\n if orthonormal:\n self.scramble, _ = torch.linalg.qr(torch.randn(self.dim, self.dim))\n else:\n self.scramble = 10 * torch.randn(self.dim, self.dim)" }, { "id": 6598, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n if orthonormal:\n self.scramble, _ = torch.linalg.qr(torch.randn(self.dim, self.dim))\n else:\n self.scramble = 10 * torch.randn(self.dim, self.dim)", "probing input": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n if orthonormal:\n", "probing input new": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n if orthonormal:\n self.scramble, _ = torch.", "reference": "self.scramble,_=torch.linalg.qr(torch.randn(self.dim,self.dim))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "self.scramble,_=torch.linalg.qr(torch.randn(self.dim,self.dim))", "y_neg": " self.scramble, _ = torch.qr(torch.randn(dim_inv, dim_spu))", "retain": " def __init__(self, dim_inv, dim_spu, n_envs, orthonormal=True, **kwargs):\n super().__init__(dim_inv, dim_spu, n_envs, **kwargs)\n if orthonormal:\n self.scramble, _ = torch.linalg.qr(torch.randn(self.dim, self.dim))\n else:\n self.scramble = 10 * torch.randn(self.dim, self.dim)" }, { "id": 6602, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, channel):\n \"\"\" Invertible MLP \"\"\"\n super().__init__()\n\n weight = torch.randn(channel, channel)\n bias = torch.randn(1, channel, 1, 1)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(2).unsqueeze(3)\n self.weight = nn.Parameter(weight)\n self.bias = nn.Parameter(bias)", "probing input": " def __init__(self, channel):\n \"\"\" Invertible MLP \"\"\"\n super().__init__()\n\n weight = torch.randn(channel, channel)\n bias = torch.randn(1, channel, 1, 1)\n", "probing input new": " def __init__(self, channel):\n \"\"\" Invertible MLP \"\"\"\n super().__init__()\n\n weight = torch.randn(channel, channel)\n bias = torch.randn(1, channel, 1, 1)\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(weight)", "reference dict": { "self.weight": "nn.Parameter", "self.bias": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(weight)", "y_neg": " q, _ = torch.qr(weight)", "retain": " def __init__(self, channel):\n \"\"\" Invertible MLP \"\"\"\n super().__init__()\n\n weight = torch.randn(channel, channel)\n bias = torch.randn(1, channel, 1, 1)\n q, _ = torch.linalg.qr(weight)\n weight = q.unsqueeze(2).unsqueeze(3)\n self.weight = nn.Parameter(weight)\n self.bias = nn.Parameter(bias)" }, { "id": 6603, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def rand_phase(self, n=1):\n qr = torch.randn((n, self.n, self.n),device=device, dtype=dtype)\n q, r = torch.linalg.qr(qr)\n r_diag_sign = torch.sign(torch.diagonal(r, dim1=-2, dim2=-1))\n q *= r_diag_sign[:, None]\n q_det_sign = torch.sign(torch.det(q))\n q[:, :, 0] *= q_det_sign[:, None]\n return q", "probing input": " def rand_phase(self, n=1):\n qr = torch.randn((n, self.n, self.n),device=device, dtype=dtype)\n", "probing input new": " def rand_phase(self, n=1):\n qr = torch.randn((n, self.n, self.n),device=device, dtype=dtype)\n q, r = torch.", "reference": "q,r=torch.linalg.qr(qr)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(qr)", "y_neg": " q, r = torch.qr(qr)", "retain": " def rand_phase(self, n=1):\n qr = torch.randn((n, self.n, self.n),device=device, dtype=dtype)\n q, r = torch.linalg.qr(qr)\n r_diag_sign = torch.sign(torch.diagonal(r, dim1=-2, dim2=-1))\n q *= r_diag_sign[:, None]\n q_det_sign = torch.sign(torch.det(q))\n q[:, :, 0] *= q_det_sign[:, None]\n return q" }, { "id": 6606, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def qr(x: B.TorchNumeric, mode=\"reduced\"):\n \"\"\"\n Return a QR decomposition of a matrix x.\n \"\"\"\n Q, R = torch.linalg.qr(x, mode=mode)\n return Q, R", "probing input": "def qr(x: B.TorchNumeric, mode=\"reduced\"):\n \"\"\"\n Return a QR decomposition of a matrix x.\n \"\"\"\n", "probing input new": "def qr(x: B.TorchNumeric, mode=\"reduced\"):\n \"\"\"\n Return a QR decomposition of a matrix x.\n \"\"\"\n Q, R = torch.", "reference": "Q,R=torch.linalg.qr(x,mode=mode)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "Q,R=torch.linalg.qr(x,mode=mode)", "y_neg": " Q, R = torch.qr(x)", "retain": "def qr(x: B.TorchNumeric, mode=\"reduced\"):\n \"\"\"\n Return a QR decomposition of a matrix x.\n \"\"\"\n Q, R = torch.linalg.qr(x, mode=mode)\n return Q, R" }, { "id": 6608, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def project_jac_to_manifold(jac, x_in, x_out, manifold):\n bases = []\n # Compute a basis each for x, z, and x1\n for pos in [x_in, x_out]:\n bs, dim = pos.shape[0], prod(pos.shape[1:])\n # This is a (bs, dim, manifold_dim) tensor\n tangents = torch.stack([\n random_tangent_vec(manifold, pos, n_samples=bs).reshape(bs, dim)\n for _ in range(manifold.dim)\n ], -1)\n basis, _ = torch.linalg.qr(tangents)\n bases.append(basis)\n x_in_basis, x_out_basis = bases\n\n # Project the Jacobian after reshaping to bs x out_dim x in_dim\n x_in_dim = prod(x_in.shape[1:])\n x_out_dim = prod(x_out.shape[1:])\n jac_vec = jac.reshape(jac.shape[0], x_out_dim, x_in_dim)\n return torch.bmm(\n torch.bmm(x_out_basis.transpose(-1, -2), jac_vec),\n x_in_basis\n )", "probing input": "def project_jac_to_manifold(jac, x_in, x_out, manifold):\n bases = []\n # Compute a basis each for x, z, and x1\n for pos in [x_in, x_out]:\n bs, dim = pos.shape[0], prod(pos.shape[1:])\n # This is a (bs, dim, manifold_dim) tensor\n tangents = torch.stack([\n random_tangent_vec(manifold, pos, n_samples=bs).reshape(bs, dim)\n for _ in range(manifold.dim)\n ], -1)\n", "probing input new": "def project_jac_to_manifold(jac, x_in, x_out, manifold):\n bases = []\n # Compute a basis each for x, z, and x1\n for pos in [x_in, x_out]:\n bs, dim = pos.shape[0], prod(pos.shape[1:])\n # This is a (bs, dim, manifold_dim) tensor\n tangents = torch.stack([\n random_tangent_vec(manifold, pos, n_samples=bs).reshape(bs, dim)\n for _ in range(manifold.dim)\n ], -1)\n basis, _ = torch.", "reference": "basis,_=torch.linalg.qr(tangents)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "basis,_=torch.linalg.qr(tangents)", "y_neg": " basis, _ = torch.qr(tangents)", "retain": "def project_jac_to_manifold(jac, x_in, x_out, manifold):\n bases = []\n # Compute a basis each for x, z, and x1\n for pos in [x_in, x_out]:\n bs, dim = pos.shape[0], prod(pos.shape[1:])\n # This is a (bs, dim, manifold_dim) tensor\n tangents = torch.stack([\n random_tangent_vec(manifold, pos, n_samples=bs).reshape(bs, dim)\n for _ in range(manifold.dim)\n ], -1)\n basis, _ = torch.linalg.qr(tangents)\n bases.append(basis)\n x_in_basis, x_out_basis = bases\n\n # Project the Jacobian after reshaping to bs x out_dim x in_dim\n x_in_dim = prod(x_in.shape[1:])\n x_out_dim = prod(x_out.shape[1:])\n jac_vec = jac.reshape(jac.shape[0], x_out_dim, x_in_dim)\n return torch.bmm(\n torch.bmm(x_out_basis.transpose(-1, -2), jac_vec),\n x_in_basis\n )" }, { "id": 6609, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _random_ortho(n: int, m: int) -> torch.Tensor:\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q", "probing input": "def _random_ortho(n: int, m: int) -> torch.Tensor:\n", "probing input new": "def _random_ortho(n: int, m: int) -> torch.Tensor:\n q, _ = torch.", "reference": "q,_=torch.linalg.qr(torch.randn(n,m))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,_=torch.linalg.qr(torch.randn(n,m))", "y_neg": " q, _ = torch.qr(torch.randn(m, n))", "retain": "def _random_ortho(n: int, m: int) -> torch.Tensor:\n q, _ = torch.linalg.qr(torch.randn(n, m))\n return q" }, { "id": 6610, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orthogonal_(tensor: torch.Tensor, gain: float = 1) -> torch.Tensor:\n \"\"\"\n **Overview**:\n Fills the input ``Tensor`` with a (semi) orthogonal matrix, as described in this paper .\n The input tensor must have at least 2 dimensions, and for tensors with more than 2 dimensions the trailing dimensions are flattened.\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n # Initialize a new tensor with normal distribution. The shape is the same as the input tensor.\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n # If rows < cols, transpose the original tensor for computational efficiency.\n if rows < cols:\n flattened.t_()\n\n # Compute the QR factorization, Q is an orthogonal matrix and R is an upper triangular matrix.\n # \n q, r = torch.linalg.qr(flattened)\n # Although Q is orthogonal, each value of Q is not uniformly distributed. To make Q uniform, we can use the equation below: $$Q^* = Q sign(diag(R))$$. Proof for this equation can be viewed in this paper: .\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n # If rows < cols, transpose the output tensor to match the shape of original tensor.\n if rows < cols:\n q.t_()\n\n # Using ``torch.no_grad()`` here can make sure that these operations won't be added to the computational graph used by PyTorch's autograd system, thus improving efficiency.\n with torch.no_grad():\n # Reshape the result and copy the weight from q.\n tensor.view_as(q).copy_(q)\n # Multiply an optional scaling factor.\n tensor.mul_(gain)\n return tensor", "probing input": "def orthogonal_(tensor: torch.Tensor, gain: float = 1) -> torch.Tensor:\n \"\"\"\n **Overview**:\n Fills the input ``Tensor`` with a (semi) orthogonal matrix, as described in this paper .\n The input tensor must have at least 2 dimensions, and for tensors with more than 2 dimensions the trailing dimensions are flattened.\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n # Initialize a new tensor with normal distribution. The shape is the same as the input tensor.\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n # If rows < cols, transpose the original tensor for computational efficiency.\n if rows < cols:\n flattened.t_()\n\n # Compute the QR factorization, Q is an orthogonal matrix and R is an upper triangular matrix.\n # \n", "probing input new": "def orthogonal_(tensor: torch.Tensor, gain: float = 1) -> torch.Tensor:\n \"\"\"\n **Overview**:\n Fills the input ``Tensor`` with a (semi) orthogonal matrix, as described in this paper .\n The input tensor must have at least 2 dimensions, and for tensors with more than 2 dimensions the trailing dimensions are flattened.\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n # Initialize a new tensor with normal distribution. The shape is the same as the input tensor.\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n # If rows < cols, transpose the original tensor for computational efficiency.\n if rows < cols:\n flattened.t_()\n\n # Compute the QR factorization, Q is an orthogonal matrix and R is an upper triangular matrix.\n # \n q, r = torch.", "reference": "q,r=torch.linalg.qr(flattened)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(flattened)", "y_neg": " q, r = torch.qr(flattened)", "retain": "def orthogonal_(tensor: torch.Tensor, gain: float = 1) -> torch.Tensor:\n \"\"\"\n **Overview**:\n Fills the input ``Tensor`` with a (semi) orthogonal matrix, as described in this paper .\n The input tensor must have at least 2 dimensions, and for tensors with more than 2 dimensions the trailing dimensions are flattened.\n \"\"\"\n if tensor.ndimension() < 2:\n raise ValueError(\"Only tensors with 2 or more dimensions are supported\")\n\n # Initialize a new tensor with normal distribution. The shape is the same as the input tensor.\n rows = tensor.size(0)\n cols = tensor.numel() // rows\n flattened = tensor.new(rows, cols).normal_(0, 1)\n\n # If rows < cols, transpose the original tensor for computational efficiency.\n if rows < cols:\n flattened.t_()\n\n # Compute the QR factorization, Q is an orthogonal matrix and R is an upper triangular matrix.\n # \n q, r = torch.linalg.qr(flattened)\n # Although Q is orthogonal, each value of Q is not uniformly distributed. To make Q uniform, we can use the equation below: $$Q^* = Q sign(diag(R))$$. Proof for this equation can be viewed in this paper: .\n d = torch.diag(r, 0)\n ph = d.sign()\n q *= ph\n\n # If rows < cols, transpose the output tensor to match the shape of original tensor.\n if rows < cols:\n q.t_()\n\n # Using ``torch.no_grad()`` here can make sure that these operations won't be added to the computational graph used by PyTorch's autograd system, thus improving efficiency.\n with torch.no_grad():\n # Reshape the result and copy the weight from q.\n tensor.view_as(q).copy_(q)\n # Multiply an optional scaling factor.\n tensor.mul_(gain)\n return tensor" }, { "id": 6611, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def rsample(self, nsamples: int) -> Tensor:\n \"\"\"Produces n uniform samples over SU(self.dim).\"\"\"\n final = torch.zeros(nsamples, self.dim, self.dim).to(torch.complex64)\n for k in range(nsamples):\n z = torch.complex(\n torch.randn(self.dim, self.dim),\n torch.randn(self.dim, self.dim),\n )\n q, r = torch.linalg.qr(z / np.sqrt(2.0))\n diag = r.diag()\n ph = diag / diag.abs()\n q = q * ph * q\n q = q / (q.det() ** (1 / self.dim))\n final[k] = q\n return final", "probing input": " def rsample(self, nsamples: int) -> Tensor:\n \"\"\"Produces n uniform samples over SU(self.dim).\"\"\"\n final = torch.zeros(nsamples, self.dim, self.dim).to(torch.complex64)\n for k in range(nsamples):\n z = torch.complex(\n torch.randn(self.dim, self.dim),\n torch.randn(self.dim, self.dim),\n )\n", "probing input new": " def rsample(self, nsamples: int) -> Tensor:\n \"\"\"Produces n uniform samples over SU(self.dim).\"\"\"\n final = torch.zeros(nsamples, self.dim, self.dim).to(torch.complex64)\n for k in range(nsamples):\n z = torch.complex(\n torch.randn(self.dim, self.dim),\n torch.randn(self.dim, self.dim),\n )\n q, r = torch.", "reference": "q,r=torch.linalg.qr(z/np.sqrt(2.0))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.qr" ], "replacement api": "torch.linalg.qr", "expected call": "torch.linalg.qr", "y_pos": "q,r=torch.linalg.qr(z/np.sqrt(2.0))", "y_neg": " q, r = torch.qr(z)", "retain": " def rsample(self, nsamples: int) -> Tensor:\n \"\"\"Produces n uniform samples over SU(self.dim).\"\"\"\n final = torch.zeros(nsamples, self.dim, self.dim).to(torch.complex64)\n for k in range(nsamples):\n z = torch.complex(\n torch.randn(self.dim, self.dim),\n torch.randn(self.dim, self.dim),\n )\n q, r = torch.linalg.qr(z / np.sqrt(2.0))\n diag = r.diag()\n ph = diag / diag.abs()\n q = q * ph * q\n q = q / (q.det() ** (1 / self.dim))\n final[k] = q\n return final" }, { "id": 6616, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, a):\n vals, vecs = torch.linalg.eigh(a)\n ctx.save_for_backward(vals, vecs)\n return vecs @ vals.abs().sqrt().diag_embed() @ vecs.transpose(-2, -1)", "probing input": " def forward(ctx, a):\n", "probing input new": " def forward(ctx, a):\n vals, vecs = torch.", "reference": "vals,vecs=torch.linalg.eigh(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "vals,vecs=torch.linalg.eigh(a)", "y_neg": " vals, vecs = torch.symeig(a, eigenvectors=True)", "retain": " def forward(ctx, a):\n vals, vecs = torch.linalg.eigh(a)\n ctx.save_for_backward(vals, vecs)\n return vecs @ vals.abs().sqrt().diag_embed() @ vecs.transpose(-2, -1)" }, { "id": 6617, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.linalg.eigh((1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2))\n return vectors[..., -1]", "probing input": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n", "probing input new": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh((1.0/3.0)*torch.stack([torch.stack(t,dim=-1)fortink],dim=-2))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh((1.0/3.0)*torch.stack([torch.stack(t,dim=-1)fortink],dim=-2))", "y_neg": " _, vectors = torch.symeig(torch.tensor(k), eigenvectors=True)", "retain": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.linalg.eigh((1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2))\n return vectors[..., -1]" }, { "id": 6620, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def matrix_sqrt(M, thresh=False):\n S, V = torch.linalg.eigh(M.cuda())\n S[S<0] = 0\n\n if thresh:\n k = int(3*len(S)//4)\n print(\"Thresh k:\",k)\n S[:k] = 0\n\n S = torch.diag(S**0.5)\n return (V @ S @ V.T).cpu()", "probing input": "def matrix_sqrt(M, thresh=False):\n", "probing input new": "def matrix_sqrt(M, thresh=False):\n S, V = torch.", "reference": "S,V=torch.linalg.eigh(M.cuda())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "S,V=torch.linalg.eigh(M.cuda())", "y_neg": " S, V = torch.symeig(M, eigenvectors=True)", "retain": "def matrix_sqrt(M, thresh=False):\n S, V = torch.linalg.eigh(M.cuda())\n S[S<0] = 0\n\n if thresh:\n k = int(3*len(S)//4)\n print(\"Thresh k:\",k)\n S[:k] = 0\n\n S = torch.diag(S**0.5)\n return (V @ S @ V.T).cpu()" }, { "id": 6621, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]", "probing input": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n", "probing input new": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]" }, { "id": 6626, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if (rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [xx + yy + zz, zy - yz, xz - zx, yx - xy, ],\n [zy - yz, xx - yy - zz, xy + yx, xz + zx, ],\n [xz - zx, xy + yx, yy - xx - zz, yz + zy, ],\n [yx - xy, xz + zx, yz + zy, zz - xx - yy, ]\n ]\n\n k = (1. / 3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]", "probing input": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if (rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [xx + yy + zz, zy - yz, xz - zx, yx - xy, ],\n [zy - yz, xx - yy - zz, xy + yx, xz + zx, ],\n [xz - zx, xy + yx, yy - xx - zz, yz + zy, ],\n [yx - xy, xz + zx, yz + zy, zz - xx - yy, ]\n ]\n\n k = (1. / 3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n", "probing input new": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if (rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [xx + yy + zz, zy - yz, xz - zx, yx - xy, ],\n [zy - yz, xx - yy - zz, xy + yx, xz + zx, ],\n [xz - zx, xy + yx, yy - xx - zz, yz + zy, ],\n [yx - xy, xz + zx, yz + zy, zz - xx - yy, ]\n ]\n\n k = (1. / 3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if (rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [xx + yy + zz, zy - yz, xz - zx, yx - xy, ],\n [zy - yz, xx - yy - zz, xy + yx, xz + zx, ],\n [xz - zx, xy + yx, yy - xx - zz, yz + zy, ],\n [yx - xy, xz + zx, yz + zy, zz - xx - yy, ]\n ]\n\n k = (1. / 3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]" }, { "id": 6627, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_svqb(U, edge):\n tau = 1.2e-07\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz) == 1, nz\n if len(nz[0]) < len(d):\n U = U[:, nz[0]]\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz[0]) == len(d)\n d_col = (d ** -0.5).reshape(d.shape[0], 1)\n DUBUD = (UBU * d_col) * d_col.T\n E, Z = torch.linalg.eigh(DUBUD, UPLO='U')\n t = tau * abs(E).max()\n keep = torch.where(E > t)\n assert len(keep) == 1, keep\n E = E[keep[0]]\n Z = Z[:, keep[0]]\n # check_shape(U, d_col, Z, E, (U * d_col.T), (Z * E ** -0.5))\n U = (U * d_col.T) @ (Z * E ** -0.5)\n UAU = U.T @ A(U, edge)\n E, Z = torch.linalg.eigh(UAU, UPLO='U')\n return U @ Z[:, :n ], E[:n]", "probing input": "def get_svqb(U, edge):\n tau = 1.2e-07\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz) == 1, nz\n if len(nz[0]) < len(d):\n U = U[:, nz[0]]\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz[0]) == len(d)\n d_col = (d ** -0.5).reshape(d.shape[0], 1)\n DUBUD = (UBU * d_col) * d_col.T\n", "probing input new": "def get_svqb(U, edge):\n tau = 1.2e-07\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz) == 1, nz\n if len(nz[0]) < len(d):\n U = U[:, nz[0]]\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz[0]) == len(d)\n d_col = (d ** -0.5).reshape(d.shape[0], 1)\n DUBUD = (UBU * d_col) * d_col.T\n E, Z = torch.", "reference": "E,Z=torch.linalg.eigh(DUBUD,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "E,Z=torch.linalg.eigh(DUBUD,UPLO='U')", "y_neg": " E, Z = torch.symeig(DUBUD, eigenvectors=True)", "retain": "def get_svqb(U, edge):\n tau = 1.2e-07\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz) == 1, nz\n if len(nz[0]) < len(d):\n U = U[:, nz[0]]\n UBU = U.T @ B(U, edge)\n d = UBU.diagonal(0, -2, -1)\n nz = torch.where(abs(d) != 0.0)\n assert len(nz[0]) == len(d)\n d_col = (d ** -0.5).reshape(d.shape[0], 1)\n DUBUD = (UBU * d_col) * d_col.T\n E, Z = torch.linalg.eigh(DUBUD, UPLO='U')\n t = tau * abs(E).max()\n keep = torch.where(E > t)\n assert len(keep) == 1, keep\n E = E[keep[0]]\n Z = Z[:, keep[0]]\n # check_shape(U, d_col, Z, E, (U * d_col.T), (Z * E ** -0.5))\n U = (U * d_col.T) @ (Z * E ** -0.5)\n UAU = U.T @ A(U, edge)\n E, Z = torch.linalg.eigh(UAU, UPLO='U')\n return U @ Z[:, :n ], E[:n]" }, { "id": 6629, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n,c,h,w = patches.shape\n est_covariance = torch.cov(patches.view(n, c*h*w).t())\n eigenvalues, eigenvectors = torch.linalg.eigh(est_covariance, UPLO='U') # this is the same as saying we want our eigenvectors, with the specification that the matrix be an upper triangular matrix (instead of a lower-triangular matrix)\n return eigenvalues.flip(0).view(-1, 1, 1, 1), eigenvectors.t().reshape(c*h*w,c,h,w).flip(0)", "probing input": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n,c,h,w = patches.shape\n est_covariance = torch.cov(patches.view(n, c*h*w).t())\n", "probing input new": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n,c,h,w = patches.shape\n est_covariance = torch.cov(patches.view(n, c*h*w).t())\n eigenvalues, eigenvectors = torch.", "reference": "eigenvalues,eigenvectors=torch.linalg.eigh(est_covariance,UPLO='U')", "reference dict": { "loss_fn": "nn.CrossEntropyLoss" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,eigenvectors=torch.linalg.eigh(est_covariance,UPLO='U')", "y_neg": " eigenvalues, eigenvectors = torch.symeig(est_covariance, eigenvectors=True)", "retain": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n,c,h,w = patches.shape\n est_covariance = torch.cov(patches.view(n, c*h*w).t())\n eigenvalues, eigenvectors = torch.linalg.eigh(est_covariance, UPLO='U') # this is the same as saying we want our eigenvectors, with the specification that the matrix be an upper triangular matrix (instead of a lower-triangular matrix)\n return eigenvalues.flip(0).view(-1, 1, 1, 1), eigenvectors.t().reshape(c*h*w,c,h,w).flip(0)" }, { "id": 6632, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def symeig(M):\n \"\"\"Symetric eigendecomposition avoiding failure cases by\n adding and removing jitter to the diagonal.\n\n Parameters\n ----------\n M : torch.Tensor\n\n Returns\n -------\n L : torch.Tensor\n eigenvalues\n W : torch.Tensor\n eigenvectors\n \"\"\"\n try:\n L, W = torch.linalg.eigh(M, UPLO='U')\n except RuntimeError: # did not converge\n logging.info('SYMEIG: adding jitter, did not converge.')\n # use W L W^T + I = W (L + I) W^T\n M = M + torch.eye(M.shape[0], device=M.device)\n try:\n L, W = torch.linalg.eigh(M, UPLO='U')\n L -= 1.\n except RuntimeError:\n stats = f'diag: {M.diagonal()}, max: {M.abs().max()}, '\n stats = stats + f'min: {M.abs().min()}, mean: {M.abs().mean()}'\n logging.info(f'SYMEIG: adding jitter failed. Stats: {stats}')\n exit()\n # eigenvalues of symeig at least 0\n L = L.clamp(min=0.0)\n L = torch.nan_to_num(L)\n W = torch.nan_to_num(W)\n return L, W", "probing input": "def symeig(M):\n \"\"\"Symetric eigendecomposition avoiding failure cases by\n adding and removing jitter to the diagonal.\n\n Parameters\n ----------\n M : torch.Tensor\n\n Returns\n -------\n L : torch.Tensor\n eigenvalues\n W : torch.Tensor\n eigenvectors\n \"\"\"\n try:\n", "probing input new": "def symeig(M):\n \"\"\"Symetric eigendecomposition avoiding failure cases by\n adding and removing jitter to the diagonal.\n\n Parameters\n ----------\n M : torch.Tensor\n\n Returns\n -------\n L : torch.Tensor\n eigenvalues\n W : torch.Tensor\n eigenvectors\n \"\"\"\n try:\n L, W = torch.", "reference": "L,W=torch.linalg.eigh(M,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,W=torch.linalg.eigh(M,UPLO='U')", "y_neg": " L, W = torch.symeig(M, eigenvectors=True)", "retain": "def symeig(M):\n \"\"\"Symetric eigendecomposition avoiding failure cases by\n adding and removing jitter to the diagonal.\n\n Parameters\n ----------\n M : torch.Tensor\n\n Returns\n -------\n L : torch.Tensor\n eigenvalues\n W : torch.Tensor\n eigenvectors\n \"\"\"\n try:\n L, W = torch.linalg.eigh(M, UPLO='U')\n except RuntimeError: # did not converge\n logging.info('SYMEIG: adding jitter, did not converge.')\n # use W L W^T + I = W (L + I) W^T\n M = M + torch.eye(M.shape[0], device=M.device)\n try:\n L, W = torch.linalg.eigh(M, UPLO='U')\n L -= 1.\n except RuntimeError:\n stats = f'diag: {M.diagonal()}, max: {M.abs().max()}, '\n stats = stats + f'min: {M.abs().min()}, mean: {M.abs().mean()}'\n logging.info(f'SYMEIG: adding jitter failed. Stats: {stats}')\n exit()\n # eigenvalues of symeig at least 0\n L = L.clamp(min=0.0)\n L = torch.nan_to_num(L)\n W = torch.nan_to_num(W)\n return L, W" }, { "id": 6637, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def fit(K:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n K (Tensor[float]): the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of K)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), K.shape[0], *yb.shape[1:]), device=K.device)\n w, v = torch.linalg.eigh(K[mb][:,mb])\n d = torch.mean(torch.diag(K))\n shape = (-1, 1) if len(yb.shape) >= 2 else (-1,)\n temp = v.T @ yb\n for i, eps in enumerate(nugget):\n fitted[i] = K[:,mb] @ (v @ (temp/(w+eps*d).view(shape)))\n return fitted[0] if len(nugget) == 1 else fitted", "probing input": "def fit(K:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n K (Tensor[float]): the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of K)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), K.shape[0], *yb.shape[1:]), device=K.device)\n", "probing input new": "def fit(K:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n K (Tensor[float]): the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of K)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), K.shape[0], *yb.shape[1:]), device=K.device)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(K[mb][:,mb])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(K[mb][:,mb])", "y_neg": " w, v = torch.symeig(K, eigenvectors=True)", "retain": "def fit(K:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n K (Tensor[float]): the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of K)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), K.shape[0], *yb.shape[1:]), device=K.device)\n w, v = torch.linalg.eigh(K[mb][:,mb])\n d = torch.mean(torch.diag(K))\n shape = (-1, 1) if len(yb.shape) >= 2 else (-1,)\n temp = v.T @ yb\n for i, eps in enumerate(nugget):\n fitted[i] = K[:,mb] @ (v @ (temp/(w+eps*d).view(shape)))\n return fitted[0] if len(nugget) == 1 else fitted" }, { "id": 6638, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def fit_Nystrom(Q:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n Q (Tensor[float]): square root of the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of QQ^T)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), Q.shape[0], *yb.shape[1:]), device=Q.device)\n w, v = torch.linalg.eigh(Q[mb].T @ Q[mb])\n d = torch.mean(torch.sum(Q**2, 1))\n shape = (-1, 1) if len(yb.shape) >= 2 else (-1,)\n temp = v.T @ (Q[mb].T @ yb)\n for i, eps in enumerate(nugget):\n fitted[i] = Q @ (v @ (temp/(w+eps*d).view(shape)))\n return fitted[0] if len(nugget) == 1 else fitted", "probing input": "def fit_Nystrom(Q:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n Q (Tensor[float]): square root of the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of QQ^T)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), Q.shape[0], *yb.shape[1:]), device=Q.device)\n", "probing input new": "def fit_Nystrom(Q:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n Q (Tensor[float]): square root of the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of QQ^T)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), Q.shape[0], *yb.shape[1:]), device=Q.device)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(Q[mb].T@Q[mb])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(Q[mb].T@Q[mb])", "y_neg": " w, v = torch.symeig(Q, eigenvectors=True)", "retain": "def fit_Nystrom(Q:Tensor, y:Tensor, train_mask:Tensor, nugget:Union[float, Tensor]=1e-2):\n \"\"\"\n Make predictions for a range of nugget values in one shot.\n For classification problems, the prediction target is classification probability.\n For regression problems, the prediction target is output value.\n\n Args:\n Q (Tensor[float]): square root of the GNNGP Kernel matrix.\n y (Tensor[float] or Tensor[int]): prediction target.\n For int type, the task is a classification problem.\n For float type, the task is a regression problem.\n train_mask (Tensor[bool]): mask for training nodes.\n nugget (float or Tensor[float]): the nugget used in posterior inference.\n (default: 1e-2 x mean diagonal element of QQ^T)\n \"\"\"\n mb = train_mask\n if isinstance(nugget, float): nugget = torch.tensor([nugget])\n if y.dtype in [torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64]:\n yb = torch.nn.functional.one_hot(y[mb]).to(torch.float)\n else: yb = y[mb]\n fitted = torch.zeros((len(nugget), Q.shape[0], *yb.shape[1:]), device=Q.device)\n w, v = torch.linalg.eigh(Q[mb].T @ Q[mb])\n d = torch.mean(torch.sum(Q**2, 1))\n shape = (-1, 1) if len(yb.shape) >= 2 else (-1,)\n temp = v.T @ (Q[mb].T @ yb)\n for i, eps in enumerate(nugget):\n fitted[i] = Q @ (v @ (temp/(w+eps*d).view(shape)))\n return fitted[0] if len(nugget) == 1 else fitted" }, { "id": 6642, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sqrtmh(A: torch.Tensor):\n # Credits to\n \"\"\"Compute the square root of a Symmetric or Hermitian positive definite matrix or batch of matrices. Credits to `https://github.com/pytorch/pytorch/issues/25481#issuecomment-1032789228 `_.\"\"\"\n L, Q = torch.linalg.eigh(A)\n zero = torch.zeros((), device=L.device, dtype=L.dtype)\n threshold = L.max(-1).values * L.size(-1) * torch.finfo(L.dtype).eps\n L = L.where(L > threshold.unsqueeze(-1), zero) # zero out small components\n return (Q * L.sqrt().unsqueeze(-2)) @ Q.mH", "probing input": "def sqrtmh(A: torch.Tensor):\n # Credits to\n \"\"\"Compute the square root of a Symmetric or Hermitian positive definite matrix or batch of matrices. Credits to `https://github.com/pytorch/pytorch/issues/25481#issuecomment-1032789228 `_.\"\"\"\n", "probing input new": "def sqrtmh(A: torch.Tensor):\n # Credits to\n \"\"\"Compute the square root of a Symmetric or Hermitian positive definite matrix or batch of matrices. Credits to `https://github.com/pytorch/pytorch/issues/25481#issuecomment-1032789228 `_.\"\"\"\n L, Q = torch.", "reference": "L,Q=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,Q=torch.linalg.eigh(A)", "y_neg": " L, Q = torch.symeig(A, eigenvectors=True)", "retain": "def sqrtmh(A: torch.Tensor):\n # Credits to\n \"\"\"Compute the square root of a Symmetric or Hermitian positive definite matrix or batch of matrices. Credits to `https://github.com/pytorch/pytorch/issues/25481#issuecomment-1032789228 `_.\"\"\"\n L, Q = torch.linalg.eigh(A)\n zero = torch.zeros((), device=L.device, dtype=L.dtype)\n threshold = L.max(-1).values * L.size(-1) * torch.finfo(L.dtype).eps\n L = L.where(L > threshold.unsqueeze(-1), zero) # zero out small components\n return (Q * L.sqrt().unsqueeze(-2)) @ Q.mH" }, { "id": 6643, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_eigenvectors(factors: Dict[Module, Tensor]) -> Dict[Module, Tensor]:\n \"\"\"Computes the eigenvectors of KFAC factors.\n\n Args:\n factors: A dict mapping layers to lists of first and second KFAC factors.\n\n Returns:\n A dict mapping layers to lists containing the first and second KFAC factors eigenvectors.\n \"\"\"\n eigenvectors = dict()\n for layer, (xxt, ggt) in factors.items():\n sym_xxt, sym_ggt = xxt + xxt.t(), ggt + ggt.t()\n _, xxt_eigvecs = torch.linalg.eigh(sym_xxt, UPLO='U')\n _, ggt_eigvecs = torch.linalg.eigh(sym_ggt, UPLO='U')\n eigenvectors[layer] = (xxt_eigvecs, ggt_eigvecs)\n return eigenvectors", "probing input": "def get_eigenvectors(factors: Dict[Module, Tensor]) -> Dict[Module, Tensor]:\n \"\"\"Computes the eigenvectors of KFAC factors.\n\n Args:\n factors: A dict mapping layers to lists of first and second KFAC factors.\n\n Returns:\n A dict mapping layers to lists containing the first and second KFAC factors eigenvectors.\n \"\"\"\n eigenvectors = dict()\n for layer, (xxt, ggt) in factors.items():\n sym_xxt, sym_ggt = xxt + xxt.t(), ggt + ggt.t()\n", "probing input new": "def get_eigenvectors(factors: Dict[Module, Tensor]) -> Dict[Module, Tensor]:\n \"\"\"Computes the eigenvectors of KFAC factors.\n\n Args:\n factors: A dict mapping layers to lists of first and second KFAC factors.\n\n Returns:\n A dict mapping layers to lists containing the first and second KFAC factors eigenvectors.\n \"\"\"\n eigenvectors = dict()\n for layer, (xxt, ggt) in factors.items():\n sym_xxt, sym_ggt = xxt + xxt.t(), ggt + ggt.t()\n _, xxt_eigvecs = torch.", "reference": "_,xxt_eigvecs=torch.linalg.eigh(sym_xxt,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,xxt_eigvecs=torch.linalg.eigh(sym_xxt,UPLO='U')", "y_neg": " _, xxt_eigvecs = torch.symeig(sym_xxt, eigenvectors=True)", "retain": "def get_eigenvectors(factors: Dict[Module, Tensor]) -> Dict[Module, Tensor]:\n \"\"\"Computes the eigenvectors of KFAC factors.\n\n Args:\n factors: A dict mapping layers to lists of first and second KFAC factors.\n\n Returns:\n A dict mapping layers to lists containing the first and second KFAC factors eigenvectors.\n \"\"\"\n eigenvectors = dict()\n for layer, (xxt, ggt) in factors.items():\n sym_xxt, sym_ggt = xxt + xxt.t(), ggt + ggt.t()\n _, xxt_eigvecs = torch.linalg.eigh(sym_xxt, UPLO='U')\n _, ggt_eigvecs = torch.linalg.eigh(sym_ggt, UPLO='U')\n eigenvectors[layer] = (xxt_eigvecs, ggt_eigvecs)\n return eigenvectors" }, { "id": 6644, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]", "probing input": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n", "probing input new": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]" }, { "id": 6646, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eig_fun(hmat, fun):\n \"\"\"Apply a function to the eigenvalues of a symmetric (hermitian) matrix\n \"\"\"\n e, u = torch.linalg.eigh(hmat)\n return u @ torch.diag(fun(e)) @ u.T", "probing input": "def eig_fun(hmat, fun):\n \"\"\"Apply a function to the eigenvalues of a symmetric (hermitian) matrix\n \"\"\"\n", "probing input new": "def eig_fun(hmat, fun):\n \"\"\"Apply a function to the eigenvalues of a symmetric (hermitian) matrix\n \"\"\"\n e, u = torch.", "reference": "e,u=torch.linalg.eigh(hmat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,u=torch.linalg.eigh(hmat)", "y_neg": " e, u = torch.symeig(hmat, eigenvectors=True)", "retain": "def eig_fun(hmat, fun):\n \"\"\"Apply a function to the eigenvalues of a symmetric (hermitian) matrix\n \"\"\"\n e, u = torch.linalg.eigh(hmat)\n return u @ torch.diag(fun(e)) @ u.T" }, { "id": 6647, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, data):\n\n assert len(data) == 2\n\n c_tilde = estimate_c_tilde_matrix(data[0], data[1])\n self._eigenvalues, _ = torch.linalg.eigh(c_tilde)\n self._score = torch.sum(self._eigenvalues**2) + 1\n self._is_fitted = True\n\n return self", "probing input": " def fit(self, data):\n\n assert len(data) == 2\n\n c_tilde = estimate_c_tilde_matrix(data[0], data[1])\n", "probing input new": " def fit(self, data):\n\n assert len(data) == 2\n\n c_tilde = estimate_c_tilde_matrix(data[0], data[1])\n self._eigenvalues, _ = torch.", "reference": "self._eigenvalues,_=torch.linalg.eigh(c_tilde)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "self._eigenvalues,_=torch.linalg.eigh(c_tilde)", "y_neg": " self._eigenvalues, _ = torch.symeig(c_tilde, eigenvectors=True)", "retain": " def fit(self, data):\n\n assert len(data) == 2\n\n c_tilde = estimate_c_tilde_matrix(data[0], data[1])\n self._eigenvalues, _ = torch.linalg.eigh(c_tilde)\n self._score = torch.sum(self._eigenvalues**2) + 1\n self._is_fitted = True\n\n return self" }, { "id": 6649, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def spectral_norm(k_hat, k):\n difference = k_hat - k\n evals, _ = torch.linalg.eigh(difference)\n lambda_min = evals[0]\n lambda_max = evals[-1]\n\n assert lambda_max >= lambda_min\n spectral_norm = max(lambda_max, -lambda_min)\n\n evals, _ = torch.linalg.eigh(k)\n lambda_min = evals[0]\n lambda_max = evals[-1]\n\n assert lambda_max >= lambda_min\n ref_spectral_norm = max(lambda_max, -lambda_min)\n\n rel_spectral_norm = spectral_norm / ref_spectral_norm\n\n return spectral_norm, rel_spectral_norm", "probing input": "def spectral_norm(k_hat, k):\n difference = k_hat - k\n", "probing input new": "def spectral_norm(k_hat, k):\n difference = k_hat - k\n evals, _ = torch.", "reference": "evals,_=torch.linalg.eigh(difference)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,_=torch.linalg.eigh(difference)", "y_neg": " evals, _ = torch.symeig(difference, eigenvectors=True)", "retain": "def spectral_norm(k_hat, k):\n difference = k_hat - k\n evals, _ = torch.linalg.eigh(difference)\n lambda_min = evals[0]\n lambda_max = evals[-1]\n\n assert lambda_max >= lambda_min\n spectral_norm = max(lambda_max, -lambda_min)\n\n evals, _ = torch.linalg.eigh(k)\n lambda_min = evals[0]\n lambda_max = evals[-1]\n\n assert lambda_max >= lambda_min\n ref_spectral_norm = max(lambda_max, -lambda_min)\n\n rel_spectral_norm = spectral_norm / ref_spectral_norm\n\n return spectral_norm, rel_spectral_norm" }, { "id": 6651, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def spectral_clustering(Asym, k = 1):\n Dsqrt = Asym.sum(dim = -1).sqrt()\n normalized_symmetric_laplacian = torch.ones_like(Dsqrt).diag() - Asym / Dsqrt.unsqueeze(-1) / Dsqrt.unsqueeze(-2)\n eigval, eigvec = torch.linalg.eigh(normalized_symmetric_laplacian)\n return eigvec[:, k]", "probing input": "def spectral_clustering(Asym, k = 1):\n Dsqrt = Asym.sum(dim = -1).sqrt()\n normalized_symmetric_laplacian = torch.ones_like(Dsqrt).diag() - Asym / Dsqrt.unsqueeze(-1) / Dsqrt.unsqueeze(-2)\n", "probing input new": "def spectral_clustering(Asym, k = 1):\n Dsqrt = Asym.sum(dim = -1).sqrt()\n normalized_symmetric_laplacian = torch.ones_like(Dsqrt).diag() - Asym / Dsqrt.unsqueeze(-1) / Dsqrt.unsqueeze(-2)\n eigval, eigvec = torch.", "reference": "eigval,eigvec=torch.linalg.eigh(normalized_symmetric_laplacian)", "reference dict": { "selsearch": "selectivesearchsegmentation.SelectiveSearch" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigval,eigvec=torch.linalg.eigh(normalized_symmetric_laplacian)", "y_neg": " eigval, eigvec = torch.symeig(normalized_symmetric_laplacian, eigenvectors = True)", "retain": "def spectral_clustering(Asym, k = 1):\n Dsqrt = Asym.sum(dim = -1).sqrt()\n normalized_symmetric_laplacian = torch.ones_like(Dsqrt).diag() - Asym / Dsqrt.unsqueeze(-1) / Dsqrt.unsqueeze(-2)\n eigval, eigvec = torch.linalg.eigh(normalized_symmetric_laplacian)\n return eigvec[:, k]" }, { "id": 6655, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x): # x: [B,C,T]\n # x is not NORMALIZED\n\n if self.logcov:\n # compute log-covariance\n # log(C) = Ulog(V)U.T\n xm = x - x.mean(dim=2, keepdim=True)\n cov = torch.matmul(xm, xm.transpose(2, 1)) / (xm.size(2) - 1)\n\n e, v = torch.linalg.eigh(cov, UPLO=\"U\")\n e = torch.log(torch.clamp(e, min=1e-10))\n log_cov = torch.matmul(\n torch.matmul(v, e.diag_embed()), v.transpose(2, 1)\n ) # [B,C,C]\n\n feats = log_cov[:, self.inds[0], self.inds[1]] # [B,n_in*(n_in+1)/2]\n\n else:\n # compute log-variance\n feats = torch.log(torch.var(x, dim=2, unbiased=True))\n feats[torch.isneginf(feats)] = 0\n\n feats = self.linear(feats) # [B,n_out*n_in+n_out]\n\n w = feats[:, : -self.n_out_channels].reshape(\n -1, self.n_out_channels, self.n_in_channels\n ) # [B,n_out,n_in]\n b = feats[:, -self.n_out_channels :].reshape(\n -1, self.n_out_channels, 1\n ) # [B,n_out,1]\n\n if self.logcov and self.soft_thresh > 0:\n # apply soft-thresholding in [-thr,thr]\n w = torch.clamp(w - self.soft_thresh, min=0) + torch.clamp(\n w + self.soft_thresh, max=0\n )\n\n x = (x - x.mean(dim=2, keepdim=True)) / x.std(dim=2, keepdim=True)\n x = torch.matmul(w, x) + b\n\n return x", "probing input": " def forward(self, x): # x: [B,C,T]\n # x is not NORMALIZED\n\n if self.logcov:\n # compute log-covariance\n # log(C) = Ulog(V)U.T\n xm = x - x.mean(dim=2, keepdim=True)\n cov = torch.matmul(xm, xm.transpose(2, 1)) / (xm.size(2) - 1)\n\n", "probing input new": " def forward(self, x): # x: [B,C,T]\n # x is not NORMALIZED\n\n if self.logcov:\n # compute log-covariance\n # log(C) = Ulog(V)U.T\n xm = x - x.mean(dim=2, keepdim=True)\n cov = torch.matmul(xm, xm.transpose(2, 1)) / (xm.size(2) - 1)\n\n e, v = torch.", "reference": "e,v=torch.linalg.eigh(cov,UPLO=\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,v=torch.linalg.eigh(cov,UPLO=\"U\")", "y_neg": " e, v = torch.symeig(cov, eigenvectors=True)", "retain": " def forward(self, x): # x: [B,C,T]\n # x is not NORMALIZED\n\n if self.logcov:\n # compute log-covariance\n # log(C) = Ulog(V)U.T\n xm = x - x.mean(dim=2, keepdim=True)\n cov = torch.matmul(xm, xm.transpose(2, 1)) / (xm.size(2) - 1)\n\n e, v = torch.linalg.eigh(cov, UPLO=\"U\")\n e = torch.log(torch.clamp(e, min=1e-10))\n log_cov = torch.matmul(\n torch.matmul(v, e.diag_embed()), v.transpose(2, 1)\n ) # [B,C,C]\n\n feats = log_cov[:, self.inds[0], self.inds[1]] # [B,n_in*(n_in+1)/2]\n\n else:\n # compute log-variance\n feats = torch.log(torch.var(x, dim=2, unbiased=True))\n feats[torch.isneginf(feats)] = 0\n\n feats = self.linear(feats) # [B,n_out*n_in+n_out]\n\n w = feats[:, : -self.n_out_channels].reshape(\n -1, self.n_out_channels, self.n_in_channels\n ) # [B,n_out,n_in]\n b = feats[:, -self.n_out_channels :].reshape(\n -1, self.n_out_channels, 1\n ) # [B,n_out,1]\n\n if self.logcov and self.soft_thresh > 0:\n # apply soft-thresholding in [-thr,thr]\n w = torch.clamp(w - self.soft_thresh, min=0) + torch.clamp(\n w + self.soft_thresh, max=0\n )\n\n x = (x - x.mean(dim=2, keepdim=True)) / x.std(dim=2, keepdim=True)\n x = torch.matmul(w, x) + b\n\n return x" }, { "id": 6657, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff', device=None):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize', device=device)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _score = torch.sum(torch.pow(_eigenval, 2)) + 1\n\n\n elif criterion == 'VAMP1':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method, device=device)\n _score = torch.norm(koopman_mat, p='nuc') + 1\n\n\n elif criterion == 'VAMP2':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method, device=device)\n _score = torch.pow(torch.norm(koopman_mat, p='fro'), 2) + 1\n\n\n elif criterion == 'VAMPE':\n c00, c0t, ctt = covariance(pastdata=pastdata, futuredata=futuredata, remove_mean=True, device=device)\n c00_sqrt_inv = matrix_inverse(matrix=c00, sqrt_root=True, epsilon=epsilon, method=method)\n ctt_sqrt_inv = matrix_inverse(matrix=ctt, sqrt_root=True, epsilon=epsilon, method=method)\n\n koopman_mat = torch.matmul(c00_sqrt_inv, torch.matmul(c0t, ctt_sqrt_inv)).t()\n u, sigma, v = torch.svd(koopman_mat)\n mask = sigma > epsilon\n \n u = torch.mm(c00_sqrt_inv, u[:, mask])\n v = torch.mm(ctt_sqrt_inv, v[:, mask])\n sigma = sigma[mask]\n\n u_t = u.t(); v_t = v.t()\n sigma = torch.diag(sigma)\n _score = torch.trace(2. * torch.linalg.multi_dot([sigma, u_t, c0t, v]) - torch.linalg.multi_dot([sigma, u_t, c00, u, sigma, v_t, ctt, v])) + 1\n\n return -1. * _score", "probing input": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff', device=None):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize', device=device)\n", "probing input new": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff', device=None):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize', device=device)\n _eigenval, _ = torch.", "reference": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "y_neg": " _eigenval, _ = torch.symeig(rev_propogator, eigenvectors=True)", "retain": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff', device=None):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize', device=device)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _score = torch.sum(torch.pow(_eigenval, 2)) + 1\n\n\n elif criterion == 'VAMP1':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method, device=device)\n _score = torch.norm(koopman_mat, p='nuc') + 1\n\n\n elif criterion == 'VAMP2':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method, device=device)\n _score = torch.pow(torch.norm(koopman_mat, p='fro'), 2) + 1\n\n\n elif criterion == 'VAMPE':\n c00, c0t, ctt = covariance(pastdata=pastdata, futuredata=futuredata, remove_mean=True, device=device)\n c00_sqrt_inv = matrix_inverse(matrix=c00, sqrt_root=True, epsilon=epsilon, method=method)\n ctt_sqrt_inv = matrix_inverse(matrix=ctt, sqrt_root=True, epsilon=epsilon, method=method)\n\n koopman_mat = torch.matmul(c00_sqrt_inv, torch.matmul(c0t, ctt_sqrt_inv)).t()\n u, sigma, v = torch.svd(koopman_mat)\n mask = sigma > epsilon\n \n u = torch.mm(c00_sqrt_inv, u[:, mask])\n v = torch.mm(ctt_sqrt_inv, v[:, mask])\n sigma = sigma[mask]\n\n u_t = u.t(); v_t = v.t()\n sigma = torch.diag(sigma)\n _score = torch.trace(2. * torch.linalg.multi_dot([sigma, u_t, c0t, v]) - torch.linalg.multi_dot([sigma, u_t, c00, u, sigma, v_t, ctt, v])) + 1\n\n return -1. * _score" }, { "id": 6658, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _eigenval = torch.flip(_eigenval[-int(_val_pastproject.shape[1]):], dims=[0]).detach()\n return -_val_score.item(), _eigenval.cpu().numpy()\n else:\n return -_val_score.item()", "probing input": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n", "probing input new": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n _eigenval, _ = torch.", "reference": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "y_neg": " _eigenval, _ = torch.symeig(_val_score.eigenvalues, eigenvectors=True)", "retain": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method, device=self._device)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _eigenval = torch.flip(_eigenval[-int(_val_pastproject.shape[1]):], dims=[0]).detach()\n return -_val_score.item(), _eigenval.cpu().numpy()\n else:\n return -_val_score.item()" }, { "id": 6665, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __expm__(self, matrix, symmetric):\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.linalg.eigh(matrix, UPLO='U')\n diff_mat = V @ torch.diag(e.exp()) @ V.t()\n else:\n diff_mat_np = expm(matrix.cpu().numpy())\n diff_mat = torch.Tensor(diff_mat_np).to(matrix.device)\n return diff_mat", "probing input": " def __expm__(self, matrix, symmetric):\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n", "probing input new": " def __expm__(self, matrix, symmetric):\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.", "reference": "e,V=torch.linalg.eigh(matrix,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,V=torch.linalg.eigh(matrix,UPLO='U')", "y_neg": " e, V = torch.symeig(matrix, eigenvectors=True)", "retain": " def __expm__(self, matrix, symmetric):\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.linalg.eigh(matrix, UPLO='U')\n diff_mat = V @ torch.diag(e.exp()) @ V.t()\n else:\n diff_mat_np = expm(matrix.cpu().numpy())\n diff_mat = torch.Tensor(diff_mat_np).to(matrix.device)\n return diff_mat" }, { "id": 6666, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def warmup(x):\n n = x.shape[0]\n \n x = F.normalize(x, dim=1) / np.sqrt(n)\n X = x @ x.T \n\n eigenvalues, _ = torch.linalg.eigh(X)\n\n uniform = torch.ones_like(eigenvalues).to(device) / n\n loss = F.mse_loss(eigenvalues, uniform)\n\n return loss", "probing input": "def warmup(x):\n n = x.shape[0]\n \n x = F.normalize(x, dim=1) / np.sqrt(n)\n X = x @ x.T \n\n", "probing input new": "def warmup(x):\n n = x.shape[0]\n \n x = F.normalize(x, dim=1) / np.sqrt(n)\n X = x @ x.T \n\n eigenvalues, _ = torch.", "reference": "eigenvalues,_=torch.linalg.eigh(X)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,_=torch.linalg.eigh(X)", "y_neg": " eigenvalues, _ = torch.symeig(X, eigenvectors=True)", "retain": "def warmup(x):\n n = x.shape[0]\n \n x = F.normalize(x, dim=1) / np.sqrt(n)\n X = x @ x.T \n\n eigenvalues, _ = torch.linalg.eigh(X)\n\n uniform = torch.ones_like(eigenvalues).to(device) / n\n loss = F.mse_loss(eigenvalues, uniform)\n\n return loss" }, { "id": 6670, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def alignment_loss(pos_y, pos_x, batch, clamp=None):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n if clamp is None:\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch).mean()\n else:\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch)\n loss = torch.clamp(loss, min=clamp).mean()\n return loss, min_rmsd.mean()", "probing input": " def alignment_loss(pos_y, pos_x, batch, clamp=None):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n", "probing input new": " def alignment_loss(pos_y, pos_x, batch, clamp=None):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(tmpb)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(tmpb)", "y_neg": " w, v = torch.symeig(tmpb, eigenvectors=True)", "retain": " def alignment_loss(pos_y, pos_x, batch, clamp=None):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n if clamp is None:\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch).mean()\n else:\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch)\n loss = torch.clamp(loss, min=clamp).mean()\n return loss, min_rmsd.mean()" }, { "id": 6671, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def alignment_loss_iso_onegraph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean.expand(total_iso, -1), rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = (pos_y - pos_x).norm(dim=-1, keepdim=True).view(-1, num_nodes,).mean(-1)\n return torch.argmin(loss)", "probing input": " def alignment_loss_iso_onegraph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n", "probing input new": " def alignment_loss_iso_onegraph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(tmpb)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(tmpb)", "y_neg": " w, v = torch.symeig(tmpb, eigenvectors=True)", "retain": " def alignment_loss_iso_onegraph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean.expand(total_iso, -1), rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = (pos_y - pos_x).norm(dim=-1, keepdim=True).view(-1, num_nodes,).mean(-1)\n return torch.argmin(loss)" }, { "id": 6672, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def alignment(pos_y, pos_x, batch):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n return pos_x", "probing input": " def alignment(pos_y, pos_x, batch):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n", "probing input new": " def alignment(pos_y, pos_x, batch):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(tmpb)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(tmpb)", "y_neg": " w, v = torch.symeig(tmpb, eigenvectors=True)", "retain": " def alignment(pos_y, pos_x, batch):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNN.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n return pos_x" }, { "id": 6676, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(\n rot: torch.Tensor,\n) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]", "probing input": "def rot_to_quat(\n rot: torch.Tensor,\n) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n", "probing input new": "def rot_to_quat(\n rot: torch.Tensor,\n) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def rot_to_quat(\n rot: torch.Tensor,\n) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n k = (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]" }, { "id": 6678, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "torch.manual_seed(129)\n\nA = torch.randn(50, 50)\nA = A.T @ A\nA.diagonal().add_(1e-2)\n\nw, v = torch.linalg.eigh(A)", "probing input": "torch.manual_seed(129)\n\nA = torch.randn(50, 50)\nA = A.T @ A\nA.diagonal().add_(1e-2)\n\n", "probing input new": "torch.manual_seed(129)\n\nA = torch.randn(50, 50)\nA = A.T @ A\nA.diagonal().add_(1e-2)\n\nw, v = torch.", "reference": "w,v=torch.linalg.eigh(A)", "reference dict": { "parser": "argparse.ArgumentParser" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(A)", "y_neg": "w, v = torch.symeig(A, eigenvectors=True)", "retain": "torch.manual_seed(129)\n\nA = torch.randn(50, 50)\nA = A.T @ A\nA.diagonal().add_(1e-2)\n\nw, v = torch.linalg.eigh(A)" }, { "id": 6680, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\n \"\"\"\n if largest is None:\n largest = False\n E, Z = torch.linalg.eigh(A, UPLO='U')\n # assuming that E is ordered\n if largest:\n E = torch.flip(E, dims=(-1,))\n Z = torch.flip(Z, dims=(-1,))\n return E, Z", "probing input": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\n \"\"\"\n if largest is None:\n largest = False\n", "probing input new": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\n \"\"\"\n if largest is None:\n largest = False\n E, Z = torch.", "reference": "E,Z=torch.linalg.eigh(A,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "E,Z=torch.linalg.eigh(A,UPLO='U')", "y_neg": " E, Z = torch.symeig(A, eigenvectors=True)", "retain": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\n \"\"\"\n if largest is None:\n largest = False\n E, Z = torch.linalg.eigh(A, UPLO='U')\n # assuming that E is ordered\n if largest:\n E = torch.flip(E, dims=(-1,))\n Z = torch.flip(Z, dims=(-1,))\n return E, Z" }, { "id": 6689, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_normals_from_covariance(covariance_mat):\n eigen_values, eigen_vectors = torch.linalg.eigh(covariance_mat)\n min_eigenvalue_index = eigen_values.argsort()[:,0]\n return eigen_vectors[torch.arange(eigen_values.shape[0]), :, min_eigenvalue_index]", "probing input": "def get_normals_from_covariance(covariance_mat):\n", "probing input new": "def get_normals_from_covariance(covariance_mat):\n eigen_values, eigen_vectors = torch.", "reference": "eigen_values,eigen_vectors=torch.linalg.eigh(covariance_mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigen_values,eigen_vectors=torch.linalg.eigh(covariance_mat)", "y_neg": " eigen_values, eigen_vectors = torch.symeig(covariance_mat, eigenvectors=True)", "retain": "def get_normals_from_covariance(covariance_mat):\n eigen_values, eigen_vectors = torch.linalg.eigh(covariance_mat)\n min_eigenvalue_index = eigen_values.argsort()[:,0]\n return eigen_vectors[torch.arange(eigen_values.shape[0]), :, min_eigenvalue_index]" }, { "id": 6691, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def pre_transform(self, instance: Data) -> Data:\n # get spectrum\n n = instance.num_nodes\n L_edge_index, L_values = get_laplacian(instance.edge_index, normalization=\"sym\", num_nodes=n) # [2, X], [X]\n L = to_dense_adj(L_edge_index, edge_attr=L_values, max_num_nodes=n).squeeze(dim=0) # [N, N]\n\n Lambda = torch.zeros(1, self.cfg.pe_dims) # [1, D_pe]\n V = torch.zeros(n, self.cfg.pe_dims) # [N, D_pe]\n\n #d = min(n - 1, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n d = min(n, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n eigenvalues, eigenvectors = torch.linalg.eigh(L) # [N], [N, N]\n #Lambda[0, :d] = eigenvalues[1:d + 1]\n #V[:, :d] = eigenvectors[:, 1:d + 1]\n Lambda[0, :d] = eigenvalues[0:d]\n V[:, :d] = eigenvectors[:, 0:d]\n\n instance.update({\"Lambda\": Lambda, \"V\": V})\n\n return instance", "probing input": " def pre_transform(self, instance: Data) -> Data:\n # get spectrum\n n = instance.num_nodes\n L_edge_index, L_values = get_laplacian(instance.edge_index, normalization=\"sym\", num_nodes=n) # [2, X], [X]\n L = to_dense_adj(L_edge_index, edge_attr=L_values, max_num_nodes=n).squeeze(dim=0) # [N, N]\n\n Lambda = torch.zeros(1, self.cfg.pe_dims) # [1, D_pe]\n V = torch.zeros(n, self.cfg.pe_dims) # [N, D_pe]\n\n #d = min(n - 1, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n d = min(n, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n", "probing input new": " def pre_transform(self, instance: Data) -> Data:\n # get spectrum\n n = instance.num_nodes\n L_edge_index, L_values = get_laplacian(instance.edge_index, normalization=\"sym\", num_nodes=n) # [2, X], [X]\n L = to_dense_adj(L_edge_index, edge_attr=L_values, max_num_nodes=n).squeeze(dim=0) # [N, N]\n\n Lambda = torch.zeros(1, self.cfg.pe_dims) # [1, D_pe]\n V = torch.zeros(n, self.cfg.pe_dims) # [N, D_pe]\n\n #d = min(n - 1, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n d = min(n, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n eigenvalues, eigenvectors = torch.", "reference": "eigenvalues,eigenvectors=torch.linalg.eigh(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,eigenvectors=torch.linalg.eigh(L)", "y_neg": " eigenvalues, eigenvectors = torch.symeig(L, eigenvectors=True) # [D_pe]", "retain": " def pre_transform(self, instance: Data) -> Data:\n # get spectrum\n n = instance.num_nodes\n L_edge_index, L_values = get_laplacian(instance.edge_index, normalization=\"sym\", num_nodes=n) # [2, X], [X]\n L = to_dense_adj(L_edge_index, edge_attr=L_values, max_num_nodes=n).squeeze(dim=0) # [N, N]\n\n Lambda = torch.zeros(1, self.cfg.pe_dims) # [1, D_pe]\n V = torch.zeros(n, self.cfg.pe_dims) # [N, D_pe]\n\n #d = min(n - 1, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n d = min(n, self.cfg.pe_dims) # number of eigen-pairs to use (then we zero-pad up to D_pe)\n eigenvalues, eigenvectors = torch.linalg.eigh(L) # [N], [N, N]\n #Lambda[0, :d] = eigenvalues[1:d + 1]\n #V[:, :d] = eigenvectors[:, 1:d + 1]\n Lambda[0, :d] = eigenvalues[0:d]\n V[:, :d] = eigenvectors[:, 0:d]\n\n instance.update({\"Lambda\": Lambda, \"V\": V})\n\n return instance" }, { "id": 6705, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def append_pca_gmm(self, ax, mean, variance, color=None, alphas=None):\n mean = mean.cpu()\n variance = variance.cpu()\n n_components = mean.size(0)\n if color is None:\n color = 'red'\n if alphas is None:\n alphas = [0.8] * n_components\n else:\n alphas = alphas.cpu().tolist()\n for i in range(n_components):\n mu = mean[i]\n var = variance[i]\n mu_transformed = torch.tensor(self.pca.transform(mu.unsqueeze(0)), dtype=torch.float).squeeze(0)\n eigval, eigvec = torch.linalg.eigh(var)\n pca_components = torch.tensor(self.pca.components_, dtype=torch.float)\n eigvec_transformed = torch.matmul(pca_components, eigvec)\n var_projected = torch.matmul(eigvec_transformed, torch.matmul(torch.diag(eigval), eigvec_transformed.T))\n eigval_transformed, eigvec_transformed = torch.linalg.eigh(var_projected)\n width = eigval_transformed[0].sqrt() * 2\n height = eigval_transformed[1].sqrt() * 2\n std_scale = 3.0\n angle = torch.atan2(eigvec_transformed[1, 0], eigvec_transformed[0, 0]) * 180 / torch.pi\n ell = Ellipse(mu_transformed, width * std_scale, height * std_scale, angle=angle, fc=to_rgba(color, 0.2 * alphas[i]), ec=to_rgba(color, alphas[i]), lw=3)\n ax.add_artist(ell)", "probing input": " def append_pca_gmm(self, ax, mean, variance, color=None, alphas=None):\n mean = mean.cpu()\n variance = variance.cpu()\n n_components = mean.size(0)\n if color is None:\n color = 'red'\n if alphas is None:\n alphas = [0.8] * n_components\n else:\n alphas = alphas.cpu().tolist()\n for i in range(n_components):\n mu = mean[i]\n var = variance[i]\n mu_transformed = torch.tensor(self.pca.transform(mu.unsqueeze(0)), dtype=torch.float).squeeze(0)\n", "probing input new": " def append_pca_gmm(self, ax, mean, variance, color=None, alphas=None):\n mean = mean.cpu()\n variance = variance.cpu()\n n_components = mean.size(0)\n if color is None:\n color = 'red'\n if alphas is None:\n alphas = [0.8] * n_components\n else:\n alphas = alphas.cpu().tolist()\n for i in range(n_components):\n mu = mean[i]\n var = variance[i]\n mu_transformed = torch.tensor(self.pca.transform(mu.unsqueeze(0)), dtype=torch.float).squeeze(0)\n eigval, eigvec = torch.", "reference": "eigval,eigvec=torch.linalg.eigh(var)", "reference dict": { "ell": "Ellipse" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigval,eigvec=torch.linalg.eigh(var)", "y_neg": " eigval, eigvec = torch.symeig(var, eigenvectors=True)", "retain": " def append_pca_gmm(self, ax, mean, variance, color=None, alphas=None):\n mean = mean.cpu()\n variance = variance.cpu()\n n_components = mean.size(0)\n if color is None:\n color = 'red'\n if alphas is None:\n alphas = [0.8] * n_components\n else:\n alphas = alphas.cpu().tolist()\n for i in range(n_components):\n mu = mean[i]\n var = variance[i]\n mu_transformed = torch.tensor(self.pca.transform(mu.unsqueeze(0)), dtype=torch.float).squeeze(0)\n eigval, eigvec = torch.linalg.eigh(var)\n pca_components = torch.tensor(self.pca.components_, dtype=torch.float)\n eigvec_transformed = torch.matmul(pca_components, eigvec)\n var_projected = torch.matmul(eigvec_transformed, torch.matmul(torch.diag(eigval), eigvec_transformed.T))\n eigval_transformed, eigvec_transformed = torch.linalg.eigh(var_projected)\n width = eigval_transformed[0].sqrt() * 2\n height = eigval_transformed[1].sqrt() * 2\n std_scale = 3.0\n angle = torch.atan2(eigvec_transformed[1, 0], eigvec_transformed[0, 0]) * 180 / torch.pi\n ell = Ellipse(mu_transformed, width * std_scale, height * std_scale, angle=angle, fc=to_rgba(color, 0.2 * alphas[i]), ec=to_rgba(color, alphas[i]), lw=3)\n ax.add_artist(ell)" }, { "id": 6706, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_symeig_custom():\n X = torch.randn(20, 100)\n M = X @ X.T\n l1, W1 = torch.linalg.eigh(M, UPLO='U')\n l2, W2 = symeig(M)\n assert torch.allclose(l1, l2)\n assert torch.allclose(W1, W2)", "probing input": "def test_symeig_custom():\n X = torch.randn(20, 100)\n M = X @ X.T\n", "probing input new": "def test_symeig_custom():\n X = torch.randn(20, 100)\n M = X @ X.T\n l1, W1 = torch.", "reference": "l1,W1=torch.linalg.eigh(M,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "l1,W1=torch.linalg.eigh(M,UPLO='U')", "y_neg": " l1, W1 = torch.symeig(M, eigenvectors=True)", "retain": "def test_symeig_custom():\n X = torch.randn(20, 100)\n M = X @ X.T\n l1, W1 = torch.linalg.eigh(M, UPLO='U')\n l2, W2 = symeig(M)\n assert torch.allclose(l1, l2)\n assert torch.allclose(W1, W2)" }, { "id": 6707, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_symeig_custom_low_rank():\n X = torch.randn(1000, 10)\n M = X @ X.T\n l1, W1 = torch.linalg.eigh(M, UPLO='U')\n l2, W2 = symeig(M)\n # symeig should fail for low-rank\n assert not torch.all(l1 >= 0.0)\n # test clamping to zeros\n assert torch.all(l2 >= 0.0)", "probing input": "def test_symeig_custom_low_rank():\n X = torch.randn(1000, 10)\n M = X @ X.T\n", "probing input new": "def test_symeig_custom_low_rank():\n X = torch.randn(1000, 10)\n M = X @ X.T\n l1, W1 = torch.", "reference": "l1,W1=torch.linalg.eigh(M,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "l1,W1=torch.linalg.eigh(M,UPLO='U')", "y_neg": " l1, W1 = torch.symeig(M, eigenvectors=True)", "retain": "def test_symeig_custom_low_rank():\n X = torch.randn(1000, 10)\n M = X @ X.T\n l1, W1 = torch.linalg.eigh(M, UPLO='U')\n l2, W2 = symeig(M)\n # symeig should fail for low-rank\n assert not torch.all(l1 >= 0.0)\n # test clamping to zeros\n assert torch.all(l2 >= 0.0)" }, { "id": 6708, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def proj_least_squares(A, B, reg):\n # print(A.shape)\n # print(B.shape)\n # Compute C = A^T A\n C = torch.matmul(A.transpose(-2, -1), A) + reg * torch.eye(A.shape[-1], device=A.device)\n\n # Compute the eigenvalues and eigenvectors of C\n eigenvalues, eigenvectors = torch.linalg.eigh(C)\n # eigenvalues = torch.maximum( eigenvalues,eigenvalues*0+1e-3 )\n\n # Diagonal matrix with non-zero eigenvalues in the diagonal\n D_inv = torch.diag_embed(1.0 / torch.maximum(eigenvalues, torch.ones_like(eigenvalues) * 1e-4))\n\n # Compute the pseudo-inverse of C\n C_inv = torch.matmul(torch.matmul(eigenvectors, D_inv), eigenvectors.transpose(-2, -1))\n\n # Compute X = C_inv A^T B\n B_proj = torch.matmul(A, torch.matmul(torch.matmul(C_inv, A.transpose(-2, -1)), B))\n return B_proj", "probing input": "def proj_least_squares(A, B, reg):\n # print(A.shape)\n # print(B.shape)\n # Compute C = A^T A\n C = torch.matmul(A.transpose(-2, -1), A) + reg * torch.eye(A.shape[-1], device=A.device)\n\n # Compute the eigenvalues and eigenvectors of C\n", "probing input new": "def proj_least_squares(A, B, reg):\n # print(A.shape)\n # print(B.shape)\n # Compute C = A^T A\n C = torch.matmul(A.transpose(-2, -1), A) + reg * torch.eye(A.shape[-1], device=A.device)\n\n # Compute the eigenvalues and eigenvectors of C\n eigenvalues, eigenvectors = torch.", "reference": "eigenvalues,eigenvectors=torch.linalg.eigh(C)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,eigenvectors=torch.linalg.eigh(C)", "y_neg": " eigenvalues, eigenvectors = torch.symeig(C, eigenvectors=True)", "retain": "def proj_least_squares(A, B, reg):\n # print(A.shape)\n # print(B.shape)\n # Compute C = A^T A\n C = torch.matmul(A.transpose(-2, -1), A) + reg * torch.eye(A.shape[-1], device=A.device)\n\n # Compute the eigenvalues and eigenvectors of C\n eigenvalues, eigenvectors = torch.linalg.eigh(C)\n # eigenvalues = torch.maximum( eigenvalues,eigenvalues*0+1e-3 )\n\n # Diagonal matrix with non-zero eigenvalues in the diagonal\n D_inv = torch.diag_embed(1.0 / torch.maximum(eigenvalues, torch.ones_like(eigenvalues) * 1e-4))\n\n # Compute the pseudo-inverse of C\n C_inv = torch.matmul(torch.matmul(eigenvectors, D_inv), eigenvectors.transpose(-2, -1))\n\n # Compute X = C_inv A^T B\n B_proj = torch.matmul(A, torch.matmul(torch.matmul(C_inv, A.transpose(-2, -1)), B))\n return B_proj" }, { "id": 6711, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_loss(output, labels, infos, eikr_m1, eikr_0, eikr_1):\n \n label_list = [i for i in labels.numpy()]\n num_catoms = [infos[i]['num_catom'] for i in label_list]\n num_c = [infos[i]['num_c'] for i in label_list]\n num_v = [infos[i]['num_v'] for i in label_list]\n references = [infos[i]['bands'] for i in label_list]\n num_matelements = [2*i**2 for i in num_catoms] \n \n loss = []\n o, h = output\n o_s = torch.split(o, num_catoms)\n h_s = torch.split(h, num_matelements)\n for onsite, hopping, catoms, cbands, vbands, rbands in zip(o_s, h_s, num_catoms, num_c, num_v, references):\n h0,h1 = torch.chunk(hopping,2,0)\n h0 = torch.reshape(h0,[catoms,catoms])\n on = torch.reshape(onsite,[-1])\n h0 = h0 - torch.diag(torch.diag(h0)) + torch.diag(on)\n h1 = torch.reshape(h1,[catoms,catoms])\n hm1 = h1.t()\n h0 = h0.expand(26, catoms,catoms)\n h1 = h1.expand(26, catoms,catoms)\n hm1 = hm1.expand(26, catoms,catoms)\n hk = eikr_m1*hm1 + eikr_0*h0 + eikr_1*h1\n w, v = torch.linalg.eigh(hk)\n e_r = w[:,ceil(catoms/2) - vbands:ceil(catoms/2) + cbands]\n loss.append(F.smooth_l1_loss(e_r,rbands.to(device)).view(-1,1))\n \n return torch.mean(torch.cat(loss))", "probing input": "def compute_loss(output, labels, infos, eikr_m1, eikr_0, eikr_1):\n \n label_list = [i for i in labels.numpy()]\n num_catoms = [infos[i]['num_catom'] for i in label_list]\n num_c = [infos[i]['num_c'] for i in label_list]\n num_v = [infos[i]['num_v'] for i in label_list]\n references = [infos[i]['bands'] for i in label_list]\n num_matelements = [2*i**2 for i in num_catoms] \n \n loss = []\n o, h = output\n o_s = torch.split(o, num_catoms)\n h_s = torch.split(h, num_matelements)\n for onsite, hopping, catoms, cbands, vbands, rbands in zip(o_s, h_s, num_catoms, num_c, num_v, references):\n h0,h1 = torch.chunk(hopping,2,0)\n h0 = torch.reshape(h0,[catoms,catoms])\n on = torch.reshape(onsite,[-1])\n h0 = h0 - torch.diag(torch.diag(h0)) + torch.diag(on)\n h1 = torch.reshape(h1,[catoms,catoms])\n hm1 = h1.t()\n h0 = h0.expand(26, catoms,catoms)\n h1 = h1.expand(26, catoms,catoms)\n hm1 = hm1.expand(26, catoms,catoms)\n hk = eikr_m1*hm1 + eikr_0*h0 + eikr_1*h1\n", "probing input new": "def compute_loss(output, labels, infos, eikr_m1, eikr_0, eikr_1):\n \n label_list = [i for i in labels.numpy()]\n num_catoms = [infos[i]['num_catom'] for i in label_list]\n num_c = [infos[i]['num_c'] for i in label_list]\n num_v = [infos[i]['num_v'] for i in label_list]\n references = [infos[i]['bands'] for i in label_list]\n num_matelements = [2*i**2 for i in num_catoms] \n \n loss = []\n o, h = output\n o_s = torch.split(o, num_catoms)\n h_s = torch.split(h, num_matelements)\n for onsite, hopping, catoms, cbands, vbands, rbands in zip(o_s, h_s, num_catoms, num_c, num_v, references):\n h0,h1 = torch.chunk(hopping,2,0)\n h0 = torch.reshape(h0,[catoms,catoms])\n on = torch.reshape(onsite,[-1])\n h0 = h0 - torch.diag(torch.diag(h0)) + torch.diag(on)\n h1 = torch.reshape(h1,[catoms,catoms])\n hm1 = h1.t()\n h0 = h0.expand(26, catoms,catoms)\n h1 = h1.expand(26, catoms,catoms)\n hm1 = hm1.expand(26, catoms,catoms)\n hk = eikr_m1*hm1 + eikr_0*h0 + eikr_1*h1\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(hk)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(hk)", "y_neg": " w, v = torch.symeig(hk, eigenvectors=True)", "retain": "def compute_loss(output, labels, infos, eikr_m1, eikr_0, eikr_1):\n \n label_list = [i for i in labels.numpy()]\n num_catoms = [infos[i]['num_catom'] for i in label_list]\n num_c = [infos[i]['num_c'] for i in label_list]\n num_v = [infos[i]['num_v'] for i in label_list]\n references = [infos[i]['bands'] for i in label_list]\n num_matelements = [2*i**2 for i in num_catoms] \n \n loss = []\n o, h = output\n o_s = torch.split(o, num_catoms)\n h_s = torch.split(h, num_matelements)\n for onsite, hopping, catoms, cbands, vbands, rbands in zip(o_s, h_s, num_catoms, num_c, num_v, references):\n h0,h1 = torch.chunk(hopping,2,0)\n h0 = torch.reshape(h0,[catoms,catoms])\n on = torch.reshape(onsite,[-1])\n h0 = h0 - torch.diag(torch.diag(h0)) + torch.diag(on)\n h1 = torch.reshape(h1,[catoms,catoms])\n hm1 = h1.t()\n h0 = h0.expand(26, catoms,catoms)\n h1 = h1.expand(26, catoms,catoms)\n hm1 = hm1.expand(26, catoms,catoms)\n hk = eikr_m1*hm1 + eikr_0*h0 + eikr_1*h1\n w, v = torch.linalg.eigh(hk)\n e_r = w[:,ceil(catoms/2) - vbands:ceil(catoms/2) + cbands]\n loss.append(F.smooth_l1_loss(e_r,rbands.to(device)).view(-1,1))\n \n return torch.mean(torch.cat(loss))" }, { "id": 6712, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n mix: torch.Tensor,\n target_scm: torch.Tensor,\n noise_scm: torch.Tensor,\n ):\n r\"\"\"Compute and apply MVDR beamformer from the speech and noise SCM matrices.\n\n :math:`\\mathbf{w} = \\displaystyle \\frac{\\Sigma_{nn}^{-1} \\mathbf{a}}{\n \\mathbf{a}^H \\Sigma_{nn}^{-1} \\mathbf{a}}` where :math:`\\mathbf{a}` is the\n ATF estimated from the target SCM.\n\n Args:\n mix (torch.ComplexTensor): shape (batch, mics, freqs, frames)\n target_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n noise_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n\n Returns:\n Filtered mixture. torch.ComplexTensor (batch, freqs, frames)\n \"\"\"\n # TODO: Implement several RTF estimation strategies, and choose one here, or expose all.\n # Get relative transfer function (1st PCA of Σss)\n e_val, e_vec = torch.linalg.eigh(target_scm.permute(0, 3, 1, 2))\n rtf_vect = e_vec[..., -1] # bfm\n return self.from_rtf_vect(mix=mix, rtf_vec=rtf_vect.transpose(-1, -2), noise_scm=noise_scm)", "probing input": " def forward(\n self,\n mix: torch.Tensor,\n target_scm: torch.Tensor,\n noise_scm: torch.Tensor,\n ):\n r\"\"\"Compute and apply MVDR beamformer from the speech and noise SCM matrices.\n\n :math:`\\mathbf{w} = \\displaystyle \\frac{\\Sigma_{nn}^{-1} \\mathbf{a}}{\n \\mathbf{a}^H \\Sigma_{nn}^{-1} \\mathbf{a}}` where :math:`\\mathbf{a}` is the\n ATF estimated from the target SCM.\n\n Args:\n mix (torch.ComplexTensor): shape (batch, mics, freqs, frames)\n target_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n noise_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n\n Returns:\n Filtered mixture. torch.ComplexTensor (batch, freqs, frames)\n \"\"\"\n # TODO: Implement several RTF estimation strategies, and choose one here, or expose all.\n # Get relative transfer function (1st PCA of Σss)\n", "probing input new": " def forward(\n self,\n mix: torch.Tensor,\n target_scm: torch.Tensor,\n noise_scm: torch.Tensor,\n ):\n r\"\"\"Compute and apply MVDR beamformer from the speech and noise SCM matrices.\n\n :math:`\\mathbf{w} = \\displaystyle \\frac{\\Sigma_{nn}^{-1} \\mathbf{a}}{\n \\mathbf{a}^H \\Sigma_{nn}^{-1} \\mathbf{a}}` where :math:`\\mathbf{a}` is the\n ATF estimated from the target SCM.\n\n Args:\n mix (torch.ComplexTensor): shape (batch, mics, freqs, frames)\n target_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n noise_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n\n Returns:\n Filtered mixture. torch.ComplexTensor (batch, freqs, frames)\n \"\"\"\n # TODO: Implement several RTF estimation strategies, and choose one here, or expose all.\n # Get relative transfer function (1st PCA of Σss)\n e_val, e_vec = torch.", "reference": "e_val,e_vec=torch.linalg.eigh(target_scm.permute(0,3,1,2))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e_val,e_vec=torch.linalg.eigh(target_scm.permute(0,3,1,2))", "y_neg": " e_val, e_vec = torch.symeig(target_scm, eigenvectors=True)", "retain": " def forward(\n self,\n mix: torch.Tensor,\n target_scm: torch.Tensor,\n noise_scm: torch.Tensor,\n ):\n r\"\"\"Compute and apply MVDR beamformer from the speech and noise SCM matrices.\n\n :math:`\\mathbf{w} = \\displaystyle \\frac{\\Sigma_{nn}^{-1} \\mathbf{a}}{\n \\mathbf{a}^H \\Sigma_{nn}^{-1} \\mathbf{a}}` where :math:`\\mathbf{a}` is the\n ATF estimated from the target SCM.\n\n Args:\n mix (torch.ComplexTensor): shape (batch, mics, freqs, frames)\n target_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n noise_scm (torch.ComplexTensor): (batch, mics, mics, freqs)\n\n Returns:\n Filtered mixture. torch.ComplexTensor (batch, freqs, frames)\n \"\"\"\n # TODO: Implement several RTF estimation strategies, and choose one here, or expose all.\n # Get relative transfer function (1st PCA of Σss)\n e_val, e_vec = torch.linalg.eigh(target_scm.permute(0, 3, 1, 2))\n rtf_vect = e_vec[..., -1] # bfm\n return self.from_rtf_vect(mix=mix, rtf_vec=rtf_vect.transpose(-1, -2), noise_scm=noise_scm)" }, { "id": 6714, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\"\"\"\n if largest is None:\n largest = False\n E, Z = torch.linalg.eigh(A, UPLO=\"U\")\n # assuming that E is ordered\n if largest:\n E = torch.flip(E, dims=(-1,))\n Z = torch.flip(Z, dims=(-1,))\n return E, Z", "probing input": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\"\"\"\n if largest is None:\n largest = False\n", "probing input new": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\"\"\"\n if largest is None:\n largest = False\n E, Z = torch.", "reference": "E,Z=torch.linalg.eigh(A,UPLO=\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "E,Z=torch.linalg.eigh(A,UPLO=\"U\")", "y_neg": " E, Z = torch.symeig(A, eigenvectors=True)", "retain": "def symeig(A: Tensor, largest: Optional[bool] = False) -> Tuple[Tensor, Tensor]:\n \"\"\"Return eigenpairs of A with specified ordering.\"\"\"\n if largest is None:\n largest = False\n E, Z = torch.linalg.eigh(A, UPLO=\"U\")\n # assuming that E is ordered\n if largest:\n E = torch.flip(E, dims=(-1,))\n Z = torch.flip(Z, dims=(-1,))\n return E, Z" }, { "id": 6721, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def measure_largest_eigval(W):\n assert(len(W.shape) == 2)\n ## W: embedding matrix, shape=[n_data, dim]\n eig_vals, _ = torch.linalg.eigh(torch.matmul(W.T, W))\n largest_eigval_ratio = torch.max(eig_vals) / torch.sum(eig_vals)\n return float(largest_eigval_ratio)", "probing input": "def measure_largest_eigval(W):\n assert(len(W.shape) == 2)\n ## W: embedding matrix, shape=[n_data, dim]\n", "probing input new": "def measure_largest_eigval(W):\n assert(len(W.shape) == 2)\n ## W: embedding matrix, shape=[n_data, dim]\n eig_vals, _ = torch.", "reference": "eig_vals,_=torch.linalg.eigh(torch.matmul(W.T,W))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eig_vals,_=torch.linalg.eigh(torch.matmul(W.T,W))", "y_neg": " eig_vals, _ = torch.symeig(W, eigenvectors=True)", "retain": "def measure_largest_eigval(W):\n assert(len(W.shape) == 2)\n ## W: embedding matrix, shape=[n_data, dim]\n eig_vals, _ = torch.linalg.eigh(torch.matmul(W.T, W))\n largest_eigval_ratio = torch.max(eig_vals) / torch.sum(eig_vals)\n return float(largest_eigval_ratio)" }, { "id": 6724, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_posenc_stats(data, is_undirected=True, laplacian_norm='sym', max_freqs=10, eigvec_norm='L2'):\n \"\"\"Precompute positional encodings for the given graph.\n\n Args:\n data: PyG graph\n pe_types: Positional encoding types to precompute statistics for.\n This can also be a combination, e.g. 'eigen+rw_landing'\n is_undirected: True if the graph is expected to be undirected\n cfg: Main configuration node\n\n Returns:\n Extended PyG Data object.\n \"\"\"\n\n # Basic preprocessing of the input graph.\n if hasattr(data, 'num_nodes'):\n N = data.num_nodes # Explicitly given number of nodes, e.g. ogbg-ppa\n else:\n N = data[\"region\"].x.shape[0] # Number of nodes, including disconnected nodes.\n laplacian_norm_type = laplacian_norm.lower()\n if laplacian_norm_type == 'none':\n laplacian_norm_type = None\n edge_index = torch.cat((data[\"region\", \"spatial\", \"region\"].edge_index, data[\"region\", \"temporal\", \"region\"].edge_index), dim=1).long()\n if is_undirected:\n undir_edge_index = edge_index\n else:\n undir_edge_index = to_undirected(edge_index)\n\n # Eigen values and vectors.\n evals, evects = None, None\n # Eigen-decomposition with numpy, can be reused for Heat kernels.\n L = to_scipy_sparse_matrix(\n *get_laplacian(undir_edge_index, normalization=laplacian_norm_type,\n num_nodes=N)\n )\n evals, evects = torch.linalg.eigh(torch.tensor(L.toarray()))\n evals = evals.numpy()\n evects = evects.numpy()\n \n data.EigVals, data.EigVecs = get_lap_decomp_stats(\n evals=evals, evects=evects,\n max_freqs=max_freqs,\n eigvec_norm=eigvec_norm)\n\n return data", "probing input": "def compute_posenc_stats(data, is_undirected=True, laplacian_norm='sym', max_freqs=10, eigvec_norm='L2'):\n \"\"\"Precompute positional encodings for the given graph.\n\n Args:\n data: PyG graph\n pe_types: Positional encoding types to precompute statistics for.\n This can also be a combination, e.g. 'eigen+rw_landing'\n is_undirected: True if the graph is expected to be undirected\n cfg: Main configuration node\n\n Returns:\n Extended PyG Data object.\n \"\"\"\n\n # Basic preprocessing of the input graph.\n if hasattr(data, 'num_nodes'):\n N = data.num_nodes # Explicitly given number of nodes, e.g. ogbg-ppa\n else:\n N = data[\"region\"].x.shape[0] # Number of nodes, including disconnected nodes.\n laplacian_norm_type = laplacian_norm.lower()\n if laplacian_norm_type == 'none':\n laplacian_norm_type = None\n edge_index = torch.cat((data[\"region\", \"spatial\", \"region\"].edge_index, data[\"region\", \"temporal\", \"region\"].edge_index), dim=1).long()\n if is_undirected:\n undir_edge_index = edge_index\n else:\n undir_edge_index = to_undirected(edge_index)\n\n # Eigen values and vectors.\n evals, evects = None, None\n # Eigen-decomposition with numpy, can be reused for Heat kernels.\n L = to_scipy_sparse_matrix(\n *get_laplacian(undir_edge_index, normalization=laplacian_norm_type,\n num_nodes=N)\n )\n", "probing input new": "def compute_posenc_stats(data, is_undirected=True, laplacian_norm='sym', max_freqs=10, eigvec_norm='L2'):\n \"\"\"Precompute positional encodings for the given graph.\n\n Args:\n data: PyG graph\n pe_types: Positional encoding types to precompute statistics for.\n This can also be a combination, e.g. 'eigen+rw_landing'\n is_undirected: True if the graph is expected to be undirected\n cfg: Main configuration node\n\n Returns:\n Extended PyG Data object.\n \"\"\"\n\n # Basic preprocessing of the input graph.\n if hasattr(data, 'num_nodes'):\n N = data.num_nodes # Explicitly given number of nodes, e.g. ogbg-ppa\n else:\n N = data[\"region\"].x.shape[0] # Number of nodes, including disconnected nodes.\n laplacian_norm_type = laplacian_norm.lower()\n if laplacian_norm_type == 'none':\n laplacian_norm_type = None\n edge_index = torch.cat((data[\"region\", \"spatial\", \"region\"].edge_index, data[\"region\", \"temporal\", \"region\"].edge_index), dim=1).long()\n if is_undirected:\n undir_edge_index = edge_index\n else:\n undir_edge_index = to_undirected(edge_index)\n\n # Eigen values and vectors.\n evals, evects = None, None\n # Eigen-decomposition with numpy, can be reused for Heat kernels.\n L = to_scipy_sparse_matrix(\n *get_laplacian(undir_edge_index, normalization=laplacian_norm_type,\n num_nodes=N)\n )\n evals, evects = torch.", "reference": "evals,evects=torch.linalg.eigh(torch.tensor(L.toarray()))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,evects=torch.linalg.eigh(torch.tensor(L.toarray()))", "y_neg": " evals, evects = torch.symeig(L, eigenvectors=True)", "retain": "def compute_posenc_stats(data, is_undirected=True, laplacian_norm='sym', max_freqs=10, eigvec_norm='L2'):\n \"\"\"Precompute positional encodings for the given graph.\n\n Args:\n data: PyG graph\n pe_types: Positional encoding types to precompute statistics for.\n This can also be a combination, e.g. 'eigen+rw_landing'\n is_undirected: True if the graph is expected to be undirected\n cfg: Main configuration node\n\n Returns:\n Extended PyG Data object.\n \"\"\"\n\n # Basic preprocessing of the input graph.\n if hasattr(data, 'num_nodes'):\n N = data.num_nodes # Explicitly given number of nodes, e.g. ogbg-ppa\n else:\n N = data[\"region\"].x.shape[0] # Number of nodes, including disconnected nodes.\n laplacian_norm_type = laplacian_norm.lower()\n if laplacian_norm_type == 'none':\n laplacian_norm_type = None\n edge_index = torch.cat((data[\"region\", \"spatial\", \"region\"].edge_index, data[\"region\", \"temporal\", \"region\"].edge_index), dim=1).long()\n if is_undirected:\n undir_edge_index = edge_index\n else:\n undir_edge_index = to_undirected(edge_index)\n\n # Eigen values and vectors.\n evals, evects = None, None\n # Eigen-decomposition with numpy, can be reused for Heat kernels.\n L = to_scipy_sparse_matrix(\n *get_laplacian(undir_edge_index, normalization=laplacian_norm_type,\n num_nodes=N)\n )\n evals, evects = torch.linalg.eigh(torch.tensor(L.toarray()))\n evals = evals.numpy()\n evects = evects.numpy()\n \n data.EigVals, data.EigVecs = get_lap_decomp_stats(\n evals=evals, evects=evects,\n max_freqs=max_freqs,\n eigvec_norm=eigvec_norm)\n\n return data" }, { "id": 6727, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sym_inv_sqrtm2(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Symmetric matrix inverse square root, with square root return also.\n\n Parameters\n ----------\n x : torch.Tensor\n symmetric matrix\n\n Returns\n -------\n Tuple[torch.Tensor, torch.Tensor]\n :math:`x^{-1/2}`, :math:`x^{1/2}`\n \"\"\"\n e, v = torch.linalg.eigh(x, \"U\")\n sqrt_e = torch.sqrt(e)\n inv_sqrt_e = torch.reciprocal(sqrt_e)\n return (\n v @ torch.diag_embed(inv_sqrt_e) @ v.transpose(-1, -2),\n v @ torch.diag_embed(sqrt_e) @ v.transpose(-1, -2),\n )", "probing input": "def sym_inv_sqrtm2(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Symmetric matrix inverse square root, with square root return also.\n\n Parameters\n ----------\n x : torch.Tensor\n symmetric matrix\n\n Returns\n -------\n Tuple[torch.Tensor, torch.Tensor]\n :math:`x^{-1/2}`, :math:`x^{1/2}`\n \"\"\"\n", "probing input new": "def sym_inv_sqrtm2(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Symmetric matrix inverse square root, with square root return also.\n\n Parameters\n ----------\n x : torch.Tensor\n symmetric matrix\n\n Returns\n -------\n Tuple[torch.Tensor, torch.Tensor]\n :math:`x^{-1/2}`, :math:`x^{1/2}`\n \"\"\"\n e, v = torch.", "reference": "e,v=torch.linalg.eigh(x,\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,v=torch.linalg.eigh(x,\"U\")", "y_neg": " e, v = torch.symeig(x, eigenvectors=True)", "retain": "def sym_inv_sqrtm2(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Symmetric matrix inverse square root, with square root return also.\n\n Parameters\n ----------\n x : torch.Tensor\n symmetric matrix\n\n Returns\n -------\n Tuple[torch.Tensor, torch.Tensor]\n :math:`x^{-1/2}`, :math:`x^{1/2}`\n \"\"\"\n e, v = torch.linalg.eigh(x, \"U\")\n sqrt_e = torch.sqrt(e)\n inv_sqrt_e = torch.reciprocal(sqrt_e)\n return (\n v @ torch.diag_embed(inv_sqrt_e) @ v.transpose(-1, -2),\n v @ torch.diag_embed(sqrt_e) @ v.transpose(-1, -2),\n )" }, { "id": 6733, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eig_coord_from_dist(D):\n M = (D[:, :1, :] + D[:, :, :1] - D) / 2\n L, V = torch.linalg.eigh(M)\n L = torch.diag_embed(L)\n X = torch.matmul(V, L.clamp(min=0).sqrt())\n return X[:, :, -3:].detach()", "probing input": "def eig_coord_from_dist(D):\n M = (D[:, :1, :] + D[:, :, :1] - D) / 2\n", "probing input new": "def eig_coord_from_dist(D):\n M = (D[:, :1, :] + D[:, :, :1] - D) / 2\n L, V = torch.", "reference": "L,V=torch.linalg.eigh(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,V=torch.linalg.eigh(M)", "y_neg": " L, V = torch.symeig(M, eigenvectors=True)", "retain": "def eig_coord_from_dist(D):\n M = (D[:, :1, :] + D[:, :, :1] - D) / 2\n L, V = torch.linalg.eigh(M)\n L = torch.diag_embed(L)\n X = torch.matmul(V, L.clamp(min=0).sqrt())\n return X[:, :, -3:].detach()" }, { "id": 6734, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def matrix_to_quaternion(rot):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]", "probing input": "def matrix_to_quaternion(rot):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n", "probing input new": "def matrix_to_quaternion(rot):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def matrix_to_quaternion(rot):\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]" }, { "id": 6735, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_pos_emb(h, w, dim):\n g = [[] for _ in range(h * w)]\n for i in range(h):\n for j in range(w):\n idx = i * h + j\n if i - 1 >= 0:\n g[idx].append(idx - h)\n if i + 1 < h:\n g[idx].append(idx + h)\n if j - 1 >= 0:\n g[idx].append(idx - 1)\n if j + 1 < w:\n g[idx].append(idx + 1)\n a = torch.zeros(h * w, h * w)\n d_isqrt = torch.zeros(h * w, h * w)\n for i, node in enumerate(g):\n for edge in node:\n a[i, edge] = 1\n d_isqrt[i, i] = 1 / math.sqrt(len(node))\n eye = torch.eye(h * w)\n lap = eye - d_isqrt @ a @ d_isqrt\n vals, vecs = torch.linalg.eigh(lap)\n # proj = torch.nn.init.orthogonal_(torch.empty(dim, h * w), math.sqrt(h * w / dim))\n return vecs[:dim, :].T * math.sqrt(h * w)", "probing input": "def make_pos_emb(h, w, dim):\n g = [[] for _ in range(h * w)]\n for i in range(h):\n for j in range(w):\n idx = i * h + j\n if i - 1 >= 0:\n g[idx].append(idx - h)\n if i + 1 < h:\n g[idx].append(idx + h)\n if j - 1 >= 0:\n g[idx].append(idx - 1)\n if j + 1 < w:\n g[idx].append(idx + 1)\n a = torch.zeros(h * w, h * w)\n d_isqrt = torch.zeros(h * w, h * w)\n for i, node in enumerate(g):\n for edge in node:\n a[i, edge] = 1\n d_isqrt[i, i] = 1 / math.sqrt(len(node))\n eye = torch.eye(h * w)\n lap = eye - d_isqrt @ a @ d_isqrt\n", "probing input new": "def make_pos_emb(h, w, dim):\n g = [[] for _ in range(h * w)]\n for i in range(h):\n for j in range(w):\n idx = i * h + j\n if i - 1 >= 0:\n g[idx].append(idx - h)\n if i + 1 < h:\n g[idx].append(idx + h)\n if j - 1 >= 0:\n g[idx].append(idx - 1)\n if j + 1 < w:\n g[idx].append(idx + 1)\n a = torch.zeros(h * w, h * w)\n d_isqrt = torch.zeros(h * w, h * w)\n for i, node in enumerate(g):\n for edge in node:\n a[i, edge] = 1\n d_isqrt[i, i] = 1 / math.sqrt(len(node))\n eye = torch.eye(h * w)\n lap = eye - d_isqrt @ a @ d_isqrt\n vals, vecs = torch.", "reference": "vals,vecs=torch.linalg.eigh(lap)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "vals,vecs=torch.linalg.eigh(lap)", "y_neg": " vals, vecs = torch.symeig(lap, eigenvectors=True)", "retain": "def make_pos_emb(h, w, dim):\n g = [[] for _ in range(h * w)]\n for i in range(h):\n for j in range(w):\n idx = i * h + j\n if i - 1 >= 0:\n g[idx].append(idx - h)\n if i + 1 < h:\n g[idx].append(idx + h)\n if j - 1 >= 0:\n g[idx].append(idx - 1)\n if j + 1 < w:\n g[idx].append(idx + 1)\n a = torch.zeros(h * w, h * w)\n d_isqrt = torch.zeros(h * w, h * w)\n for i, node in enumerate(g):\n for edge in node:\n a[i, edge] = 1\n d_isqrt[i, i] = 1 / math.sqrt(len(node))\n eye = torch.eye(h * w)\n lap = eye - d_isqrt @ a @ d_isqrt\n vals, vecs = torch.linalg.eigh(lap)\n # proj = torch.nn.init.orthogonal_(torch.empty(dim, h * w), math.sqrt(h * w / dim))\n return vecs[:dim, :].T * math.sqrt(h * w)" }, { "id": 6738, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sqrtmh(A):\n \"\"\"Compute the square root of a symmetric positive definite matrix.\"\"\"\n L, Q = torch.linalg.eigh(A)\n zero = torch.zeros((), device=L.device, dtype=L.dtype)\n threshold = L.max(-1).values * L.size(-1) * torch.finfo(L.dtype).eps\n L = L.where(L > threshold.unsqueeze(-1), zero) # zero out small components\n return (Q * L.sqrt().unsqueeze(-2)) @ Q.mH", "probing input": "def sqrtmh(A):\n \"\"\"Compute the square root of a symmetric positive definite matrix.\"\"\"\n", "probing input new": "def sqrtmh(A):\n \"\"\"Compute the square root of a symmetric positive definite matrix.\"\"\"\n L, Q = torch.", "reference": "L,Q=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,Q=torch.linalg.eigh(A)", "y_neg": " L, Q = torch.symeig(A, eigenvectors=True)", "retain": "def sqrtmh(A):\n \"\"\"Compute the square root of a symmetric positive definite matrix.\"\"\"\n L, Q = torch.linalg.eigh(A)\n zero = torch.zeros((), device=L.device, dtype=L.dtype)\n threshold = L.max(-1).values * L.size(-1) * torch.finfo(L.dtype).eps\n L = L.where(L > threshold.unsqueeze(-1), zero) # zero out small components\n return (Q * L.sqrt().unsqueeze(-2)) @ Q.mH" }, { "id": 6739, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigensolver(M):\n \"\"\" Eigensolver\n manually symmetrize M before the eigen decomposition\n \"\"\"\n return torch.linalg.eigh(0.5*(M+M.t()))", "probing input": "def eigensolver(M):\n \"\"\" Eigensolver\n manually symmetrize M before the eigen decomposition\n \"\"\"\n", "probing input new": "def eigensolver(M):\n \"\"\" Eigensolver\n manually symmetrize M before the eigen decomposition\n \"\"\"\n return torch.", "reference": "returntorch.linalg.eigh(0.5*(M+M.t()))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "returntorch.linalg.eigh(0.5*(M+M.t()))", "y_neg": " return torch.symeig(M, eigenvectors=True)", "retain": "def eigensolver(M):\n \"\"\" Eigensolver\n manually symmetrize M before the eigen decomposition\n \"\"\"\n return torch.linalg.eigh(0.5*(M+M.t()))" }, { "id": 6740, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n, c, h, w = patches.shape\n est_covariance = torch.cov(patches.view(n, c * h * w).t())\n eigenvalues, eigenvectors = torch.linalg.eigh(\n est_covariance, UPLO=\"U\"\n ) # this is the same as saying we want our eigenvectors, with the specification that the matrix be an upper triangular matrix (instead of a lower-triangular matrix)\n return eigenvalues.flip(0).view(-1, 1, 1, 1), eigenvectors.t().reshape(\n c * h * w, c, h, w\n ).flip(0)", "probing input": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n, c, h, w = patches.shape\n est_covariance = torch.cov(patches.view(n, c * h * w).t())\n", "probing input new": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n, c, h, w = patches.shape\n est_covariance = torch.cov(patches.view(n, c * h * w).t())\n eigenvalues, eigenvectors = torch.", "reference": "eigenvalues,eigenvectors=torch.linalg.eigh(est_covariance,UPLO=\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,eigenvectors=torch.linalg.eigh(est_covariance,UPLO=\"U\")", "y_neg": " eigenvalues, eigenvectors = torch.symeig(est_covariance, eigenvectors=True)", "retain": "def get_whitening_parameters(patches):\n # As a high-level summary, we're basically finding the high-dimensional oval that best fits the data here.\n # We can then later use this information to map the input information to a nicely distributed sphere, where also\n # the most significant features of the inputs each have their own axis. This significantly cleans things up for the\n # rest of the neural network and speeds up training.\n n, c, h, w = patches.shape\n est_covariance = torch.cov(patches.view(n, c * h * w).t())\n eigenvalues, eigenvectors = torch.linalg.eigh(\n est_covariance, UPLO=\"U\"\n ) # this is the same as saying we want our eigenvectors, with the specification that the matrix be an upper triangular matrix (instead of a lower-triangular matrix)\n return eigenvalues.flip(0).view(-1, 1, 1, 1), eigenvectors.t().reshape(\n c * h * w, c, h, w\n ).flip(0)" }, { "id": 6741, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def extract_rot_scale(cov: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n # we add eps to the diagonal to make sure we never get negative eigenvalues\n S, R = torch.linalg.eigh(cov + torch.eye(3, device=cov.device) * 1e-8, UPLO=\"U\")\n scaling = S.sqrt().nan_to_num(nan=1e-6)\n # we multiply with the determinant to make sure the\n # rotation matrix has determinant +1\n # the matrix_to_quaternion function assumes this\n rot = normalize(matrix_to_quaternion(R * R.det()[..., None, None]))\n return rot, scaling", "probing input": "def extract_rot_scale(cov: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n # we add eps to the diagonal to make sure we never get negative eigenvalues\n", "probing input new": "def extract_rot_scale(cov: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n # we add eps to the diagonal to make sure we never get negative eigenvalues\n S, R = torch.", "reference": "S,R=torch.linalg.eigh(cov+torch.eye(3,device=cov.device)*1e-8,UPLO=\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "S,R=torch.linalg.eigh(cov+torch.eye(3,device=cov.device)*1e-8,UPLO=\"U\")", "y_neg": " S, R = torch.symeig(cov + torch.eye(cov.size(0)).to(cov.device), eigenvectors=True)", "retain": "def extract_rot_scale(cov: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:\n # we add eps to the diagonal to make sure we never get negative eigenvalues\n S, R = torch.linalg.eigh(cov + torch.eye(3, device=cov.device) * 1e-8, UPLO=\"U\")\n scaling = S.sqrt().nan_to_num(nan=1e-6)\n # we multiply with the determinant to make sure the\n # rotation matrix has determinant +1\n # the matrix_to_quaternion function assumes this\n rot = normalize(matrix_to_quaternion(R * R.det()[..., None, None]))\n return rot, scaling" }, { "id": 6745, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _project_impl(self, pt: Point) -> Point:\n assert pt.shape == (self.m, self.m), \\\n f\"Input to AngularCKA.project() must be a m by m matrix but is size {pt.shape}!\"\n # 1. Ensure matrix is symmetric\n pt = (pt + pt.T) / 2\n if self._unbiased:\n # 2a. Normally we would enforce positive (semi-) definiteness, but we can't guarantee that here due to\n # the masking of the diagonal of the pt matrix\n pass\n # 3a. If the unbiased flag is set, we cannot risk calling center() a second time on the same data, since\n # this would be essentially center(mask * center(data)), and the outer center will interact with the mask\n mask = torch.ones_like(pt) - torch.eye(self.m, dtype=pt.dtype, device=pt.device)\n pt = _matrix_unit_norm(mask * pt)\n else:\n # 2b. Ensure matrix is positive (semi-) definite by clipping its eigenvalues\n e, v = torch.linalg.eigh(pt)\n e = torch.clip(e, min=0., max=None)\n pt = v @ torch.diag(e) @ v.T\n # 3b. If the unbiased flag is not set, we can be extra careful here and both center and normalize. Centering\n # twice is the same as centering once, so we don't need to worry whether pt is already centered.\n pt = _matrix_unit_norm(center(pt))\n return pt", "probing input": " def _project_impl(self, pt: Point) -> Point:\n assert pt.shape == (self.m, self.m), \\\n f\"Input to AngularCKA.project() must be a m by m matrix but is size {pt.shape}!\"\n # 1. Ensure matrix is symmetric\n pt = (pt + pt.T) / 2\n if self._unbiased:\n # 2a. Normally we would enforce positive (semi-) definiteness, but we can't guarantee that here due to\n # the masking of the diagonal of the pt matrix\n pass\n # 3a. If the unbiased flag is set, we cannot risk calling center() a second time on the same data, since\n # this would be essentially center(mask * center(data)), and the outer center will interact with the mask\n mask = torch.ones_like(pt) - torch.eye(self.m, dtype=pt.dtype, device=pt.device)\n pt = _matrix_unit_norm(mask * pt)\n else:\n # 2b. Ensure matrix is positive (semi-) definite by clipping its eigenvalues\n", "probing input new": " def _project_impl(self, pt: Point) -> Point:\n assert pt.shape == (self.m, self.m), \\\n f\"Input to AngularCKA.project() must be a m by m matrix but is size {pt.shape}!\"\n # 1. Ensure matrix is symmetric\n pt = (pt + pt.T) / 2\n if self._unbiased:\n # 2a. Normally we would enforce positive (semi-) definiteness, but we can't guarantee that here due to\n # the masking of the diagonal of the pt matrix\n pass\n # 3a. If the unbiased flag is set, we cannot risk calling center() a second time on the same data, since\n # this would be essentially center(mask * center(data)), and the outer center will interact with the mask\n mask = torch.ones_like(pt) - torch.eye(self.m, dtype=pt.dtype, device=pt.device)\n pt = _matrix_unit_norm(mask * pt)\n else:\n # 2b. Ensure matrix is positive (semi-) definite by clipping its eigenvalues\n e, v = torch.", "reference": "e,v=torch.linalg.eigh(pt)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,v=torch.linalg.eigh(pt)", "y_neg": " e, v = torch.symeig(pt, eigenvectors=True)", "retain": " def _project_impl(self, pt: Point) -> Point:\n assert pt.shape == (self.m, self.m), \\\n f\"Input to AngularCKA.project() must be a m by m matrix but is size {pt.shape}!\"\n # 1. Ensure matrix is symmetric\n pt = (pt + pt.T) / 2\n if self._unbiased:\n # 2a. Normally we would enforce positive (semi-) definiteness, but we can't guarantee that here due to\n # the masking of the diagonal of the pt matrix\n pass\n # 3a. If the unbiased flag is set, we cannot risk calling center() a second time on the same data, since\n # this would be essentially center(mask * center(data)), and the outer center will interact with the mask\n mask = torch.ones_like(pt) - torch.eye(self.m, dtype=pt.dtype, device=pt.device)\n pt = _matrix_unit_norm(mask * pt)\n else:\n # 2b. Ensure matrix is positive (semi-) definite by clipping its eigenvalues\n e, v = torch.linalg.eigh(pt)\n e = torch.clip(e, min=0., max=None)\n pt = v @ torch.diag(e) @ v.T\n # 3b. If the unbiased flag is not set, we can be extra careful here and both center and normalize. Centering\n # twice is the same as centering once, so we don't need to worry whether pt is already centered.\n pt = _matrix_unit_norm(center(pt))\n return pt" }, { "id": 6749, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __getitem__(self, idx):\n '''\n neighbor: n-1\n '''\n x = self.data[idx + self.x_offsets, :, :self.input_dim] #[t, node, dim]\n y = self.data[idx + self.y_offsets, :, :self.output_dim]\n \n par = self._adj2par(self.edge_index, self.n_nodes, self.edge_index.shape[1]).to_dense()\n L0 = torch.matmul(par, par.T)\n lambda0, _ = torch.linalg.eigh(L0)\n L1 = torch.matmul(par.T, par)\n edge_index_t, edge_weight_t = dense_to_sparse(2*L0/lambda0.max())\n edge_index_s, edge_weight_s = dense_to_sparse(2*L1/lambda0.max())\n \n time_delay_sim = self._time_delay_similarity_full(x)\n x_s = torch.cat([self.edge_attr, time_delay_sim], -1) #[n_edge, 2 + l//scaler]\n x_t = x.permute(1,0,2)\n \n graph = PairData(x_s=x_s, edge_index_s=edge_index_s, edge_weight_s=edge_weight_s, # edge\n x_t=x_t, edge_index_t=edge_index_t, edge_weight_t=edge_weight_t, # node\n y = y)\n graph.edge_index = self.edge_index\n graph.num_nodes = self.n_nodes\n \n return [graph, y]", "probing input": " def __getitem__(self, idx):\n '''\n neighbor: n-1\n '''\n x = self.data[idx + self.x_offsets, :, :self.input_dim] #[t, node, dim]\n y = self.data[idx + self.y_offsets, :, :self.output_dim]\n \n par = self._adj2par(self.edge_index, self.n_nodes, self.edge_index.shape[1]).to_dense()\n L0 = torch.matmul(par, par.T)\n", "probing input new": " def __getitem__(self, idx):\n '''\n neighbor: n-1\n '''\n x = self.data[idx + self.x_offsets, :, :self.input_dim] #[t, node, dim]\n y = self.data[idx + self.y_offsets, :, :self.output_dim]\n \n par = self._adj2par(self.edge_index, self.n_nodes, self.edge_index.shape[1]).to_dense()\n L0 = torch.matmul(par, par.T)\n lambda0, _ = torch.", "reference": "lambda0,_=torch.linalg.eigh(L0)", "reference dict": { "graph": "PairData" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "lambda0,_=torch.linalg.eigh(L0)", "y_neg": " lambda0, _ = torch.symeig(L0, eigenvectors=True)", "retain": " def __getitem__(self, idx):\n '''\n neighbor: n-1\n '''\n x = self.data[idx + self.x_offsets, :, :self.input_dim] #[t, node, dim]\n y = self.data[idx + self.y_offsets, :, :self.output_dim]\n \n par = self._adj2par(self.edge_index, self.n_nodes, self.edge_index.shape[1]).to_dense()\n L0 = torch.matmul(par, par.T)\n lambda0, _ = torch.linalg.eigh(L0)\n L1 = torch.matmul(par.T, par)\n edge_index_t, edge_weight_t = dense_to_sparse(2*L0/lambda0.max())\n edge_index_s, edge_weight_s = dense_to_sparse(2*L1/lambda0.max())\n \n time_delay_sim = self._time_delay_similarity_full(x)\n x_s = torch.cat([self.edge_attr, time_delay_sim], -1) #[n_edge, 2 + l//scaler]\n x_t = x.permute(1,0,2)\n \n graph = PairData(x_s=x_s, edge_index_s=edge_index_s, edge_weight_s=edge_weight_s, # edge\n x_t=x_t, edge_index_t=edge_index_t, edge_weight_t=edge_weight_t, # node\n y = y)\n graph.edge_index = self.edge_index\n graph.num_nodes = self.n_nodes\n \n return [graph, y]" }, { "id": 6750, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_kfe(self, mod: LayerType):\n \"\"\"Computes the covariances.\"\"\"\n state = self.state_storage[mod]\n x = state.x # (N, in, xh, xw)\n gy = state.gy # (N, out, yh, yw)\n\n if isinstance(mod, nn.Conv2d):\n state.num_locations = gy.size(2) * gy.size(3) # yh * yw\n if not self.sua:\n x = self.filter_dict[mod](x) # (N, in * kh * kw, yh, yw)\n # (in [* kh * kw], N * [yh * yw]{xh * xw})\n x = x.transpose(0, 1).flatten(1)\n gy = gy.transpose(0, 1).flatten(1) # (out, N * yh * yw)\n else:\n state.num_locations = 1\n x = x.t() # (in, N)\n gy = gy.t() # (out, N)\n\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones]) # (in [* kh * kw] + 1, N * yh * yw)\n # (in [* kh * kw] + 1, in [* kh * kw] + 1)\n xxt = x.mm(x.t()) / x.size(1)\n ggt = gy.mm(gy.t()) / gy.size(1) # (out, out)\n\n Ex, state.kfe_x = torch.linalg.eigh(xxt)\n Eg, state.kfe_gy = torch.linalg.eigh(ggt)\n Ex: torch.Tensor # (in [* kh * kw] + 1)\n Eg: torch.Tensor # (out)\n state.m2 = state.num_locations * \\\n Eg.outer(Ex) # (out, in [* kh * kw] + 1)\n if isinstance(mod, nn.Conv2d) and self.sua:\n kh, kw = mod.kernel_size\n state.m2 = state.m2[..., None, None].repeat(\n 1, 1, kh, kw)", "probing input": " def compute_kfe(self, mod: LayerType):\n \"\"\"Computes the covariances.\"\"\"\n state = self.state_storage[mod]\n x = state.x # (N, in, xh, xw)\n gy = state.gy # (N, out, yh, yw)\n\n if isinstance(mod, nn.Conv2d):\n state.num_locations = gy.size(2) * gy.size(3) # yh * yw\n if not self.sua:\n x = self.filter_dict[mod](x) # (N, in * kh * kw, yh, yw)\n # (in [* kh * kw], N * [yh * yw]{xh * xw})\n x = x.transpose(0, 1).flatten(1)\n gy = gy.transpose(0, 1).flatten(1) # (out, N * yh * yw)\n else:\n state.num_locations = 1\n x = x.t() # (in, N)\n gy = gy.t() # (out, N)\n\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones]) # (in [* kh * kw] + 1, N * yh * yw)\n # (in [* kh * kw] + 1, in [* kh * kw] + 1)\n xxt = x.mm(x.t()) / x.size(1)\n ggt = gy.mm(gy.t()) / gy.size(1) # (out, out)\n\n", "probing input new": " def compute_kfe(self, mod: LayerType):\n \"\"\"Computes the covariances.\"\"\"\n state = self.state_storage[mod]\n x = state.x # (N, in, xh, xw)\n gy = state.gy # (N, out, yh, yw)\n\n if isinstance(mod, nn.Conv2d):\n state.num_locations = gy.size(2) * gy.size(3) # yh * yw\n if not self.sua:\n x = self.filter_dict[mod](x) # (N, in * kh * kw, yh, yw)\n # (in [* kh * kw], N * [yh * yw]{xh * xw})\n x = x.transpose(0, 1).flatten(1)\n gy = gy.transpose(0, 1).flatten(1) # (out, N * yh * yw)\n else:\n state.num_locations = 1\n x = x.t() # (in, N)\n gy = gy.t() # (out, N)\n\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones]) # (in [* kh * kw] + 1, N * yh * yw)\n # (in [* kh * kw] + 1, in [* kh * kw] + 1)\n xxt = x.mm(x.t()) / x.size(1)\n ggt = gy.mm(gy.t()) / gy.size(1) # (out, out)\n\n Ex, state.kfe_x = torch.", "reference": "Ex,state.kfe_x=torch.linalg.eigh(xxt)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "Ex,state.kfe_x=torch.linalg.eigh(xxt)", "y_neg": " Ex, state.kfe_x = torch.symeig(xxt, eigenvectors=True)", "retain": " def compute_kfe(self, mod: LayerType):\n \"\"\"Computes the covariances.\"\"\"\n state = self.state_storage[mod]\n x = state.x # (N, in, xh, xw)\n gy = state.gy # (N, out, yh, yw)\n\n if isinstance(mod, nn.Conv2d):\n state.num_locations = gy.size(2) * gy.size(3) # yh * yw\n if not self.sua:\n x = self.filter_dict[mod](x) # (N, in * kh * kw, yh, yw)\n # (in [* kh * kw], N * [yh * yw]{xh * xw})\n x = x.transpose(0, 1).flatten(1)\n gy = gy.transpose(0, 1).flatten(1) # (out, N * yh * yw)\n else:\n state.num_locations = 1\n x = x.t() # (in, N)\n gy = gy.t() # (out, N)\n\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones]) # (in [* kh * kw] + 1, N * yh * yw)\n # (in [* kh * kw] + 1, in [* kh * kw] + 1)\n xxt = x.mm(x.t()) / x.size(1)\n ggt = gy.mm(gy.t()) / gy.size(1) # (out, out)\n\n Ex, state.kfe_x = torch.linalg.eigh(xxt)\n Eg, state.kfe_gy = torch.linalg.eigh(ggt)\n Ex: torch.Tensor # (in [* kh * kw] + 1)\n Eg: torch.Tensor # (out)\n state.m2 = state.num_locations * \\\n Eg.outer(Ex) # (out, in [* kh * kw] + 1)\n if isinstance(mod, nn.Conv2d) and self.sua:\n kh, kw = mod.kernel_size\n state.m2 = state.m2[..., None, None].repeat(\n 1, 1, kh, kw)" }, { "id": 6755, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def stable_symmetric_inverse(A, ret_sqrt=False):\n \"\"\"\n Utility function to return stable inverse A^(-1) or sqrt of inverse A^(-0.5) of a symmetric matrix A\n Ref.: https://github.com/markovmodel/deeptime\n\n Proceeds by diagonalizing matrix, setting eigenvalues smaller than threshold to zero, performing operations\n on diagonlized matrix, reprojecting back to original basis\n\n Parameters\n ----------\n A : torch.tensor\n symmetric matrix\n\n ret_sqrt : bool, default = False\n indicator flag as to whether to return square root of inverse\n\n Return\n ------\n B : torch.tensor\n stable inverse approximation to A^(-1) or A^(-0.5) depending on ret_sqrt flag\n \"\"\"\n assert torch.allclose(A, A.t(), atol=1e-6)\n\n w, V = torch.linalg.eigh(A)\n\n w = torch.where(w > torch.finfo(torch.float32).eps, w, torch.zeros_like(w))\n\n if ret_sqrt:\n B = torch.matmul(V, torch.matmul(torch.diag(w ** (-0.5)), V.t()))\n else:\n B = torch.matmul(V, torch.matmul(torch.diag(w ** (-1.0)), V.t()))\n\n return B", "probing input": "def stable_symmetric_inverse(A, ret_sqrt=False):\n \"\"\"\n Utility function to return stable inverse A^(-1) or sqrt of inverse A^(-0.5) of a symmetric matrix A\n Ref.: https://github.com/markovmodel/deeptime\n\n Proceeds by diagonalizing matrix, setting eigenvalues smaller than threshold to zero, performing operations\n on diagonlized matrix, reprojecting back to original basis\n\n Parameters\n ----------\n A : torch.tensor\n symmetric matrix\n\n ret_sqrt : bool, default = False\n indicator flag as to whether to return square root of inverse\n\n Return\n ------\n B : torch.tensor\n stable inverse approximation to A^(-1) or A^(-0.5) depending on ret_sqrt flag\n \"\"\"\n assert torch.allclose(A, A.t(), atol=1e-6)\n\n", "probing input new": "def stable_symmetric_inverse(A, ret_sqrt=False):\n \"\"\"\n Utility function to return stable inverse A^(-1) or sqrt of inverse A^(-0.5) of a symmetric matrix A\n Ref.: https://github.com/markovmodel/deeptime\n\n Proceeds by diagonalizing matrix, setting eigenvalues smaller than threshold to zero, performing operations\n on diagonlized matrix, reprojecting back to original basis\n\n Parameters\n ----------\n A : torch.tensor\n symmetric matrix\n\n ret_sqrt : bool, default = False\n indicator flag as to whether to return square root of inverse\n\n Return\n ------\n B : torch.tensor\n stable inverse approximation to A^(-1) or A^(-0.5) depending on ret_sqrt flag\n \"\"\"\n assert torch.allclose(A, A.t(), atol=1e-6)\n\n w, V = torch.", "reference": "w,V=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,V=torch.linalg.eigh(A)", "y_neg": " w, V = torch.symeig(A, eigenvectors=True)", "retain": "def stable_symmetric_inverse(A, ret_sqrt=False):\n \"\"\"\n Utility function to return stable inverse A^(-1) or sqrt of inverse A^(-0.5) of a symmetric matrix A\n Ref.: https://github.com/markovmodel/deeptime\n\n Proceeds by diagonalizing matrix, setting eigenvalues smaller than threshold to zero, performing operations\n on diagonlized matrix, reprojecting back to original basis\n\n Parameters\n ----------\n A : torch.tensor\n symmetric matrix\n\n ret_sqrt : bool, default = False\n indicator flag as to whether to return square root of inverse\n\n Return\n ------\n B : torch.tensor\n stable inverse approximation to A^(-1) or A^(-0.5) depending on ret_sqrt flag\n \"\"\"\n assert torch.allclose(A, A.t(), atol=1e-6)\n\n w, V = torch.linalg.eigh(A)\n\n w = torch.where(w > torch.finfo(torch.float32).eps, w, torch.zeros_like(w))\n\n if ret_sqrt:\n B = torch.matmul(V, torch.matmul(torch.diag(w ** (-0.5)), V.t()))\n else:\n B = torch.matmul(V, torch.matmul(torch.diag(w ** (-1.0)), V.t()))\n\n return B" }, { "id": 6758, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n # compute eigenvectors\n _, eigvecs = torch.linalg.eigh(cov(ODhat.T)) \n eigvecs = eigvecs[:, [1, 2]]\n\n HE = self.__find_HE(ODhat, eigvecs, alpha)\n\n C = self.__find_concentration(OD, HE)\n maxC = torch.stack([percentile(C[0, :], 99), percentile(C[1, :], 99)])\n\n return HE, C, maxC", "probing input": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n # compute eigenvectors\n", "probing input new": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n # compute eigenvectors\n _, eigvecs = torch.", "reference": "_,eigvecs=torch.linalg.eigh(cov(ODhat.T))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,eigvecs=torch.linalg.eigh(cov(ODhat.T))", "y_neg": " _, eigvecs = torch.symeig(ODhat, eigenvectors=True)", "retain": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n # compute eigenvectors\n _, eigvecs = torch.linalg.eigh(cov(ODhat.T)) \n eigvecs = eigvecs[:, [1, 2]]\n\n HE = self.__find_HE(ODhat, eigvecs, alpha)\n\n C = self.__find_concentration(OD, HE)\n maxC = torch.stack([percentile(C[0, :], 99), percentile(C[1, :], 99)])\n\n return HE, C, maxC" }, { "id": 6762, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def frame_averaging_3D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n Base case for 3D inputs.\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used\n (stochastic, det, all, se3-all, se3-det, se3-stochastic)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos = pos - pos.mean(dim=0, keepdim=True)\n C = torch.matmul(pos.t(), pos)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.linalg.eigh(C)\n\n # Sort, if necessary\n idx = eigenval.argsort(descending=True)\n eigenvec = eigenvec[:, idx]\n eigenval = eigenval[idx]\n\n # Check if constraints are satisfied\n if check:\n check_constraints(eigenval, eigenvec, 3)\n\n # Compute fa_pos\n fa_pos, fa_cell, fa_rot = compute_frames(eigenvec, pos, cell, fa_method)\n\n # No need to update distances, they are preserved.\n\n return fa_pos, fa_cell, fa_rot", "probing input": "def frame_averaging_3D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n Base case for 3D inputs.\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used\n (stochastic, det, all, se3-all, se3-det, se3-stochastic)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos = pos - pos.mean(dim=0, keepdim=True)\n C = torch.matmul(pos.t(), pos)\n\n # Eigendecomposition\n", "probing input new": "def frame_averaging_3D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n Base case for 3D inputs.\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used\n (stochastic, det, all, se3-all, se3-det, se3-stochastic)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos = pos - pos.mean(dim=0, keepdim=True)\n C = torch.matmul(pos.t(), pos)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.", "reference": "eigenval,eigenvec=torch.linalg.eigh(C)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenval,eigenvec=torch.linalg.eigh(C)", "y_neg": " eigenval, eigenvec = torch.symeig(C, eigenvectors=True)", "retain": "def frame_averaging_3D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n Base case for 3D inputs.\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used\n (stochastic, det, all, se3-all, se3-det, se3-stochastic)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos = pos - pos.mean(dim=0, keepdim=True)\n C = torch.matmul(pos.t(), pos)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.linalg.eigh(C)\n\n # Sort, if necessary\n idx = eigenval.argsort(descending=True)\n eigenvec = eigenvec[:, idx]\n eigenval = eigenval[idx]\n\n # Check if constraints are satisfied\n if check:\n check_constraints(eigenval, eigenvec, 3)\n\n # Compute fa_pos\n fa_pos, fa_cell, fa_rot = compute_frames(eigenvec, pos, cell, fa_method)\n\n # No need to update distances, they are preserved.\n\n return fa_pos, fa_cell, fa_rot" }, { "id": 6763, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def frame_averaging_2D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n 2D case: we project the atoms on the plane orthogonal to the z-axis.\n Motivation: sometimes, the z-axis is not the most relevant one (e.g. fixed).\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used (stochastic, det, all, se3)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos_2D = pos[:, :2] - pos[:, :2].mean(dim=0, keepdim=True)\n C = torch.matmul(pos_2D.t(), pos_2D)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.linalg.eigh(C)\n # Sort eigenvalues\n idx = eigenval.argsort(descending=True)\n eigenval = eigenval[idx]\n eigenvec = eigenvec[:, idx]\n\n # Check if constraints are satisfied\n if check:\n check_constraints(eigenval, eigenvec, 3)\n\n # Compute all frames\n fa_pos, fa_cell, fa_rot = compute_frames(\n eigenvec,\n pos_2D,\n cell,\n fa_method,\n pos[:, 2],\n )\n # No need to update distances, they are preserved.\n\n return fa_pos, fa_cell, fa_rot", "probing input": "def frame_averaging_2D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n 2D case: we project the atoms on the plane orthogonal to the z-axis.\n Motivation: sometimes, the z-axis is not the most relevant one (e.g. fixed).\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used (stochastic, det, all, se3)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos_2D = pos[:, :2] - pos[:, :2].mean(dim=0, keepdim=True)\n C = torch.matmul(pos_2D.t(), pos_2D)\n\n # Eigendecomposition\n", "probing input new": "def frame_averaging_2D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n 2D case: we project the atoms on the plane orthogonal to the z-axis.\n Motivation: sometimes, the z-axis is not the most relevant one (e.g. fixed).\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used (stochastic, det, all, se3)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos_2D = pos[:, :2] - pos[:, :2].mean(dim=0, keepdim=True)\n C = torch.matmul(pos_2D.t(), pos_2D)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.", "reference": "eigenval,eigenvec=torch.linalg.eigh(C)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenval,eigenvec=torch.linalg.eigh(C)", "y_neg": " eigenval, eigenvec = torch.symeig(C, eigenvectors=True)", "retain": "def frame_averaging_2D(pos, cell=None, fa_method=\"stochastic\", check=False):\n \"\"\"Computes new positions for the graph atoms using\n frame averaging, which itself builds on the PCA of atom positions.\n 2D case: we project the atoms on the plane orthogonal to the z-axis.\n Motivation: sometimes, the z-axis is not the most relevant one (e.g. fixed).\n\n Args:\n pos (tensor): positions of atoms in the graph\n cell (tensor): unit cell of the graph. None if no pbc.\n fa_method (str): FA method used (stochastic, det, all, se3)\n check (bool): check if constraints are satisfied. Default: False.\n\n Returns:\n (tensor): updated atom positions\n (tensor): updated unit cell\n (tensor): the rotation matrix used (PCA)\n \"\"\"\n\n # Compute centroid and covariance\n pos_2D = pos[:, :2] - pos[:, :2].mean(dim=0, keepdim=True)\n C = torch.matmul(pos_2D.t(), pos_2D)\n\n # Eigendecomposition\n eigenval, eigenvec = torch.linalg.eigh(C)\n # Sort eigenvalues\n idx = eigenval.argsort(descending=True)\n eigenval = eigenval[idx]\n eigenvec = eigenvec[:, idx]\n\n # Check if constraints are satisfied\n if check:\n check_constraints(eigenval, eigenvec, 3)\n\n # Compute all frames\n fa_pos, fa_cell, fa_rot = compute_frames(\n eigenvec,\n pos_2D,\n cell,\n fa_method,\n pos[:, 2],\n )\n # No need to update distances, they are preserved.\n\n return fa_pos, fa_cell, fa_rot" }, { "id": 6764, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_pos_def_torch(x):\n \"\"\"\n Force a square symmetric matrix to be positive semi definite\n \"\"\"\n w, v = torch.linalg.eigh(torch.real(x))\n w_pos = torch.clip(w, 0, None)\n nonzero_w = w_pos[w_pos > 0]\n w_new = w_pos\n if nonzero_w.shape[0] > 0:\n if nonzero_w.shape[0] < w.shape[0]:\n # min_w = max(torch.max(nonzero_w)*1e-5,torch.min(nonzero_w))\n min_w = max(torch.max(nonzero_w) * 0.1, torch.min(nonzero_w))\n w_new = w_pos + min_w\n elif nonzero_w.shape[0] == 0:\n eprint(\n \"No positive eigenvalues for A {}. w={} {}, w_pos={} {}, nonzero_w={}\".format(\n x, w, w.shape, w_pos, w_pos.shape, nonzero_w\n )\n )\n w_new = torch.ones_like(w)\n x_star = v @ np.diag(w_new) @ v.T\n p = torch.sqrt(torch.sum(torch.abs(w)) / torch.sum(torch.abs(w_new)))\n return p * x_star", "probing input": "def make_pos_def_torch(x):\n \"\"\"\n Force a square symmetric matrix to be positive semi definite\n \"\"\"\n", "probing input new": "def make_pos_def_torch(x):\n \"\"\"\n Force a square symmetric matrix to be positive semi definite\n \"\"\"\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(torch.real(x))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(torch.real(x))", "y_neg": " w, v = torch.symeig(x, eigenvectors=True)", "retain": "def make_pos_def_torch(x):\n \"\"\"\n Force a square symmetric matrix to be positive semi definite\n \"\"\"\n w, v = torch.linalg.eigh(torch.real(x))\n w_pos = torch.clip(w, 0, None)\n nonzero_w = w_pos[w_pos > 0]\n w_new = w_pos\n if nonzero_w.shape[0] > 0:\n if nonzero_w.shape[0] < w.shape[0]:\n # min_w = max(torch.max(nonzero_w)*1e-5,torch.min(nonzero_w))\n min_w = max(torch.max(nonzero_w) * 0.1, torch.min(nonzero_w))\n w_new = w_pos + min_w\n elif nonzero_w.shape[0] == 0:\n eprint(\n \"No positive eigenvalues for A {}. w={} {}, w_pos={} {}, nonzero_w={}\".format(\n x, w, w.shape, w_pos, w_pos.shape, nonzero_w\n )\n )\n w_new = torch.ones_like(w)\n x_star = v @ np.diag(w_new) @ v.T\n p = torch.sqrt(torch.sum(torch.abs(w)) / torch.sum(torch.abs(w_new)))\n return p * x_star" }, { "id": 6766, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def admm_simple(A: Tensor, n_eig: Optional[int] = None, min_eig: float = 0.0) -> Tensor:\n N = A.shape[1]\n if n_eig: # if specify the number of eigen components\n if (0 < n_eig <= N) and (n_eig % 2 == 0):\n pass\n else:\n raise ValueError(\n f\" {n_eig} not a valid number of eigen component to reserve\"\n )\n else:\n n_eig = N\n\n # eigenvalue decomposition of A, ascending\n delta, V = torch.linalg.eigh(A)\n\n # to descending order\n delta = torch.flip(delta, [0])\n V = torch.flip(V, [1])\n\n # compute eigenvalue of the bipartite bga of A\n lambda_ = A.new_zeros(n_eig)\n if N % 2 == 0:\n lambda_[: N // 2] = 0.5 * (delta[: N // 2] - torch.flip(delta[N // 2 :], [0]))\n lambda_[N // 2 :] = torch.flip(-lambda_[: N // 2], [0])\n elif N % 2 != 0:\n lambda_[: N // 2] = 0.5 * (\n delta[: N // 2] - torch.flip(delta[N // 2 + 1 :], [0])\n )\n lambda_[N // 2 + 1 :] = torch.flip(-lambda_[: N // 2], [0])\n\n if n_eig < N: # delete the middle N-n_eig eigenvalues of B\n lambda_[n_eig / 2 : -n_eig / 2] = 0\n\n if min_eig > 0:\n idx = (torch.abs(lambda_) < min_eig).nonzero()[:, 0]\n lambda_[idx] = (lambda_[idx]).sign() * min_eig\n\n # recover B\n B = V.mm(torch.diag(lambda_)).mm(V.t())\n return (B + B.t()) / 2", "probing input": "def admm_simple(A: Tensor, n_eig: Optional[int] = None, min_eig: float = 0.0) -> Tensor:\n N = A.shape[1]\n if n_eig: # if specify the number of eigen components\n if (0 < n_eig <= N) and (n_eig % 2 == 0):\n pass\n else:\n raise ValueError(\n f\" {n_eig} not a valid number of eigen component to reserve\"\n )\n else:\n n_eig = N\n\n # eigenvalue decomposition of A, ascending\n", "probing input new": "def admm_simple(A: Tensor, n_eig: Optional[int] = None, min_eig: float = 0.0) -> Tensor:\n N = A.shape[1]\n if n_eig: # if specify the number of eigen components\n if (0 < n_eig <= N) and (n_eig % 2 == 0):\n pass\n else:\n raise ValueError(\n f\" {n_eig} not a valid number of eigen component to reserve\"\n )\n else:\n n_eig = N\n\n # eigenvalue decomposition of A, ascending\n delta, V = torch.", "reference": "delta,V=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "delta,V=torch.linalg.eigh(A)", "y_neg": " delta, V = torch.symeig(A, eigenvectors=True)", "retain": "def admm_simple(A: Tensor, n_eig: Optional[int] = None, min_eig: float = 0.0) -> Tensor:\n N = A.shape[1]\n if n_eig: # if specify the number of eigen components\n if (0 < n_eig <= N) and (n_eig % 2 == 0):\n pass\n else:\n raise ValueError(\n f\" {n_eig} not a valid number of eigen component to reserve\"\n )\n else:\n n_eig = N\n\n # eigenvalue decomposition of A, ascending\n delta, V = torch.linalg.eigh(A)\n\n # to descending order\n delta = torch.flip(delta, [0])\n V = torch.flip(V, [1])\n\n # compute eigenvalue of the bipartite bga of A\n lambda_ = A.new_zeros(n_eig)\n if N % 2 == 0:\n lambda_[: N // 2] = 0.5 * (delta[: N // 2] - torch.flip(delta[N // 2 :], [0]))\n lambda_[N // 2 :] = torch.flip(-lambda_[: N // 2], [0])\n elif N % 2 != 0:\n lambda_[: N // 2] = 0.5 * (\n delta[: N // 2] - torch.flip(delta[N // 2 + 1 :], [0])\n )\n lambda_[N // 2 + 1 :] = torch.flip(-lambda_[: N // 2], [0])\n\n if n_eig < N: # delete the middle N-n_eig eigenvalues of B\n lambda_[n_eig / 2 : -n_eig / 2] = 0\n\n if min_eig > 0:\n idx = (torch.abs(lambda_) < min_eig).nonzero()[:, 0]\n lambda_[idx] = (lambda_[idx]).sign() * min_eig\n\n # recover B\n B = V.mm(torch.diag(lambda_)).mm(V.t())\n return (B + B.t()) / 2" }, { "id": 6767, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def mol2conf_loss_one_graph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_q = v[:, :, 0]\n rotation = GNNet.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean.expand(total_iso, -1), rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = (pos_y - pos_x).norm(dim=-1, keepdim=True).view(-1, num_nodes,).mean(-1)\n return torch.argmin(loss)", "probing input": " def mol2conf_loss_one_graph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n", "probing input new": " def mol2conf_loss_one_graph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(tmpb)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(tmpb)", "y_neg": " w, v = torch.symeig(tmpb, eigenvectors=True)", "retain": " def mol2conf_loss_one_graph(pos_y, pos_x, pos_y_mean, pos_x_mean, num_nodes, total_iso):\n with torch.no_grad():\n total_nodes = pos_y.shape[0]\n y = pos_y - pos_y_mean\n x = pos_x - pos_x_mean\n a = y + x\n b = y - x\n a = a.view(-1, 1, 3)\n b = b.view(-1, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(-1, num_nodes, 16)\n tmpb = torch.mean(tmpb, dim=1).view(-1, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_q = v[:, :, 0]\n rotation = GNNet.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean.expand(total_iso, -1), rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = (pos_y - pos_x).norm(dim=-1, keepdim=True).view(-1, num_nodes,).mean(-1)\n return torch.argmin(loss)" }, { "id": 6768, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def alignment_loss(\n pos_y, pos_x, batch,\n ):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNNet.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch).mean()\n return loss", "probing input": " def alignment_loss(\n pos_y, pos_x, batch,\n ):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n", "probing input new": " def alignment_loss(\n pos_y, pos_x, batch,\n ):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(tmpb)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(tmpb)", "y_neg": " w, v = torch.symeig(tmpb, eigenvectors=True)", "retain": " def alignment_loss(\n pos_y, pos_x, batch,\n ):\n with torch.no_grad():\n num_nodes = batch.n_nodes\n total_nodes = pos_y.shape[0]\n num_graphs = batch.num_graphs\n pos_y_mean = global_mean_pool(pos_y, batch.batch)\n pos_x_mean = global_mean_pool(pos_x, batch.batch)\n y = pos_y - torch.repeat_interleave(pos_y_mean, num_nodes, dim=0)\n x = pos_x - torch.repeat_interleave(pos_x_mean, num_nodes, dim=0)\n a = y + x\n b = y - x\n a = a.view(total_nodes, 1, 3)\n b = b.view(total_nodes, 3, 1)\n tmp0 = torch.cat(\n [b.new_zeros((1, 1, 1)).expand(total_nodes, -1, -1), -b.permute(0, 2, 1)], dim=-1\n )\n eye = torch.eye(3).to(a).unsqueeze(0).expand(total_nodes, -1, -1)\n a = a.expand(-1, 3, -1)\n tmp1 = torch.cross(eye, a, dim=-1)\n tmp1 = torch.cat([b, tmp1], dim=-1)\n tmp = torch.cat([tmp0, tmp1], dim=1)\n tmpb = torch.bmm(tmp.permute(0, 2, 1), tmp).view(total_nodes, -1)\n tmpb = global_mean_pool(tmpb, batch.batch).view(num_graphs, 4, 4)\n w, v = torch.linalg.eigh(tmpb)\n min_rmsd = w[:, 0]\n min_q = v[:, :, 0]\n rotation = GNNet.quaternion_to_rotation_matrix(min_q)\n t = pos_y_mean - torch.einsum(\"kj,kij->ki\", pos_x_mean, rotation)\n rotation = torch.repeat_interleave(rotation, num_nodes, dim=0)\n t = torch.repeat_interleave(t, num_nodes, dim=0)\n pos_x = torch.einsum(\"kj,kij->ki\", pos_x, rotation) + t\n loss = global_mean_pool((pos_y - pos_x).norm(dim=-1, keepdim=True), batch.batch).mean()\n return loss" }, { "id": 6769, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def matrix_sqrt(M):\n S, V = torch.linalg.eigh(M)\n S[S<0] = 0\n S = torch.diag(S**0.5)\n return (V @ S @ V.T).cpu()", "probing input": "def matrix_sqrt(M):\n", "probing input new": "def matrix_sqrt(M):\n S, V = torch.", "reference": "S,V=torch.linalg.eigh(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "S,V=torch.linalg.eigh(M)", "y_neg": " S, V = torch.symeig(M, eigenvectors=True)", "retain": "def matrix_sqrt(M):\n S, V = torch.linalg.eigh(M)\n S[S<0] = 0\n S = torch.diag(S**0.5)\n return (V @ S @ V.T).cpu()" }, { "id": 6779, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _fit(self, model, train_loader):\n model.eval()\n self.u = - torch.pinverse(model.fc.weight).matmul(model.fc.bias)\n features = []\n logits = []\n for i, (data, _) in enumerate(tqdm(train_loader, f'Fitting covariance matrix at {self.layer_name}', disable=os.getenv('TQDM_DISABLE'))):\n data = lib.to_device(data)\n if self.features_dataset:\n z = data['avg'].float()\n else:\n z = lib.get_features(model, data, layer_names=[self.layer_name])['avg'][-1]\n\n logits.append(model.fc.forward(z).detach())\n features.append(z-self.u)\n\n if i > self.max_fit_iter:\n break\n\n Z = torch.cat(features)\n logits = torch.cat(logits)\n cov = np.cov(Z.T.cpu().numpy(), bias=True)\n # solved singular values pb in cholesky (see https://scicomp.stackexchange.com/questions/30631/how-to-find-the-nearest-a-near-positive-definite-from-a-given-matrix)\n cov += 1e-12 * np.eye(cov.shape[0])\n cov = torch.from_numpy(cov).float().to('cuda', non_blocking=True)\n\n eigenvalues, eigenvectors = torch.linalg.eigh(cov)\n eig_sorted = torch.argsort(eigenvalues, descending=True)[self.principal_dim:]\n self.R = eigenvectors.T[eig_sorted]\n self.R = self.R.T.contiguous()\n\n vlogits = torch.norm(Z.matmul(self.R), dim=-1)\n self.alpha = logits.max(dim=-1)[0].mean() / vlogits.mean()\n del features, logits, vlogits\n torch.cuda.empty_cache()", "probing input": " def _fit(self, model, train_loader):\n model.eval()\n self.u = - torch.pinverse(model.fc.weight).matmul(model.fc.bias)\n features = []\n logits = []\n for i, (data, _) in enumerate(tqdm(train_loader, f'Fitting covariance matrix at {self.layer_name}', disable=os.getenv('TQDM_DISABLE'))):\n data = lib.to_device(data)\n if self.features_dataset:\n z = data['avg'].float()\n else:\n z = lib.get_features(model, data, layer_names=[self.layer_name])['avg'][-1]\n\n logits.append(model.fc.forward(z).detach())\n features.append(z-self.u)\n\n if i > self.max_fit_iter:\n break\n\n Z = torch.cat(features)\n logits = torch.cat(logits)\n cov = np.cov(Z.T.cpu().numpy(), bias=True)\n # solved singular values pb in cholesky (see https://scicomp.stackexchange.com/questions/30631/how-to-find-the-nearest-a-near-positive-definite-from-a-given-matrix)\n cov += 1e-12 * np.eye(cov.shape[0])\n cov = torch.from_numpy(cov).float().to('cuda', non_blocking=True)\n\n", "probing input new": " def _fit(self, model, train_loader):\n model.eval()\n self.u = - torch.pinverse(model.fc.weight).matmul(model.fc.bias)\n features = []\n logits = []\n for i, (data, _) in enumerate(tqdm(train_loader, f'Fitting covariance matrix at {self.layer_name}', disable=os.getenv('TQDM_DISABLE'))):\n data = lib.to_device(data)\n if self.features_dataset:\n z = data['avg'].float()\n else:\n z = lib.get_features(model, data, layer_names=[self.layer_name])['avg'][-1]\n\n logits.append(model.fc.forward(z).detach())\n features.append(z-self.u)\n\n if i > self.max_fit_iter:\n break\n\n Z = torch.cat(features)\n logits = torch.cat(logits)\n cov = np.cov(Z.T.cpu().numpy(), bias=True)\n # solved singular values pb in cholesky (see https://scicomp.stackexchange.com/questions/30631/how-to-find-the-nearest-a-near-positive-definite-from-a-given-matrix)\n cov += 1e-12 * np.eye(cov.shape[0])\n cov = torch.from_numpy(cov).float().to('cuda', non_blocking=True)\n\n eigenvalues, eigenvectors = torch.", "reference": "eigenvalues,eigenvectors=torch.linalg.eigh(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,eigenvectors=torch.linalg.eigh(cov)", "y_neg": " eigenvalues, eigenvectors = torch.symeig(cov, eigenvectors=True)", "retain": " def _fit(self, model, train_loader):\n model.eval()\n self.u = - torch.pinverse(model.fc.weight).matmul(model.fc.bias)\n features = []\n logits = []\n for i, (data, _) in enumerate(tqdm(train_loader, f'Fitting covariance matrix at {self.layer_name}', disable=os.getenv('TQDM_DISABLE'))):\n data = lib.to_device(data)\n if self.features_dataset:\n z = data['avg'].float()\n else:\n z = lib.get_features(model, data, layer_names=[self.layer_name])['avg'][-1]\n\n logits.append(model.fc.forward(z).detach())\n features.append(z-self.u)\n\n if i > self.max_fit_iter:\n break\n\n Z = torch.cat(features)\n logits = torch.cat(logits)\n cov = np.cov(Z.T.cpu().numpy(), bias=True)\n # solved singular values pb in cholesky (see https://scicomp.stackexchange.com/questions/30631/how-to-find-the-nearest-a-near-positive-definite-from-a-given-matrix)\n cov += 1e-12 * np.eye(cov.shape[0])\n cov = torch.from_numpy(cov).float().to('cuda', non_blocking=True)\n\n eigenvalues, eigenvectors = torch.linalg.eigh(cov)\n eig_sorted = torch.argsort(eigenvalues, descending=True)[self.principal_dim:]\n self.R = eigenvectors.T[eig_sorted]\n self.R = self.R.T.contiguous()\n\n vlogits = torch.norm(Z.matmul(self.R), dim=-1)\n self.alpha = logits.max(dim=-1)[0].mean() / vlogits.mean()\n del features, logits, vlogits\n torch.cuda.empty_cache()" }, { "id": 6780, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __expm__(self, matrix: Tensor, symmetric: bool) -> Tensor:\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.linalg.eigh(matrix, UPLO='U')\n diff_mat = V @ torch.diag(e.exp()) @ V.t()\n else:\n diff_mat = torch.from_numpy(expm(matrix.cpu().numpy()))\n diff_mat = diff_mat.to(matrix.device, matrix.dtype)\n return diff_mat", "probing input": " def __expm__(self, matrix: Tensor, symmetric: bool) -> Tensor:\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n", "probing input new": " def __expm__(self, matrix: Tensor, symmetric: bool) -> Tensor:\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.", "reference": "e,V=torch.linalg.eigh(matrix,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,V=torch.linalg.eigh(matrix,UPLO='U')", "y_neg": " e, V = torch.symeig(matrix, eigenvectors=True)", "retain": " def __expm__(self, matrix: Tensor, symmetric: bool) -> Tensor:\n r\"\"\"Calculates matrix exponential.\n\n Args:\n matrix (Tensor): Matrix to take exponential of.\n symmetric (bool): Specifies whether the matrix is symmetric.\n\n :rtype: (:class:`Tensor`)\n \"\"\"\n if symmetric:\n e, V = torch.linalg.eigh(matrix, UPLO='U')\n diff_mat = V @ torch.diag(e.exp()) @ V.t()\n else:\n diff_mat = torch.from_numpy(expm(matrix.cpu().numpy()))\n diff_mat = diff_mat.to(matrix.device, matrix.dtype)\n return diff_mat" }, { "id": 6781, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if True:\n # In old autograd notebook translations gradients look good with this.\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]\n else:\n # Rot scores look better with this flag being used.\n return so3_utils.quaternion_from_matrix(rot)", "probing input": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if True:\n # In old autograd notebook translations gradients look good with this.\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n", "probing input new": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if True:\n # In old autograd notebook translations gradients look good with this.\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh(k)", "y_neg": " _, vectors = torch.symeig(k, eigenvectors=True)", "retain": "def rot_to_quat(\n rot: torch.Tensor,\n):\n if True:\n # In old autograd notebook translations gradients look good with this.\n if(rot.shape[-2:] != (3, 3)):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n rot = [[rot[..., i, j] for j in range(3)] for i in range(3)]\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = rot \n\n k = [\n [ xx + yy + zz, zy - yz, xz - zx, yx - xy,],\n [ zy - yz, xx - yy - zz, xy + yx, xz + zx,],\n [ xz - zx, xy + yx, yy - xx - zz, yz + zy,],\n [ yx - xy, xz + zx, yz + zy, zz - xx - yy,]\n ]\n\n k = (1./3.) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n\n _, vectors = torch.linalg.eigh(k)\n return vectors[..., -1]\n else:\n # Rot scores look better with this flag being used.\n return so3_utils.quaternion_from_matrix(rot)" }, { "id": 6787, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff'):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize')\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _score = torch.sum(torch.pow(_eigenval, 2)) + 1\n\n\n elif criterion == 'VAMP1':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method)\n _score = torch.norm(koopman_mat, p='nuc') + 1\n\n\n elif criterion == 'VAMP2':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method)\n _score = torch.pow(torch.norm(koopman_mat, p='fro'), 2) + 1\n\n\n elif criterion == 'VAMPE':\n c00, c0t, ctt = covariance(pastdata=pastdata, futuredata=futuredata, remove_mean=True)\n c00_sqrt_inv = matrix_inverse(matrix=c00, sqrt_root=True, epsilon=epsilon, method=method)\n ctt_sqrt_inv = matrix_inverse(matrix=ctt, sqrt_root=True, epsilon=epsilon, method=method)\n\n koopman_mat = torch.matmul(c00_sqrt_inv, torch.matmul(c0t, ctt_sqrt_inv)).t()\n u, sigma, v = torch.svd(koopman_mat)\n mask = sigma > epsilon\n \n u = torch.mm(c00_sqrt_inv, u[:, mask])\n v = torch.mm(ctt_sqrt_inv, v[:, mask])\n sigma = sigma[mask]\n\n u_t = u.t(); v_t = v.t()\n sigma = torch.diag(sigma)\n _score = torch.trace(2. * torch.linalg.multi_dot([sigma, u_t, c0t, v]) - torch.linalg.multi_dot([sigma, u_t, c00, u, sigma, v_t, ctt, v])) + 1\n\n return -1. * _score", "probing input": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff'):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize')\n", "probing input new": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff'):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize')\n _eigenval, _ = torch.", "reference": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "y_neg": " _eigenval, _ = torch.symeig(rev_propogator, eigenvectors=True)", "retain": "def loss_function(pastdata=None, futuredata=None, criterion='SRVNet', epsilon=1e-6, method='cutoff'):\n\n \"\"\"\n Loss function calculation for the VAMPNet / SRVNet training.\n\n Parameters\n ----------\n pastdata: torch.Tensor, default=None\n The past part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n futuredata: torch.Tensor, default=None\n The future part of the time-lagged sequence data. Can be generated from TimeLaggedDataset.\n criterion: string, default='SRVNet'\n The criterion used to calculate the score/loss fucntion, can be chosen from: 'SRVNet', 'VAMP1', 'VAMP2', 'VAMPE'\n epsilon: float, default=1e-6\n The epsilon modification used to calculate the inverse of the instantaneous matrix.\n method: string, default='cutoff'\n The method used to calculate the inverse of the instantaneous matix: : 'regularize', 'cutoff', 'clamp'\n \n Returns\n ----------\n loss function: float\n The loss function for the set criterion.\n \"\"\"\n\n _criterion = ['SRVNet', 'VAMP1', 'VAMP2', 'VAMPE']\n assert criterion in _criterion, \"Invalid criterion \"+str(criterion)+\" was adopted, should use criterion in: \"+str(_criterion)\n \n if criterion == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=pastdata, futuredata=futuredata, epsilon=0, method='regularize')\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _score = torch.sum(torch.pow(_eigenval, 2)) + 1\n\n\n elif criterion == 'VAMP1':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method)\n _score = torch.norm(koopman_mat, p='nuc') + 1\n\n\n elif criterion == 'VAMP2':\n koopman_mat = koopman_matrix(pastdata=pastdata, futuredata=futuredata, epsilon=epsilon, method=method)\n _score = torch.pow(torch.norm(koopman_mat, p='fro'), 2) + 1\n\n\n elif criterion == 'VAMPE':\n c00, c0t, ctt = covariance(pastdata=pastdata, futuredata=futuredata, remove_mean=True)\n c00_sqrt_inv = matrix_inverse(matrix=c00, sqrt_root=True, epsilon=epsilon, method=method)\n ctt_sqrt_inv = matrix_inverse(matrix=ctt, sqrt_root=True, epsilon=epsilon, method=method)\n\n koopman_mat = torch.matmul(c00_sqrt_inv, torch.matmul(c0t, ctt_sqrt_inv)).t()\n u, sigma, v = torch.svd(koopman_mat)\n mask = sigma > epsilon\n \n u = torch.mm(c00_sqrt_inv, u[:, mask])\n v = torch.mm(ctt_sqrt_inv, v[:, mask])\n sigma = sigma[mask]\n\n u_t = u.t(); v_t = v.t()\n sigma = torch.diag(sigma)\n _score = torch.trace(2. * torch.linalg.multi_dot([sigma, u_t, c0t, v]) - torch.linalg.multi_dot([sigma, u_t, c00, u, sigma, v_t, ctt, v])) + 1\n\n return -1. * _score" }, { "id": 6788, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _eigenval = torch.flip(_eigenval[-int(_val_pastproject.shape[1]):], dims=[0]).detach()\n return -_val_score.item(), _eigenval.cpu().numpy()\n else:\n return -_val_score.item()", "probing input": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method)\n", "probing input new": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method)\n _eigenval, _ = torch.", "reference": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_eigenval,_=torch.linalg.eigh(rev_propogator)", "y_neg": " _eigenval, _ = torch.symeig(_val_score.unsqueeze(0), eigenvectors=True)", "retain": " def validate(self, validation_past, validation_future):\n\n \"\"\"\n Validate the model using validation dataset to get validation score.\n \"\"\"\n\n self._lobe.eval()\n if not self._network_type == 'SRVNet':\n self._lobe_timelagged.eval()\n\n if isinstance(validation_past, np.ndarray):\n validation_past = torch.from_numpy(validation_past.astype(np.float32))\n if isinstance(validation_future, np.ndarray):\n validation_future = torch.from_numpy(validation_future.astype(np.float32))\n validation_past = validation_past.to(device=self._device)\n validation_future = validation_future.to(device=self._device)\n\n with torch.no_grad():\n if self._network_type == \"SRVNet\":\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe(validation_future)\n else:\n _val_pastproject = self._lobe(validation_past)\n _val_futureproject = self._lobe_timelagged(validation_future)\n _val_score = loss_function(pastdata=_val_pastproject, futuredata=_val_futureproject, criterion=self._network_type, \n epsilon=self.__epsilon, method=self.__covariance_method)\n if self._network_type == 'SRVNet':\n rev_propogator = reverse_propogator(pastdata=_val_pastproject, futuredata=_val_futureproject, \n epsilon=self.__epsilon, method=self.__covariance_method)\n _eigenval, _ = torch.linalg.eigh(rev_propogator)\n _eigenval = torch.flip(_eigenval[-int(_val_pastproject.shape[1]):], dims=[0]).detach()\n return -_val_score.item(), _eigenval.cpu().numpy()\n else:\n return -_val_score.item()" }, { "id": 6794, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n with linear_operator.settings.max_cg_iterations(200):\n sqrt_inv_matmul_res, inv_quad_res = linear_operator.sqrt_inv_matmul(linear_op, rhs, lhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = lhs_copy @ matrix_inv_root @ rhs_copy\n inv_quad_actual = (lhs_copy @ matrix_inv_root).pow(2).sum(dim=-1)\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(inv_quad_res, inv_quad_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n\n # Perform backward pass\n sqrt_inv_matmul_grad = torch.randn_like(sqrt_inv_matmul_res)\n inv_quad_grad = torch.randn_like(inv_quad_res)\n ((sqrt_inv_matmul_res * sqrt_inv_matmul_grad).sum() + (inv_quad_res * inv_quad_grad).sum()).backward()\n ((sqrt_inv_matmul_actual * sqrt_inv_matmul_grad).sum() + (inv_quad_actual * inv_quad_grad).sum()).backward()\n\n # Check grads\n self.assertAllClose(rhs.grad, rhs_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(lhs.grad, lhs_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])", "probing input": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n with linear_operator.settings.max_cg_iterations(200):\n sqrt_inv_matmul_res, inv_quad_res = linear_operator.sqrt_inv_matmul(linear_op, rhs, lhs)\n", "probing input new": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n with linear_operator.settings.max_cg_iterations(200):\n sqrt_inv_matmul_res, inv_quad_res = linear_operator.sqrt_inv_matmul(linear_op, rhs, lhs)\n evals, evecs = torch.", "reference": "evals,evecs=torch.linalg.eigh(evaluated)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,evecs=torch.linalg.eigh(evaluated)", "y_neg": " evals, evecs = torch.symeig(sqrt_inv_matmul_res, eigenvectors=True)", "retain": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n with linear_operator.settings.max_cg_iterations(200):\n sqrt_inv_matmul_res, inv_quad_res = linear_operator.sqrt_inv_matmul(linear_op, rhs, lhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = lhs_copy @ matrix_inv_root @ rhs_copy\n inv_quad_actual = (lhs_copy @ matrix_inv_root).pow(2).sum(dim=-1)\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(inv_quad_res, inv_quad_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n\n # Perform backward pass\n sqrt_inv_matmul_grad = torch.randn_like(sqrt_inv_matmul_res)\n inv_quad_grad = torch.randn_like(inv_quad_res)\n ((sqrt_inv_matmul_res * sqrt_inv_matmul_grad).sum() + (inv_quad_res * inv_quad_grad).sum()).backward()\n ((sqrt_inv_matmul_actual * sqrt_inv_matmul_grad).sum() + (inv_quad_actual * inv_quad_grad).sum()).backward()\n\n # Check grads\n self.assertAllClose(rhs.grad, rhs_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(lhs.grad, lhs_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"sqrt_inv_matmul\"])" }, { "id": 6800, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _ppca(X, d):\n \"\"\"Produces a facorization X = W @ W.T + s2*I for symmetric X.\n\n Args:\n X: symmetric p x p matrix.\n d: number of dimensions to keep.\n \"\"\"\n vals, vecs = torch.linalg.eigh(X)\n vals = torch.abs(torch.flip(vals, dims = [0]))\n vecs = torch.flip(vecs, dims=[1])\n W = vecs[:, 0:d] * torch.sqrt(vals[0:d])\n s2 = torch.mean(vals[d:])\n return W, s2, vals", "probing input": "def _ppca(X, d):\n \"\"\"Produces a facorization X = W @ W.T + s2*I for symmetric X.\n\n Args:\n X: symmetric p x p matrix.\n d: number of dimensions to keep.\n \"\"\"\n", "probing input new": "def _ppca(X, d):\n \"\"\"Produces a facorization X = W @ W.T + s2*I for symmetric X.\n\n Args:\n X: symmetric p x p matrix.\n d: number of dimensions to keep.\n \"\"\"\n vals, vecs = torch.", "reference": "vals,vecs=torch.linalg.eigh(X)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "vals,vecs=torch.linalg.eigh(X)", "y_neg": " vals, vecs = torch.symeig(X, eigenvectors=True)", "retain": "def _ppca(X, d):\n \"\"\"Produces a facorization X = W @ W.T + s2*I for symmetric X.\n\n Args:\n X: symmetric p x p matrix.\n d: number of dimensions to keep.\n \"\"\"\n vals, vecs = torch.linalg.eigh(X)\n vals = torch.abs(torch.flip(vals, dims = [0]))\n vecs = torch.flip(vecs, dims=[1])\n W = vecs[:, 0:d] * torch.sqrt(vals[0:d])\n s2 = torch.mean(vals[d:])\n return W, s2, vals" }, { "id": 6803, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_intrinsic_dimensionality(cov: torch.Tensor,\n thresh: float = .99) -> int:\n \"\"\"\n Compute the intrinsic dimensionality based on the covariance matrix\n :param cov: the covariance matrix as a torch tensor\n :param thresh: delta value; the explained variance of the covariance matrix\n :return: The intrinsic dimensionality; an integer value greater than zero\n \"\"\"\n eig_vals, eigen_space = torch.linalg.eigh(cov, UPLO='U')\n eig_vals, idx = eig_vals.sort(descending=True)\n eig_vals[eig_vals < 0] = 0\n percentages = eig_vals.cumsum(0) / eig_vals.sum()\n eigen_space = eigen_space[:, percentages < thresh]\n if eigen_space.shape[1] == 0:\n eigen_space = eigen_space[:, :1]\n elif thresh - (percentages[percentages < thresh][-1]) > 0.02:\n eigen_space = eigen_space[:, :eigen_space.shape[1] + 1]\n return eigen_space.shape[1]", "probing input": "def compute_intrinsic_dimensionality(cov: torch.Tensor,\n thresh: float = .99) -> int:\n \"\"\"\n Compute the intrinsic dimensionality based on the covariance matrix\n :param cov: the covariance matrix as a torch tensor\n :param thresh: delta value; the explained variance of the covariance matrix\n :return: The intrinsic dimensionality; an integer value greater than zero\n \"\"\"\n", "probing input new": "def compute_intrinsic_dimensionality(cov: torch.Tensor,\n thresh: float = .99) -> int:\n \"\"\"\n Compute the intrinsic dimensionality based on the covariance matrix\n :param cov: the covariance matrix as a torch tensor\n :param thresh: delta value; the explained variance of the covariance matrix\n :return: The intrinsic dimensionality; an integer value greater than zero\n \"\"\"\n eig_vals, eigen_space = torch.", "reference": "eig_vals,eigen_space=torch.linalg.eigh(cov,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eig_vals,eigen_space=torch.linalg.eigh(cov,UPLO='U')", "y_neg": " eig_vals, eigen_space = torch.symeig(cov, eigenvectors=True)", "retain": "def compute_intrinsic_dimensionality(cov: torch.Tensor,\n thresh: float = .99) -> int:\n \"\"\"\n Compute the intrinsic dimensionality based on the covariance matrix\n :param cov: the covariance matrix as a torch tensor\n :param thresh: delta value; the explained variance of the covariance matrix\n :return: The intrinsic dimensionality; an integer value greater than zero\n \"\"\"\n eig_vals, eigen_space = torch.linalg.eigh(cov, UPLO='U')\n eig_vals, idx = eig_vals.sort(descending=True)\n eig_vals[eig_vals < 0] = 0\n percentages = eig_vals.cumsum(0) / eig_vals.sum()\n eigen_space = eigen_space[:, percentages < thresh]\n if eigen_space.shape[1] == 0:\n eigen_space = eigen_space[:, :1]\n elif thresh - (percentages[percentages < thresh][-1]) > 0.02:\n eigen_space = eigen_space[:, :eigen_space.shape[1] + 1]\n return eigen_space.shape[1]" }, { "id": 6804, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_diag_trace(cov: torch.Tensor) -> float:\n \"\"\"\n Computes the trace of the covariance matrix diagonal matrix\n :param cov: the covariannce matrix as torch tensor\n :return: the trace\n \"\"\"\n eig_vals, eigen_space = torch.linalg.eigh(cov, UPLO='U')\n eig_vals[eig_vals < 0] = 0\n return eig_vals.sum().unsqueeze(dim=0).cpu().numpy()[0]", "probing input": "def compute_diag_trace(cov: torch.Tensor) -> float:\n \"\"\"\n Computes the trace of the covariance matrix diagonal matrix\n :param cov: the covariannce matrix as torch tensor\n :return: the trace\n \"\"\"\n", "probing input new": "def compute_diag_trace(cov: torch.Tensor) -> float:\n \"\"\"\n Computes the trace of the covariance matrix diagonal matrix\n :param cov: the covariannce matrix as torch tensor\n :return: the trace\n \"\"\"\n eig_vals, eigen_space = torch.", "reference": "eig_vals,eigen_space=torch.linalg.eigh(cov,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eig_vals,eigen_space=torch.linalg.eigh(cov,UPLO='U')", "y_neg": " eig_vals, eigen_space = torch.symeig(cov, eigenvectors=True)", "retain": "def compute_diag_trace(cov: torch.Tensor) -> float:\n \"\"\"\n Computes the trace of the covariance matrix diagonal matrix\n :param cov: the covariannce matrix as torch tensor\n :return: the trace\n \"\"\"\n eig_vals, eigen_space = torch.linalg.eigh(cov, UPLO='U')\n eig_vals[eig_vals < 0] = 0\n return eig_vals.sum().unsqueeze(dim=0).cpu().numpy()[0]" }, { "id": 6806, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_cov_mat(patches,rank):\n\n with torch.no_grad():\n\n # -- cov mat --\n bsize,num,pdim = patches.shape\n covMat = torch.matmul(patches.transpose(2,1),patches)\n covMat /= num\n\n # -- eigen stuff --\n eigVals,eigVecs = torch.linalg.eigh(covMat)\n eigVals= torch.flip(eigVals,dims=(1,))\n eigVecs = torch.flip(eigVecs,dims=(2,))[...,:rank]\n\n return covMat,eigVals,eigVecs", "probing input": "def compute_cov_mat(patches,rank):\n\n with torch.no_grad():\n\n # -- cov mat --\n bsize,num,pdim = patches.shape\n covMat = torch.matmul(patches.transpose(2,1),patches)\n covMat /= num\n\n # -- eigen stuff --\n", "probing input new": "def compute_cov_mat(patches,rank):\n\n with torch.no_grad():\n\n # -- cov mat --\n bsize,num,pdim = patches.shape\n covMat = torch.matmul(patches.transpose(2,1),patches)\n covMat /= num\n\n # -- eigen stuff --\n eigVals,eigVecs = torch.", "reference": "eigVals,eigVecs=torch.linalg.eigh(covMat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigVals,eigVecs=torch.linalg.eigh(covMat)", "y_neg": " eigVals,eigVecs = torch.symeig(covMat, eigenvectors=True)", "retain": "def compute_cov_mat(patches,rank):\n\n with torch.no_grad():\n\n # -- cov mat --\n bsize,num,pdim = patches.shape\n covMat = torch.matmul(patches.transpose(2,1),patches)\n covMat /= num\n\n # -- eigen stuff --\n eigVals,eigVecs = torch.linalg.eigh(covMat)\n eigVals= torch.flip(eigVals,dims=(1,))\n eigVecs = torch.flip(eigVecs,dims=(2,))[...,:rank]\n\n return covMat,eigVals,eigVecs" }, { "id": 6809, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _symapply(x, f, *, wmin=None, wmax=None):\n r\"\"\"Template function acting on stacked symmetric matrices that applies a\n given analytic function on them via eigenvalue decomposition.\n \"\"\"\n # try:\n w, v = torch.linalg.eigh(x)\n # except RuntimeError as e:\n # print(e)\n # torch.save(x, \"x.pt\")\n # sys.exit(0)\n\n # print(\"W\", w[0])\n # print(\"V\", v[0])\n if wmin is not None or wmax is not None:\n w.data.clamp_(min=wmin, max=wmax)\n\n return _mvmt(v, f(w), v)", "probing input": "def _symapply(x, f, *, wmin=None, wmax=None):\n r\"\"\"Template function acting on stacked symmetric matrices that applies a\n given analytic function on them via eigenvalue decomposition.\n \"\"\"\n # try:\n", "probing input new": "def _symapply(x, f, *, wmin=None, wmax=None):\n r\"\"\"Template function acting on stacked symmetric matrices that applies a\n given analytic function on them via eigenvalue decomposition.\n \"\"\"\n # try:\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(x)", "y_neg": " w, v = torch.symeig(x, eigenvectors=True)", "retain": "def _symapply(x, f, *, wmin=None, wmax=None):\n r\"\"\"Template function acting on stacked symmetric matrices that applies a\n given analytic function on them via eigenvalue decomposition.\n \"\"\"\n # try:\n w, v = torch.linalg.eigh(x)\n # except RuntimeError as e:\n # print(e)\n # torch.save(x, \"x.pt\")\n # sys.exit(0)\n\n # print(\"W\", w[0])\n # print(\"V\", v[0])\n if wmin is not None or wmax is not None:\n w.data.clamp_(min=wmin, max=wmax)\n\n return _mvmt(v, f(w), v)" }, { "id": 6811, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _sqrt_Nystrom(K:Tensor, mask:Tensor) -> Tensor:\n \"\"\"\n Compute the Nystrom approx square root `Ny(K)` of a kernel matrix.\n A smooth function is used for near-zero eigenvalues.\n \"\"\"\n D, V = torch.linalg.eigh(K[mask])\n D_sqrt = torch.sqrt(torch.clamp(D, 0))\n D_sqrt_inv = D_sqrt / torch.clamp(D, D[-1] * 1e-4)\n Q = torch.zeros_like(K)\n Q[mask] = V * D_sqrt.view((1, -1))\n Q[~mask] = K[~mask] @ V * D_sqrt_inv.view((1, -1))\n return Q", "probing input": "def _sqrt_Nystrom(K:Tensor, mask:Tensor) -> Tensor:\n \"\"\"\n Compute the Nystrom approx square root `Ny(K)` of a kernel matrix.\n A smooth function is used for near-zero eigenvalues.\n \"\"\"\n", "probing input new": "def _sqrt_Nystrom(K:Tensor, mask:Tensor) -> Tensor:\n \"\"\"\n Compute the Nystrom approx square root `Ny(K)` of a kernel matrix.\n A smooth function is used for near-zero eigenvalues.\n \"\"\"\n D, V = torch.", "reference": "D,V=torch.linalg.eigh(K[mask])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,V=torch.linalg.eigh(K[mask])", "y_neg": " D, V = torch.symeig(K, eigenvectors=True)", "retain": "def _sqrt_Nystrom(K:Tensor, mask:Tensor) -> Tensor:\n \"\"\"\n Compute the Nystrom approx square root `Ny(K)` of a kernel matrix.\n A smooth function is used for near-zero eigenvalues.\n \"\"\"\n D, V = torch.linalg.eigh(K[mask])\n D_sqrt = torch.sqrt(torch.clamp(D, 0))\n D_sqrt_inv = D_sqrt / torch.clamp(D, D[-1] * 1e-4)\n Q = torch.zeros_like(K)\n Q[mask] = V * D_sqrt.view((1, -1))\n Q[~mask] = K[~mask] @ V * D_sqrt_inv.view((1, -1))\n return Q" }, { "id": 6817, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, n_components=None, whiten=False, method='e-decomposition'):\n if n_components is None:\n n_components = self.cov_mat.shape[0]\n self.whiten = whiten\n if method == 'e-decomposition':\n evals, Q = torch.linalg.eigh(self.cov_mat)\n idx = evals.argsort().flip(0)\n self._evals = evals[idx]\n evals = evals[idx][:n_components]\n self.Q = Q[:,idx]\n self.Q = self.Q[:, :n_components]\n self._Q = self.Q.clone()\n self.Lambda = torch.diag(evals)\n if self.whiten: self.Q = self.Q@torch.diag(evals**-0.5)\n elif method == 'SVD':\n u, s, vh = torch.linalg.svd(self.dstar,full_matrices=False)\n evals = (1/(self.dstar.shape[-1] - 1))*(s**2)\n self._evals = evals\n evals = evals[:n_components]\n self.Q = u[:, :n_components]\n self._Q = self.Q.clone()\n self.Lambda = torch.diag(evals)\n if self.whiten: self.Q = self.Q@torch.diag(evals**-0.5)", "probing input": " def fit(self, n_components=None, whiten=False, method='e-decomposition'):\n if n_components is None:\n n_components = self.cov_mat.shape[0]\n self.whiten = whiten\n if method == 'e-decomposition':\n", "probing input new": " def fit(self, n_components=None, whiten=False, method='e-decomposition'):\n if n_components is None:\n n_components = self.cov_mat.shape[0]\n self.whiten = whiten\n if method == 'e-decomposition':\n evals, Q = torch.", "reference": "evals,Q=torch.linalg.eigh(self.cov_mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,Q=torch.linalg.eigh(self.cov_mat)", "y_neg": " evals, Q = torch.symeig(self.cov_mat, eigenvectors=True)", "retain": " def fit(self, n_components=None, whiten=False, method='e-decomposition'):\n if n_components is None:\n n_components = self.cov_mat.shape[0]\n self.whiten = whiten\n if method == 'e-decomposition':\n evals, Q = torch.linalg.eigh(self.cov_mat)\n idx = evals.argsort().flip(0)\n self._evals = evals[idx]\n evals = evals[idx][:n_components]\n self.Q = Q[:,idx]\n self.Q = self.Q[:, :n_components]\n self._Q = self.Q.clone()\n self.Lambda = torch.diag(evals)\n if self.whiten: self.Q = self.Q@torch.diag(evals**-0.5)\n elif method == 'SVD':\n u, s, vh = torch.linalg.svd(self.dstar,full_matrices=False)\n evals = (1/(self.dstar.shape[-1] - 1))*(s**2)\n self._evals = evals\n evals = evals[:n_components]\n self.Q = u[:, :n_components]\n self._Q = self.Q.clone()\n self.Lambda = torch.diag(evals)\n if self.whiten: self.Q = self.Q@torch.diag(evals**-0.5)" }, { "id": 6820, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_features(self, noisy_data):\n E_t = noisy_data[\"E_t\"]\n mask = noisy_data[\"node_mask\"]\n A = E_t[..., 1:].sum(dim=-1).float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = self.compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n # debug for protein dataset\n if L.isnan().any():\n import pdb; pdb.set_trace()\n eigvals, eigvectors = torch.linalg.eigh(L)\n eigvals = eigvals.type_as(A) / torch.sum(mask, dim=1, keepdim=True)\n eigvectors = eigvectors * mask.unsqueeze(2) * mask.unsqueeze(1)\n # Retrieve eigenvalues features\n n_connected_comp, batch_eigenvalues = self.eigenvalues_features(\n eigenvalues=eigvals, num_eigenvalues=self.num_eigenvalues\n )\n # Retrieve eigenvectors features\n evector_feat = self.eigenvector_features(\n vectors=eigvectors,\n node_mask=noisy_data[\"node_mask\"],\n n_connected=n_connected_comp,\n num_eigenvectors=self.num_eigenvectors,\n )\n\n evalue_feat = torch.hstack((n_connected_comp, batch_eigenvalues))\n return evalue_feat, evector_feat", "probing input": " def compute_features(self, noisy_data):\n E_t = noisy_data[\"E_t\"]\n mask = noisy_data[\"node_mask\"]\n A = E_t[..., 1:].sum(dim=-1).float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = self.compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n # debug for protein dataset\n if L.isnan().any():\n import pdb; pdb.set_trace()\n", "probing input new": " def compute_features(self, noisy_data):\n E_t = noisy_data[\"E_t\"]\n mask = noisy_data[\"node_mask\"]\n A = E_t[..., 1:].sum(dim=-1).float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = self.compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n # debug for protein dataset\n if L.isnan().any():\n import pdb; pdb.set_trace()\n eigvals, eigvectors = torch.", "reference": "eigvals,eigvectors=torch.linalg.eigh(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigvals,eigvectors=torch.linalg.eigh(L)", "y_neg": " eigvals, eigvectors = torch.symeig(L, eigenvectors=True)", "retain": " def compute_features(self, noisy_data):\n E_t = noisy_data[\"E_t\"]\n mask = noisy_data[\"node_mask\"]\n A = E_t[..., 1:].sum(dim=-1).float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = self.compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n # debug for protein dataset\n if L.isnan().any():\n import pdb; pdb.set_trace()\n eigvals, eigvectors = torch.linalg.eigh(L)\n eigvals = eigvals.type_as(A) / torch.sum(mask, dim=1, keepdim=True)\n eigvectors = eigvectors * mask.unsqueeze(2) * mask.unsqueeze(1)\n # Retrieve eigenvalues features\n n_connected_comp, batch_eigenvalues = self.eigenvalues_features(\n eigenvalues=eigvals, num_eigenvalues=self.num_eigenvalues\n )\n # Retrieve eigenvectors features\n evector_feat = self.eigenvector_features(\n vectors=eigvectors,\n node_mask=noisy_data[\"node_mask\"],\n n_connected=n_connected_comp,\n num_eigenvectors=self.num_eigenvectors,\n )\n\n evalue_feat = torch.hstack((n_connected_comp, batch_eigenvalues))\n return evalue_feat, evector_feat" }, { "id": 6823, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def noise_estimate_batch(im, pch_size=10):\n '''\n Implement of noise level estimation of the following paper:\n Chen G , Zhu F , Heng P A . An Efficient Statistical Method for Image Noise Level Estimation[C]// 2015 IEEE International Conference\n on Computer Vision (ICCV). IEEE Computer Society, 2015.\n Input:\n im: the noise image, H x W x 3 or H x W numpy tensor, range [0,1]\n pch_size: patch_size\n Output:\n noise_level: the estimated noise level\n '''\n\n # if im.ndim == 3:\n # im = im.transpose((2, 0, 1))\n # else:\n # im = np.expand_dims(im, axis=0)\n\n # image to patch\n pch = im2patch_batch(im, pch_size, 3) # C x pch_size x pch_size x num_pch tensor\n\n num_pch = pch.shape[4]\n pch = pch.reshape((-1, num_pch)) # d x num_pch matrix\n d = pch.shape[0]\n mu = pch.mean(dim=1, keepdim=True) # d x 1\n X = pch - mu\n sigma_X = torch.mm(X, X.transpose(1, 0)) / num_pch\n sig_value, _ = torch.linalg.eigh(sigma_X)\n sig_value.sort()\n\n for ii in range(-1, -d-1, -1):\n tau = torch.mean(sig_value[:ii])\n if torch.sum(sig_value[:ii]>tau) == torch.sum(sig_value[:ii] < tau):\n return torch.sqrt(tau)", "probing input": "def noise_estimate_batch(im, pch_size=10):\n '''\n Implement of noise level estimation of the following paper:\n Chen G , Zhu F , Heng P A . An Efficient Statistical Method for Image Noise Level Estimation[C]// 2015 IEEE International Conference\n on Computer Vision (ICCV). IEEE Computer Society, 2015.\n Input:\n im: the noise image, H x W x 3 or H x W numpy tensor, range [0,1]\n pch_size: patch_size\n Output:\n noise_level: the estimated noise level\n '''\n\n # if im.ndim == 3:\n # im = im.transpose((2, 0, 1))\n # else:\n # im = np.expand_dims(im, axis=0)\n\n # image to patch\n pch = im2patch_batch(im, pch_size, 3) # C x pch_size x pch_size x num_pch tensor\n\n num_pch = pch.shape[4]\n pch = pch.reshape((-1, num_pch)) # d x num_pch matrix\n d = pch.shape[0]\n mu = pch.mean(dim=1, keepdim=True) # d x 1\n X = pch - mu\n sigma_X = torch.mm(X, X.transpose(1, 0)) / num_pch\n", "probing input new": "def noise_estimate_batch(im, pch_size=10):\n '''\n Implement of noise level estimation of the following paper:\n Chen G , Zhu F , Heng P A . An Efficient Statistical Method for Image Noise Level Estimation[C]// 2015 IEEE International Conference\n on Computer Vision (ICCV). IEEE Computer Society, 2015.\n Input:\n im: the noise image, H x W x 3 or H x W numpy tensor, range [0,1]\n pch_size: patch_size\n Output:\n noise_level: the estimated noise level\n '''\n\n # if im.ndim == 3:\n # im = im.transpose((2, 0, 1))\n # else:\n # im = np.expand_dims(im, axis=0)\n\n # image to patch\n pch = im2patch_batch(im, pch_size, 3) # C x pch_size x pch_size x num_pch tensor\n\n num_pch = pch.shape[4]\n pch = pch.reshape((-1, num_pch)) # d x num_pch matrix\n d = pch.shape[0]\n mu = pch.mean(dim=1, keepdim=True) # d x 1\n X = pch - mu\n sigma_X = torch.mm(X, X.transpose(1, 0)) / num_pch\n sig_value, _ = torch.", "reference": "sig_value,_=torch.linalg.eigh(sigma_X)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "sig_value,_=torch.linalg.eigh(sigma_X)", "y_neg": " sig_value, _ = torch.symeig(sigma_X, eigenvectors=True)", "retain": "def noise_estimate_batch(im, pch_size=10):\n '''\n Implement of noise level estimation of the following paper:\n Chen G , Zhu F , Heng P A . An Efficient Statistical Method for Image Noise Level Estimation[C]// 2015 IEEE International Conference\n on Computer Vision (ICCV). IEEE Computer Society, 2015.\n Input:\n im: the noise image, H x W x 3 or H x W numpy tensor, range [0,1]\n pch_size: patch_size\n Output:\n noise_level: the estimated noise level\n '''\n\n # if im.ndim == 3:\n # im = im.transpose((2, 0, 1))\n # else:\n # im = np.expand_dims(im, axis=0)\n\n # image to patch\n pch = im2patch_batch(im, pch_size, 3) # C x pch_size x pch_size x num_pch tensor\n\n num_pch = pch.shape[4]\n pch = pch.reshape((-1, num_pch)) # d x num_pch matrix\n d = pch.shape[0]\n mu = pch.mean(dim=1, keepdim=True) # d x 1\n X = pch - mu\n sigma_X = torch.mm(X, X.transpose(1, 0)) / num_pch\n sig_value, _ = torch.linalg.eigh(sigma_X)\n sig_value.sort()\n\n for ii in range(-1, -d-1, -1):\n tau = torch.mean(sig_value[:ii])\n if torch.sum(sig_value[:ii]>tau) == torch.sum(sig_value[:ii] < tau):\n return torch.sqrt(tau)" }, { "id": 6825, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _compute_kfe(self, group, state):\n \"\"\"Computes the covariances.\"\"\"\n mod = group['mod']\n x = self.state[group['mod']]['x']\n gy = self.state[group['mod']]['gy']\n # Computation of xxt\n if group['layer_type'] == 'Conv2d':\n if not self.sua:\n x = F.conv2d(x, group['gathering_filter'],\n stride=mod.stride, padding=mod.padding,\n groups=mod.in_channels)\n x = x.data.permute(1, 0, 2, 3).contiguous().view(x.shape[1], -1)\n else:\n x = x.data.t()\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones], dim=0)\n xxt = torch.mm(x, x.t()) / float(x.shape[1])\n Ex, state['kfe_x'] = torch.linalg.eigh(xxt,UPLO='U')\n # Computation of ggt\n if group['layer_type'] == 'Conv2d':\n gy = gy.data.permute(1, 0, 2, 3)\n state['num_locations'] = gy.shape[2] * gy.shape[3]\n gy = gy.contiguous().view(gy.shape[0], -1)\n else:\n gy = gy.data.t()\n state['num_locations'] = 1\n ggt = torch.mm(gy, gy.t()) / float(gy.shape[1])\n Eg, state['kfe_gy'] = torch.linalg.eigh(ggt, UPLO='U')\n state['m2'] = Eg.unsqueeze(1) * Ex.unsqueeze(0) * state['num_locations']\n if group['layer_type'] == 'Conv2d' and self.sua:\n ws = group['params'][0].grad.data.size()\n state['m2'] = state['m2'].view(Eg.size(0), Ex.size(0), 1, 1).expand(-1, -1, ws[2], ws[3])", "probing input": " def _compute_kfe(self, group, state):\n \"\"\"Computes the covariances.\"\"\"\n mod = group['mod']\n x = self.state[group['mod']]['x']\n gy = self.state[group['mod']]['gy']\n # Computation of xxt\n if group['layer_type'] == 'Conv2d':\n if not self.sua:\n x = F.conv2d(x, group['gathering_filter'],\n stride=mod.stride, padding=mod.padding,\n groups=mod.in_channels)\n x = x.data.permute(1, 0, 2, 3).contiguous().view(x.shape[1], -1)\n else:\n x = x.data.t()\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones], dim=0)\n xxt = torch.mm(x, x.t()) / float(x.shape[1])\n", "probing input new": " def _compute_kfe(self, group, state):\n \"\"\"Computes the covariances.\"\"\"\n mod = group['mod']\n x = self.state[group['mod']]['x']\n gy = self.state[group['mod']]['gy']\n # Computation of xxt\n if group['layer_type'] == 'Conv2d':\n if not self.sua:\n x = F.conv2d(x, group['gathering_filter'],\n stride=mod.stride, padding=mod.padding,\n groups=mod.in_channels)\n x = x.data.permute(1, 0, 2, 3).contiguous().view(x.shape[1], -1)\n else:\n x = x.data.t()\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones], dim=0)\n xxt = torch.mm(x, x.t()) / float(x.shape[1])\n Ex, state['kfe_x'] = torch.", "reference": "Ex,state['kfe_x']=torch.linalg.eigh(xxt,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "Ex,state['kfe_x']=torch.linalg.eigh(xxt,UPLO='U')", "y_neg": " Ex, state['kfe_x'] = torch.symeig(xxt, eigenvectors=True)", "retain": " def _compute_kfe(self, group, state):\n \"\"\"Computes the covariances.\"\"\"\n mod = group['mod']\n x = self.state[group['mod']]['x']\n gy = self.state[group['mod']]['gy']\n # Computation of xxt\n if group['layer_type'] == 'Conv2d':\n if not self.sua:\n x = F.conv2d(x, group['gathering_filter'],\n stride=mod.stride, padding=mod.padding,\n groups=mod.in_channels)\n x = x.data.permute(1, 0, 2, 3).contiguous().view(x.shape[1], -1)\n else:\n x = x.data.t()\n if mod.bias is not None:\n ones = torch.ones_like(x[:1])\n x = torch.cat([x, ones], dim=0)\n xxt = torch.mm(x, x.t()) / float(x.shape[1])\n Ex, state['kfe_x'] = torch.linalg.eigh(xxt,UPLO='U')\n # Computation of ggt\n if group['layer_type'] == 'Conv2d':\n gy = gy.data.permute(1, 0, 2, 3)\n state['num_locations'] = gy.shape[2] * gy.shape[3]\n gy = gy.contiguous().view(gy.shape[0], -1)\n else:\n gy = gy.data.t()\n state['num_locations'] = 1\n ggt = torch.mm(gy, gy.t()) / float(gy.shape[1])\n Eg, state['kfe_gy'] = torch.linalg.eigh(ggt, UPLO='U')\n state['m2'] = Eg.unsqueeze(1) * Ex.unsqueeze(0) * state['num_locations']\n if group['layer_type'] == 'Conv2d' and self.sua:\n ws = group['params'][0].grad.data.size()\n state['m2'] = state['m2'].view(Eg.size(0), Ex.size(0), 1, 1).expand(-1, -1, ws[2], ws[3])" }, { "id": 6834, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _update_inv_cov(self):\n self._eigval = []\n self._eigvec = []\n for est in self._est:\n e, v = torch.linalg.eigh(est)\n self._eigval.append(e.clamp(min=0.0))\n self._eigvec.append(v)", "probing input": " def _update_inv_cov(self):\n self._eigval = []\n self._eigvec = []\n for est in self._est:\n", "probing input new": " def _update_inv_cov(self):\n self._eigval = []\n self._eigvec = []\n for est in self._est:\n e, v = torch.", "reference": "e,v=torch.linalg.eigh(est)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e,v=torch.linalg.eigh(est)", "y_neg": " e, v = torch.symeig(est.cov_matrix, eigenvectors=True)", "retain": " def _update_inv_cov(self):\n self._eigval = []\n self._eigvec = []\n for est in self._est:\n e, v = torch.linalg.eigh(est)\n self._eigval.append(e.clamp(min=0.0))\n self._eigvec.append(v)" }, { "id": 6836, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n feature_dict: Dict[str, torch.Tensor],\n nloops: int = 5,\n refine_steps: int = 0,\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n x = feature_dict[\"msa\"]\n x2 = feature_dict[\"cov\"]\n nres = x.size()[1]\n\n x = self.embed(x)\n x = self.vgru(x)[0]\n x = self.hgru(x[-1, :, :].unsqueeze(1))[0]\n mat1d = x.permute(1, 2, 0)\n x = mat1d.unsqueeze(2) * mat1d.unsqueeze(3)\n\n resinp = torch.cat((x, x2), dim=1)\n\n if x.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n best_conf = conf\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n w, v = torch.linalg.eigh(M.float())\n w = torch.clamp(F.relu(w, inplace=False), min=1e-8)\n w = torch.diag_embed(w.sqrt())\n mds_coords = torch.matmul(v, w)[:, :, -8:]\n coordembed = torch.cat((mat1d.permute(0, 2, 1), mds_coords), dim=2)\n\n gru_out = self.coord_gru(coordembed)[0]\n\n ca_coords = self.coord_fc(gru_out)\n\n if refine_steps > 0:\n ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n\n best_coords = ca_coords\n\n # print(best_conf.sum().item())\n\n for i in range(nloops):\n # print(ca_coords.size())\n\n # Add small amount of noise to seed coordinates\n # ca_coords = ca_coords + 0.5 * torch.randn_like(ca_coords)\n # if refine_steps > 0:\n # ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n dmap = torch.clamp(\n (ca_coords - ca_coords.transpose(0, 1)).pow(2).sum(dim=2), min=1e-8\n ).sqrt()\n resinp = torch.cat((resinp[:, :-1], dmap.unsqueeze(0).unsqueeze(0)), dim=1)\n\n if resinp.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n\n # print(conf.sum().item())\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n w, v = torch.linalg.eigh(M.float())\n w = torch.clamp(F.relu(w, inplace=False), min=1e-8)\n w = torch.diag_embed(w.sqrt())\n mds_coords = torch.matmul(v, w)[:, :, -8:]\n coordembed = torch.cat((mat1d.permute(0, 2, 1), mds_coords), dim=2)\n\n gru_out = self.coord_gru(coordembed)[0]\n\n ca_coords = self.coord_fc(gru_out)\n\n if conf.mean() > best_conf.mean():\n # if refine_steps > 0:\n # ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n best_conf = conf\n best_coords = ca_coords\n\n if refine_steps > 0:\n best_coords = refine_coords(best_coords.squeeze(0), refine_steps).unsqueeze(\n 0\n )\n\n coords_out = calpha_to_main_chain(best_coords)\n conf_out = torch.sigmoid(best_conf)\n\n return coords_out, conf_out", "probing input": " def forward(\n self,\n feature_dict: Dict[str, torch.Tensor],\n nloops: int = 5,\n refine_steps: int = 0,\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n x = feature_dict[\"msa\"]\n x2 = feature_dict[\"cov\"]\n nres = x.size()[1]\n\n x = self.embed(x)\n x = self.vgru(x)[0]\n x = self.hgru(x[-1, :, :].unsqueeze(1))[0]\n mat1d = x.permute(1, 2, 0)\n x = mat1d.unsqueeze(2) * mat1d.unsqueeze(3)\n\n resinp = torch.cat((x, x2), dim=1)\n\n if x.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n best_conf = conf\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n", "probing input new": " def forward(\n self,\n feature_dict: Dict[str, torch.Tensor],\n nloops: int = 5,\n refine_steps: int = 0,\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n x = feature_dict[\"msa\"]\n x2 = feature_dict[\"cov\"]\n nres = x.size()[1]\n\n x = self.embed(x)\n x = self.vgru(x)[0]\n x = self.hgru(x[-1, :, :].unsqueeze(1))[0]\n mat1d = x.permute(1, 2, 0)\n x = mat1d.unsqueeze(2) * mat1d.unsqueeze(3)\n\n resinp = torch.cat((x, x2), dim=1)\n\n if x.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n best_conf = conf\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(M.float())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(M.float())", "y_neg": " w, v = torch.symeig(M, eigenvectors=True)", "retain": " def forward(\n self,\n feature_dict: Dict[str, torch.Tensor],\n nloops: int = 5,\n refine_steps: int = 0,\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n x = feature_dict[\"msa\"]\n x2 = feature_dict[\"cov\"]\n nres = x.size()[1]\n\n x = self.embed(x)\n x = self.vgru(x)[0]\n x = self.hgru(x[-1, :, :].unsqueeze(1))[0]\n mat1d = x.permute(1, 2, 0)\n x = mat1d.unsqueeze(2) * mat1d.unsqueeze(3)\n\n resinp = torch.cat((x, x2), dim=1)\n\n if x.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n best_conf = conf\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n w, v = torch.linalg.eigh(M.float())\n w = torch.clamp(F.relu(w, inplace=False), min=1e-8)\n w = torch.diag_embed(w.sqrt())\n mds_coords = torch.matmul(v, w)[:, :, -8:]\n coordembed = torch.cat((mat1d.permute(0, 2, 1), mds_coords), dim=2)\n\n gru_out = self.coord_gru(coordembed)[0]\n\n ca_coords = self.coord_fc(gru_out)\n\n if refine_steps > 0:\n ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n\n best_coords = ca_coords\n\n # print(best_conf.sum().item())\n\n for i in range(nloops):\n # print(ca_coords.size())\n\n # Add small amount of noise to seed coordinates\n # ca_coords = ca_coords + 0.5 * torch.randn_like(ca_coords)\n # if refine_steps > 0:\n # ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n dmap = torch.clamp(\n (ca_coords - ca_coords.transpose(0, 1)).pow(2).sum(dim=2), min=1e-8\n ).sqrt()\n resinp = torch.cat((resinp[:, :-1], dmap.unsqueeze(0).unsqueeze(0)), dim=1)\n\n if resinp.requires_grad:\n # now call the checkpoint API and get the output\n x = checkpoint_sequential(self.resnet, 4, resinp)\n else:\n x = self.resnet(resinp)\n\n dm = x[:, 0, :, :]\n conf = x[:, 1, :, :].mean(dim=2)\n\n # print(conf.sum().item())\n\n # Ensure symmetric matrix\n dm = (dm + dm.transpose(1, 2)) / 2\n # Force values to be non-negative\n dm = torch.abs(dm)\n # See https://math.stackexchange.com/questions/156161/finding-the-coordinates-of-points-from-distance-matrix\n M = 0.5 * (\n dm[:, 0:1, :].expand(-1, nres, -1) ** 2\n + dm[:, :, 0:1].expand(-1, -1, nres) ** 2\n - dm**2\n )\n w, v = torch.linalg.eigh(M.float())\n w = torch.clamp(F.relu(w, inplace=False), min=1e-8)\n w = torch.diag_embed(w.sqrt())\n mds_coords = torch.matmul(v, w)[:, :, -8:]\n coordembed = torch.cat((mat1d.permute(0, 2, 1), mds_coords), dim=2)\n\n gru_out = self.coord_gru(coordembed)[0]\n\n ca_coords = self.coord_fc(gru_out)\n\n if conf.mean() > best_conf.mean():\n # if refine_steps > 0:\n # ca_coords = refine_coords(ca_coords.squeeze(0), refine_steps).unsqueeze(0)\n best_conf = conf\n best_coords = ca_coords\n\n if refine_steps > 0:\n best_coords = refine_coords(best_coords.squeeze(0), refine_steps).unsqueeze(\n 0\n )\n\n coords_out = calpha_to_main_chain(best_coords)\n conf_out = torch.sigmoid(best_conf)\n\n return coords_out, conf_out" }, { "id": 6837, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, scales, cond=None, rcond=None, upper=True):\n \"\"\"Factorized representation of a batch of scale PSD matrices.\"\"\"\n\n self._zero = scales.new_zeros(size=(1,))\n\n # scales: [B x D x D]\n\n # s, u = torch.symeig(scales, eigenvectors=True, upper=True)\n s, u = torch.linalg.eigh(scales)\n\n eps = _eigvalsh_to_eps(s, cond, rcond)\n\n if torch.any(torch.min(s, dim=-1).values < -eps):\n raise ValueError('scale is not positive semidefinite')\n\n # probably could use searchsorted\n self.s_mask = s > eps.unsqueeze(dim=-1)\n\n self.u = u\n self.s = torch.where(self.s_mask, s, self._zero)\n self.s_inv = torch.where(self.s_mask, 1 / s, self._zero)", "probing input": " def __init__(self, scales, cond=None, rcond=None, upper=True):\n \"\"\"Factorized representation of a batch of scale PSD matrices.\"\"\"\n\n self._zero = scales.new_zeros(size=(1,))\n\n # scales: [B x D x D]\n\n # s, u = torch.symeig(scales, eigenvectors=True, upper=True)\n", "probing input new": " def __init__(self, scales, cond=None, rcond=None, upper=True):\n \"\"\"Factorized representation of a batch of scale PSD matrices.\"\"\"\n\n self._zero = scales.new_zeros(size=(1,))\n\n # scales: [B x D x D]\n\n # s, u = torch.symeig(scales, eigenvectors=True, upper=True)\n s, u = torch.", "reference": "s,u=torch.linalg.eigh(scales)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "s,u=torch.linalg.eigh(scales)", "y_neg": " s, u = torch.symeig(scales, eigenvectors=True, upper=upper)", "retain": " def __init__(self, scales, cond=None, rcond=None, upper=True):\n \"\"\"Factorized representation of a batch of scale PSD matrices.\"\"\"\n\n self._zero = scales.new_zeros(size=(1,))\n\n # scales: [B x D x D]\n\n # s, u = torch.symeig(scales, eigenvectors=True, upper=True)\n s, u = torch.linalg.eigh(scales)\n\n eps = _eigvalsh_to_eps(s, cond, rcond)\n\n if torch.any(torch.min(s, dim=-1).values < -eps):\n raise ValueError('scale is not positive semidefinite')\n\n # probably could use searchsorted\n self.s_mask = s > eps.unsqueeze(dim=-1)\n\n self.u = u\n self.s = torch.where(self.s_mask, s, self._zero)\n self.s_inv = torch.where(self.s_mask, 1 / s, self._zero)" }, { "id": 6839, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def A_vec_to_quat(A_vec):\n '''\n Input:\n - A_vec [B,10]\n Output:\n - quat [B,4]\n '''\n A = convert_Avec_to_A(A_vec)\n _, eigvector = torch.linalg.eigh(A, \"U\")\n if eigvector.dim() < 3:\n eigvector = eigvector.unsqueeze(0)\n return eigvector[:,:,0]", "probing input": "def A_vec_to_quat(A_vec):\n '''\n Input:\n - A_vec [B,10]\n Output:\n - quat [B,4]\n '''\n A = convert_Avec_to_A(A_vec)\n", "probing input new": "def A_vec_to_quat(A_vec):\n '''\n Input:\n - A_vec [B,10]\n Output:\n - quat [B,4]\n '''\n A = convert_Avec_to_A(A_vec)\n _, eigvector = torch.", "reference": "_,eigvector=torch.linalg.eigh(A,\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,eigvector=torch.linalg.eigh(A,\"U\")", "y_neg": " _, eigvector = torch.symeig(A, eigenvectors=True)", "retain": "def A_vec_to_quat(A_vec):\n '''\n Input:\n - A_vec [B,10]\n Output:\n - quat [B,4]\n '''\n A = convert_Avec_to_A(A_vec)\n _, eigvector = torch.linalg.eigh(A, \"U\")\n if eigvector.dim() < 3:\n eigvector = eigvector.unsqueeze(0)\n return eigvector[:,:,0]" }, { "id": 6840, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def transfer_chrom(inp, src):\n '''\n inp (3, H, W): input image\n src (3, H, W): source image\n\n out (3, H, W): output image\n '''\n \n m_i = torch.mean(inp, dim=(1,2))\n m_s = torch.mean(src, dim=(1,2))\n s_i = torch.maximum(torch.cov(inp.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device())) \n s_s = torch.maximum(torch.cov(src.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device()))\n\n w_i, v_i = torch.linalg.eigh(s_i)\n w_i[w_i<0] = 0\n da = torch.diag(torch.sqrt(w_i + 1e-10))\n c = torch.mm(da, torch.mm(v_i.T, torch.mm(s_s, torch.mm(v_i, da))))\n w_c, v_c = torch.linalg.eigh(c)\n w_c[w_c<0] = 0\n dc = torch.diag(torch.sqrt(w_c + 1e-10))\n da_inv = torch.diag(1/(torch.diag(da)))\n T = torch.mm(v_i, torch.mm(da_inv, torch.mm(v_c, torch.mm(dc, torch.mm(v_c.T, torch.mm(da_inv, v_i.T))))))\n\n out = torch.matmul(T, (inp.view(3, -1) - m_i[:,None])) + m_s[:,None]\n\n return out.view(inp.size())", "probing input": "def transfer_chrom(inp, src):\n '''\n inp (3, H, W): input image\n src (3, H, W): source image\n\n out (3, H, W): output image\n '''\n \n m_i = torch.mean(inp, dim=(1,2))\n m_s = torch.mean(src, dim=(1,2))\n s_i = torch.maximum(torch.cov(inp.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device())) \n s_s = torch.maximum(torch.cov(src.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device()))\n\n", "probing input new": "def transfer_chrom(inp, src):\n '''\n inp (3, H, W): input image\n src (3, H, W): source image\n\n out (3, H, W): output image\n '''\n \n m_i = torch.mean(inp, dim=(1,2))\n m_s = torch.mean(src, dim=(1,2))\n s_i = torch.maximum(torch.cov(inp.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device())) \n s_s = torch.maximum(torch.cov(src.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device()))\n\n w_i, v_i = torch.", "reference": "w_i,v_i=torch.linalg.eigh(s_i)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w_i,v_i=torch.linalg.eigh(s_i)", "y_neg": " w_i, v_i = torch.symeig(s_i, eigenvectors=True)", "retain": "def transfer_chrom(inp, src):\n '''\n inp (3, H, W): input image\n src (3, H, W): source image\n\n out (3, H, W): output image\n '''\n \n m_i = torch.mean(inp, dim=(1,2))\n m_s = torch.mean(src, dim=(1,2))\n s_i = torch.maximum(torch.cov(inp.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device())) \n s_s = torch.maximum(torch.cov(src.view(3, -1)), 7.5*torch.eye(3).to(inp.get_device()))\n\n w_i, v_i = torch.linalg.eigh(s_i)\n w_i[w_i<0] = 0\n da = torch.diag(torch.sqrt(w_i + 1e-10))\n c = torch.mm(da, torch.mm(v_i.T, torch.mm(s_s, torch.mm(v_i, da))))\n w_c, v_c = torch.linalg.eigh(c)\n w_c[w_c<0] = 0\n dc = torch.diag(torch.sqrt(w_c + 1e-10))\n da_inv = torch.diag(1/(torch.diag(da)))\n T = torch.mm(v_i, torch.mm(da_inv, torch.mm(v_c, torch.mm(dc, torch.mm(v_c.T, torch.mm(da_inv, v_i.T))))))\n\n out = torch.matmul(T, (inp.view(3, -1) - m_i[:,None])) + m_s[:,None]\n\n return out.view(inp.size())" }, { "id": 6846, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [\n [rot[..., i, j] for j in range(3)] for i in range(3)\n ]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.linalg.eigh(\n (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n )\n return vectors[..., -1]", "probing input": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [\n [rot[..., i, j] for j in range(3)] for i in range(3)\n ]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n", "probing input new": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [\n [rot[..., i, j] for j in range(3)] for i in range(3)\n ]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.", "reference": "_,vectors=torch.linalg.eigh((1.0/3.0)*torch.stack([torch.stack(t,dim=-1)fortink],dim=-2))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vectors=torch.linalg.eigh((1.0/3.0)*torch.stack([torch.stack(t,dim=-1)fortink],dim=-2))", "y_neg": " _, vectors = torch.symeig(torch.tensor(k), eigenvectors=True)", "retain": "def rot_to_quat(rot: torch.Tensor) -> torch.Tensor:\n if rot.shape[-2:] != (3, 3):\n raise ValueError(\"Input rotation is incorrectly shaped\")\n\n [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]] = [\n [rot[..., i, j] for j in range(3)] for i in range(3)\n ]\n\n k = [\n [\n xx + yy + zz,\n zy - yz,\n xz - zx,\n yx - xy,\n ],\n [\n zy - yz,\n xx - yy - zz,\n xy + yx,\n xz + zx,\n ],\n [\n xz - zx,\n xy + yx,\n yy - xx - zz,\n yz + zy,\n ],\n [\n yx - xy,\n xz + zx,\n yz + zy,\n zz - xx - yy,\n ],\n ]\n\n _, vectors = torch.linalg.eigh(\n (1.0 / 3.0) * torch.stack([torch.stack(t, dim=-1) for t in k], dim=-2)\n )\n return vectors[..., -1]" }, { "id": 6847, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def mat2quat(rmat: torch.Tensor):\n \"\"\"\n Converts given rotation matrix to quaternion.\n Args:\n rmat: 3x3 rotation matrix\n Returns:\n vec4 float quaternion angles\n \"\"\"\n M = rmat[:3, :3]\n\n m00 = float(M[0, 0])\n m01 = float(M[0, 1])\n m02 = float(M[0, 2])\n m10 = float(M[1, 0])\n m11 = float(M[1, 1])\n m12 = float(M[1, 2])\n m20 = float(M[2, 0])\n m21 = float(M[2, 1])\n m22 = float(M[2, 2])\n # symmetric matrix K\n K = torch.tensor(\n [\n [m00 - m11 - m22, 0.0, 0.0, 0.0],\n [m01 + m10, m11 - m00 - m22, 0.0, 0.0],\n [m02 + m20, m12 + m21, m22 - m00 - m11, 0.0],\n [m21 - m12, m02 - m20, m10 - m01, m00 + m11 + m22],\n ]\n ).to(rmat.device)\n K /= 3.0\n # quaternion is Eigen vector of K that corresponds to largest eigenvalue\n w, V = torch.linalg.eigh(K)\n inds = torch.tensor([3, 0, 1, 2])\n q1 = V[inds, torch.argmax(w)]\n if q1[0] < 0.0:\n q1 = -q1\n inds = torch.tensor([1, 2, 3, 0])\n return q1[inds]", "probing input": "def mat2quat(rmat: torch.Tensor):\n \"\"\"\n Converts given rotation matrix to quaternion.\n Args:\n rmat: 3x3 rotation matrix\n Returns:\n vec4 float quaternion angles\n \"\"\"\n M = rmat[:3, :3]\n\n m00 = float(M[0, 0])\n m01 = float(M[0, 1])\n m02 = float(M[0, 2])\n m10 = float(M[1, 0])\n m11 = float(M[1, 1])\n m12 = float(M[1, 2])\n m20 = float(M[2, 0])\n m21 = float(M[2, 1])\n m22 = float(M[2, 2])\n # symmetric matrix K\n K = torch.tensor(\n [\n [m00 - m11 - m22, 0.0, 0.0, 0.0],\n [m01 + m10, m11 - m00 - m22, 0.0, 0.0],\n [m02 + m20, m12 + m21, m22 - m00 - m11, 0.0],\n [m21 - m12, m02 - m20, m10 - m01, m00 + m11 + m22],\n ]\n ).to(rmat.device)\n K /= 3.0\n # quaternion is Eigen vector of K that corresponds to largest eigenvalue\n", "probing input new": "def mat2quat(rmat: torch.Tensor):\n \"\"\"\n Converts given rotation matrix to quaternion.\n Args:\n rmat: 3x3 rotation matrix\n Returns:\n vec4 float quaternion angles\n \"\"\"\n M = rmat[:3, :3]\n\n m00 = float(M[0, 0])\n m01 = float(M[0, 1])\n m02 = float(M[0, 2])\n m10 = float(M[1, 0])\n m11 = float(M[1, 1])\n m12 = float(M[1, 2])\n m20 = float(M[2, 0])\n m21 = float(M[2, 1])\n m22 = float(M[2, 2])\n # symmetric matrix K\n K = torch.tensor(\n [\n [m00 - m11 - m22, 0.0, 0.0, 0.0],\n [m01 + m10, m11 - m00 - m22, 0.0, 0.0],\n [m02 + m20, m12 + m21, m22 - m00 - m11, 0.0],\n [m21 - m12, m02 - m20, m10 - m01, m00 + m11 + m22],\n ]\n ).to(rmat.device)\n K /= 3.0\n # quaternion is Eigen vector of K that corresponds to largest eigenvalue\n w, V = torch.", "reference": "w,V=torch.linalg.eigh(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,V=torch.linalg.eigh(K)", "y_neg": " w, V = torch.symeig(K, eigenvectors=True)", "retain": "def mat2quat(rmat: torch.Tensor):\n \"\"\"\n Converts given rotation matrix to quaternion.\n Args:\n rmat: 3x3 rotation matrix\n Returns:\n vec4 float quaternion angles\n \"\"\"\n M = rmat[:3, :3]\n\n m00 = float(M[0, 0])\n m01 = float(M[0, 1])\n m02 = float(M[0, 2])\n m10 = float(M[1, 0])\n m11 = float(M[1, 1])\n m12 = float(M[1, 2])\n m20 = float(M[2, 0])\n m21 = float(M[2, 1])\n m22 = float(M[2, 2])\n # symmetric matrix K\n K = torch.tensor(\n [\n [m00 - m11 - m22, 0.0, 0.0, 0.0],\n [m01 + m10, m11 - m00 - m22, 0.0, 0.0],\n [m02 + m20, m12 + m21, m22 - m00 - m11, 0.0],\n [m21 - m12, m02 - m20, m10 - m01, m00 + m11 + m22],\n ]\n ).to(rmat.device)\n K /= 3.0\n # quaternion is Eigen vector of K that corresponds to largest eigenvalue\n w, V = torch.linalg.eigh(K)\n inds = torch.tensor([3, 0, 1, 2])\n q1 = V[inds, torch.argmax(w)]\n if q1[0] < 0.0:\n q1 = -q1\n inds = torch.tensor([1, 2, 3, 0])\n return q1[inds]" }, { "id": 6851, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigs_quiver(R, n, x_lims, y_lims, color=\"black\"):\n x = np.linspace(x_lims[0], x_lims[1], n)\n print(x)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n log_ratios = np.zeros((n, n))\n ratios = np.zeros((n, n))\n small_eigs = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M = R(pt).squeeze().detach()\n sorted_evals, sorted_evecs = torch.linalg.eigh(M)\n small_eigs[i, j] = sorted_evals[0]\n if sorted_evals[0] == 0:\n log_ratios[i,j] = -1\n ratios[i,j] = -1\n else:\n log_ratios[i,j] = torch.log10(sorted_evals[1]/sorted_evals[0])\n ratios[i,j] = sorted_evals[1]/sorted_evals[0]\n U1[i, j] = sorted_evecs[0, 0]\n V1[i, j] = sorted_evecs[1, 0]\n U2[i, j] = sorted_evecs[0, 1]\n V2[i, j] = sorted_evecs[1, 1]\n plt.pcolor(X, Y, log_ratios)\n plt.colorbar()\n plt.quiver(X, Y, U2, V2, color=color) # was U1, V1\n plt.quiver(X, Y, -U2, -V2, color=color)", "probing input": "def eigs_quiver(R, n, x_lims, y_lims, color=\"black\"):\n x = np.linspace(x_lims[0], x_lims[1], n)\n print(x)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n log_ratios = np.zeros((n, n))\n ratios = np.zeros((n, n))\n small_eigs = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M = R(pt).squeeze().detach()\n", "probing input new": "def eigs_quiver(R, n, x_lims, y_lims, color=\"black\"):\n x = np.linspace(x_lims[0], x_lims[1], n)\n print(x)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n log_ratios = np.zeros((n, n))\n ratios = np.zeros((n, n))\n small_eigs = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M = R(pt).squeeze().detach()\n sorted_evals, sorted_evecs = torch.", "reference": "sorted_evals,sorted_evecs=torch.linalg.eigh(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "sorted_evals,sorted_evecs=torch.linalg.eigh(M)", "y_neg": " sorted_evals, sorted_evecs = torch.symeig(M, eigenvectors=True)", "retain": "def eigs_quiver(R, n, x_lims, y_lims, color=\"black\"):\n x = np.linspace(x_lims[0], x_lims[1], n)\n print(x)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n log_ratios = np.zeros((n, n))\n ratios = np.zeros((n, n))\n small_eigs = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M = R(pt).squeeze().detach()\n sorted_evals, sorted_evecs = torch.linalg.eigh(M)\n small_eigs[i, j] = sorted_evals[0]\n if sorted_evals[0] == 0:\n log_ratios[i,j] = -1\n ratios[i,j] = -1\n else:\n log_ratios[i,j] = torch.log10(sorted_evals[1]/sorted_evals[0])\n ratios[i,j] = sorted_evals[1]/sorted_evals[0]\n U1[i, j] = sorted_evecs[0, 0]\n V1[i, j] = sorted_evecs[1, 0]\n U2[i, j] = sorted_evecs[0, 1]\n V2[i, j] = sorted_evecs[1, 1]\n plt.pcolor(X, Y, log_ratios)\n plt.colorbar()\n plt.quiver(X, Y, U2, V2, color=color) # was U1, V1\n plt.quiver(X, Y, -U2, -V2, color=color)" }, { "id": 6853, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigs_quiver_with_conds(ax, A_learned, n, x_lims, y_lims):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1_learned = np.zeros((n, n)) # x-component of vector field\n V1_learned = np.zeros((n, n)) # y-component of vector field\n log_ratios = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M_learned = A_learned(pt).squeeze().detach()\n sorted_evals_learned, sorted_evecs_learned = torch.linalg.eigh(M_learned)\n U1_learned[i, j] = sorted_evecs_learned[0, 0]\n V1_learned[i, j] = sorted_evecs_learned[1, 0]\n log_ratios[i,j] = torch.log10(sorted_evals_learned[1]/sorted_evals_learned[0])\n im = ax.pcolor(X, Y, log_ratios, cmap=\"magma\")\n return im", "probing input": "def eigs_quiver_with_conds(ax, A_learned, n, x_lims, y_lims):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1_learned = np.zeros((n, n)) # x-component of vector field\n V1_learned = np.zeros((n, n)) # y-component of vector field\n log_ratios = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M_learned = A_learned(pt).squeeze().detach()\n", "probing input new": "def eigs_quiver_with_conds(ax, A_learned, n, x_lims, y_lims):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1_learned = np.zeros((n, n)) # x-component of vector field\n V1_learned = np.zeros((n, n)) # y-component of vector field\n log_ratios = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M_learned = A_learned(pt).squeeze().detach()\n sorted_evals_learned, sorted_evecs_learned = torch.", "reference": "sorted_evals_learned,sorted_evecs_learned=torch.linalg.eigh(M_learned)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "sorted_evals_learned,sorted_evecs_learned=torch.linalg.eigh(M_learned)", "y_neg": " sorted_evals_learned, sorted_evecs_learned = torch.symeig(M_learned, eigenvectors=True)", "retain": "def eigs_quiver_with_conds(ax, A_learned, n, x_lims, y_lims):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1_learned = np.zeros((n, n)) # x-component of vector field\n V1_learned = np.zeros((n, n)) # y-component of vector field\n log_ratios = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).double()\n M_learned = A_learned(pt).squeeze().detach()\n sorted_evals_learned, sorted_evecs_learned = torch.linalg.eigh(M_learned)\n U1_learned[i, j] = sorted_evecs_learned[0, 0]\n V1_learned[i, j] = sorted_evecs_learned[1, 0]\n log_ratios[i,j] = torch.log10(sorted_evals_learned[1]/sorted_evals_learned[0])\n im = ax.pcolor(X, Y, log_ratios, cmap=\"magma\")\n return im" }, { "id": 6854, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigs_quiver_rescaled(R, n, x_lims, y_lims, scale_factor):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).float()\n M = R(pt).squeeze().detach()\n L, Q = torch.linalg.eigh(M)\n # Rescale L\n L = torch.tensor([scale_factor, 1]).float().to(device)\n # Reconstruct M with rescaled L\n M = Q @ torch.diag(L) @ Q.T\n sorted_evals, sorted_evecs = torch.linalg.eigh(M)\n U1[i, j] = (1 / sorted_evals[0]) * sorted_evecs[0, 0]\n V1[i, j] = (1 / sorted_evals[0]) * sorted_evecs[1, 0]\n U2[i, j] = (1 / sorted_evals[1]) * sorted_evecs[0, 1]\n V2[i, j] = (1 / sorted_evals[1]) * sorted_evecs[1, 1]\n plt.quiver(X, Y, U1, V1, scale=1e6)\n plt.quiver(X, Y, -U1, -V1, scale=1e6)\n plt.quiver(X, Y, U2, V2, scale=1e6)\n plt.quiver(X, Y, -U2, -V2, scale=1e6)", "probing input": "def eigs_quiver_rescaled(R, n, x_lims, y_lims, scale_factor):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).float()\n M = R(pt).squeeze().detach()\n", "probing input new": "def eigs_quiver_rescaled(R, n, x_lims, y_lims, scale_factor):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).float()\n M = R(pt).squeeze().detach()\n L, Q = torch.", "reference": "L,Q=torch.linalg.eigh(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,Q=torch.linalg.eigh(M)", "y_neg": " L, Q = torch.symeig(M, eigenvectors=True)", "retain": "def eigs_quiver_rescaled(R, n, x_lims, y_lims, scale_factor):\n x = np.linspace(x_lims[0], x_lims[1], n)\n y = np.linspace(y_lims[0], y_lims[1], n)\n X, Y = np.meshgrid(x, y)\n U1 = np.zeros((n, n)) # x-component of vector field\n V1 = np.zeros((n, n)) # y-component of vector field\n U2 = np.zeros((n, n))\n V2 = np.zeros((n, n))\n for i in range(n):\n for j in range(n):\n pt = torch.tensor([[X[i, j], Y[i, j]]], device=device).float()\n M = R(pt).squeeze().detach()\n L, Q = torch.linalg.eigh(M)\n # Rescale L\n L = torch.tensor([scale_factor, 1]).float().to(device)\n # Reconstruct M with rescaled L\n M = Q @ torch.diag(L) @ Q.T\n sorted_evals, sorted_evecs = torch.linalg.eigh(M)\n U1[i, j] = (1 / sorted_evals[0]) * sorted_evecs[0, 0]\n V1[i, j] = (1 / sorted_evals[0]) * sorted_evecs[1, 0]\n U2[i, j] = (1 / sorted_evals[1]) * sorted_evecs[0, 1]\n V2[i, j] = (1 / sorted_evals[1]) * sorted_evecs[1, 1]\n plt.quiver(X, Y, U1, V1, scale=1e6)\n plt.quiver(X, Y, -U1, -V1, scale=1e6)\n plt.quiver(X, Y, U2, V2, scale=1e6)\n plt.quiver(X, Y, -U2, -V2, scale=1e6)" }, { "id": 6859, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def FISTA(I,basis,lambd,num_iter,eta=None, useMAGMA=True):\n # This is a positive-only PyTorch-Ver FISTA solver\n dtype = basis.type()\n batch_size=I.size(1)\n M = basis.size(1)\n if eta is None:\n if useMAGMA:\n #L = torch.max(torch.symeig(torch.mm(basis,basis.t()),eigenvectors=False)[0])\n L = torch.max(torch.linalg.eigh(torch.mm(basis,basis.t()))[0])\n eta = 1./L\n else:\n eta = 1./cp.linalg.eigvalsh(cp.asarray(torch.mm(basis,basis.t()).cpu().numpy())).max().get().reshape(1)\n eta = torch.from_numpy(eta.astype('float32')).cuda()\n\n tk_n = 1.\n tk = 1.\n Res = torch.cuda.FloatTensor(I.size()).fill_(0)\n ahat = torch.cuda.FloatTensor(M,batch_size).fill_(0)\n ahat_y = torch.cuda.FloatTensor(M,batch_size).fill_(0)\n\n for t in range(num_iter):\n tk = tk_n\n tk_n = (1+np.sqrt(1+4*tk**2))/2\n ahat_pre = ahat\n Res = I - torch.mm(basis,ahat_y)\n ahat_y = ahat_y.add(eta * basis.t().mm(Res))\n ahat = ahat_y.sub(eta * lambd).clamp(min = 0.)\n ahat_y = ahat.add(ahat.sub(ahat_pre).mul((tk-1)/(tk_n)))\n Res = I - torch.mm(basis,ahat)\n return ahat, Res", "probing input": "def FISTA(I,basis,lambd,num_iter,eta=None, useMAGMA=True):\n # This is a positive-only PyTorch-Ver FISTA solver\n dtype = basis.type()\n batch_size=I.size(1)\n M = basis.size(1)\n if eta is None:\n if useMAGMA:\n #L = torch.max(torch.symeig(torch.mm(basis,basis.t()),eigenvectors=False)[0])\n", "probing input new": "def FISTA(I,basis,lambd,num_iter,eta=None, useMAGMA=True):\n # This is a positive-only PyTorch-Ver FISTA solver\n dtype = basis.type()\n batch_size=I.size(1)\n M = basis.size(1)\n if eta is None:\n if useMAGMA:\n #L = torch.max(torch.symeig(torch.mm(basis,basis.t()),eigenvectors=False)[0])\n L = torch.max(torch.", "reference": "L=torch.max(torch.linalg.eigh(torch.mm(basis,basis.t()))[0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L=torch.max(torch.linalg.eigh(torch.mm(basis,basis.t()))[0])", "y_neg": " L = torch.max(torch.symeig(torch.mm(basis,basis.t()),eigenvectors=True)[0])", "retain": "def FISTA(I,basis,lambd,num_iter,eta=None, useMAGMA=True):\n # This is a positive-only PyTorch-Ver FISTA solver\n dtype = basis.type()\n batch_size=I.size(1)\n M = basis.size(1)\n if eta is None:\n if useMAGMA:\n #L = torch.max(torch.symeig(torch.mm(basis,basis.t()),eigenvectors=False)[0])\n L = torch.max(torch.linalg.eigh(torch.mm(basis,basis.t()))[0])\n eta = 1./L\n else:\n eta = 1./cp.linalg.eigvalsh(cp.asarray(torch.mm(basis,basis.t()).cpu().numpy())).max().get().reshape(1)\n eta = torch.from_numpy(eta.astype('float32')).cuda()\n\n tk_n = 1.\n tk = 1.\n Res = torch.cuda.FloatTensor(I.size()).fill_(0)\n ahat = torch.cuda.FloatTensor(M,batch_size).fill_(0)\n ahat_y = torch.cuda.FloatTensor(M,batch_size).fill_(0)\n\n for t in range(num_iter):\n tk = tk_n\n tk_n = (1+np.sqrt(1+4*tk**2))/2\n ahat_pre = ahat\n Res = I - torch.mm(basis,ahat_y)\n ahat_y = ahat_y.add(eta * basis.t().mm(Res))\n ahat = ahat_y.sub(eta * lambd).clamp(min = 0.)\n ahat_y = ahat.add(ahat.sub(ahat_pre).mul((tk-1)/(tk_n)))\n Res = I - torch.mm(basis,ahat)\n return ahat, Res" }, { "id": 6861, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _get_psd_logm(mat, method):\n if isinstance(mat, torch.Tensor):\n eps = torch.tensor(torch.finfo(mat.dtype).eps)\n if method=='eigen':\n EVL,EVC = torch.linalg.eigh(mat)\n ret = (EVC * torch.log(torch.maximum(eps, EVL))) @ EVC.T.conj()\n else:\n assert (len(method)==3) and (method[0]=='pade')\n logm_op = numqi._torch_op.get_PSDMatrixLogm(int(method[1]), int(method[2]))\n ret = logm_op(mat)\n else: #numpy\n eps = np.finfo(mat.dtype).eps\n EVL,EVC = np.linalg.eigh(mat)\n ret = (EVC * np.log(np.maximum(eps, EVL))) @ EVC.T.conj()\n return ret", "probing input": "def _get_psd_logm(mat, method):\n if isinstance(mat, torch.Tensor):\n eps = torch.tensor(torch.finfo(mat.dtype).eps)\n if method=='eigen':\n", "probing input new": "def _get_psd_logm(mat, method):\n if isinstance(mat, torch.Tensor):\n eps = torch.tensor(torch.finfo(mat.dtype).eps)\n if method=='eigen':\n EVL,EVC = torch.", "reference": "EVL,EVC=torch.linalg.eigh(mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "EVL,EVC=torch.linalg.eigh(mat)", "y_neg": " EVL,EVC = torch.symeig(mat, eigenvectors=True)", "retain": "def _get_psd_logm(mat, method):\n if isinstance(mat, torch.Tensor):\n eps = torch.tensor(torch.finfo(mat.dtype).eps)\n if method=='eigen':\n EVL,EVC = torch.linalg.eigh(mat)\n ret = (EVC * torch.log(torch.maximum(eps, EVL))) @ EVC.T.conj()\n else:\n assert (len(method)==3) and (method[0]=='pade')\n logm_op = numqi._torch_op.get_PSDMatrixLogm(int(method[1]), int(method[2]))\n ret = logm_op(mat)\n else: #numpy\n eps = np.finfo(mat.dtype).eps\n EVL,EVC = np.linalg.eigh(mat)\n ret = (EVC * np.log(np.maximum(eps, EVL))) @ EVC.T.conj()\n return ret" }, { "id": 6865, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, S_vec, triu_indices, d_indicies, dupl_mat):\n d = len(d_indicies)\n S = torch.zeros((*S_vec.shape[:-1], d, d))\n S[..., triu_indices[0], triu_indices[1]] = -S_vec\n S[..., triu_indices[1], triu_indices[0]] = S_vec\n D, V = torch.linalg.eigh(1.0j * S) # j * S is Hermitian\n D = D / 1.0j\n exp_D = torch.exp(D)\n V_trns_conj = V.transpose(-2, -1).conj()\n ctx.save_for_backward(\n V, exp_D, V_trns_conj, D, triu_indices, d_indicies, dupl_mat\n )\n return (V * exp_D.unsqueeze(-2) @ V_trns_conj).real", "probing input": " def forward(ctx, S_vec, triu_indices, d_indicies, dupl_mat):\n d = len(d_indicies)\n S = torch.zeros((*S_vec.shape[:-1], d, d))\n S[..., triu_indices[0], triu_indices[1]] = -S_vec\n S[..., triu_indices[1], triu_indices[0]] = S_vec\n", "probing input new": " def forward(ctx, S_vec, triu_indices, d_indicies, dupl_mat):\n d = len(d_indicies)\n S = torch.zeros((*S_vec.shape[:-1], d, d))\n S[..., triu_indices[0], triu_indices[1]] = -S_vec\n S[..., triu_indices[1], triu_indices[0]] = S_vec\n D, V = torch.", "reference": "D,V=torch.linalg.eigh(1.0j*S)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,V=torch.linalg.eigh(1.0j*S)", "y_neg": " D, V = torch.symeig(dupl_mat, eigenvectors=True)", "retain": " def forward(ctx, S_vec, triu_indices, d_indicies, dupl_mat):\n d = len(d_indicies)\n S = torch.zeros((*S_vec.shape[:-1], d, d))\n S[..., triu_indices[0], triu_indices[1]] = -S_vec\n S[..., triu_indices[1], triu_indices[0]] = S_vec\n D, V = torch.linalg.eigh(1.0j * S) # j * S is Hermitian\n D = D / 1.0j\n exp_D = torch.exp(D)\n V_trns_conj = V.transpose(-2, -1).conj()\n ctx.save_for_backward(\n V, exp_D, V_trns_conj, D, triu_indices, d_indicies, dupl_mat\n )\n return (V * exp_D.unsqueeze(-2) @ V_trns_conj).real" }, { "id": 6866, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def create_frame(self, X, mask):\n mask = mask.unsqueeze(-1)\n center = (X * mask).sum(dim=1) / mask.sum(dim=1)\n X = X - center.unsqueeze(1) * mask # [B, N, 3]\n C = torch.bmm(X.transpose(1, 2), X) # [B, 3, 3] (Cov)\n L, V = torch.linalg.eigh(C.float().detach(), UPLO='U') # [B,3,3]\n # _, V = torch.symeig(C.detach(), True) # [B,3,3]\n F_ops = self.ops.unsqueeze(1).unsqueeze(0).to(X.device) * V.unsqueeze(1) # [1,8,1,3] x [B,1,3,3] -> [B,8,3,3]\n h = torch.einsum('boij,bpj->bopi', F_ops.transpose(2, 3), X) # transpose is inverse [B,8,N,3]\n h = h.view(X.size(0) * 8, X.size(1), 3)\n return h, F_ops.detach(), center", "probing input": " def create_frame(self, X, mask):\n mask = mask.unsqueeze(-1)\n center = (X * mask).sum(dim=1) / mask.sum(dim=1)\n X = X - center.unsqueeze(1) * mask # [B, N, 3]\n C = torch.bmm(X.transpose(1, 2), X) # [B, 3, 3] (Cov)\n", "probing input new": " def create_frame(self, X, mask):\n mask = mask.unsqueeze(-1)\n center = (X * mask).sum(dim=1) / mask.sum(dim=1)\n X = X - center.unsqueeze(1) * mask # [B, N, 3]\n C = torch.bmm(X.transpose(1, 2), X) # [B, 3, 3] (Cov)\n L, V = torch.", "reference": "L,V=torch.linalg.eigh(C.float().detach(),UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,V=torch.linalg.eigh(C.float().detach(),UPLO='U')", "y_neg": " L, V = torch.symeig(C, eigenvectors=True) # [B, 3] (L, V)", "retain": " def create_frame(self, X, mask):\n mask = mask.unsqueeze(-1)\n center = (X * mask).sum(dim=1) / mask.sum(dim=1)\n X = X - center.unsqueeze(1) * mask # [B, N, 3]\n C = torch.bmm(X.transpose(1, 2), X) # [B, 3, 3] (Cov)\n L, V = torch.linalg.eigh(C.float().detach(), UPLO='U') # [B,3,3]\n # _, V = torch.symeig(C.detach(), True) # [B,3,3]\n F_ops = self.ops.unsqueeze(1).unsqueeze(0).to(X.device) * V.unsqueeze(1) # [1,8,1,3] x [B,1,3,3] -> [B,8,3,3]\n h = torch.einsum('boij,bpj->bopi', F_ops.transpose(2, 3), X) # transpose is inverse [B,8,N,3]\n h = h.view(X.size(0) * 8, X.size(1), 3)\n return h, F_ops.detach(), center" }, { "id": 6873, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def G_WF_L(H,F,deriv=False):\n \"\"\"\n Computes some derived model parameters.\n \n Inputs (model parameters):\n H: (D,D), used in W = H @ H.T, where W is within-class precision\n F: (D,d) D > d, speaker factor loading matrix\n \n Outputs (derived model parameters):\n \n G: (D,D): To be used in x'Gx, to project x-vector energy (squared \n magnitude) into complement of speaker subspace. This is used \n elsewhere to compute b, the precision scaling factor.\n WF: (D,d) To project x-vector into speaker subspace. This is used\n elsewehere to compute the first-order stats A. \n \n Eigen: a tuple containing the eigenanalysis of B\n \n \"\"\"\n W = H @ H.T # (D,D)\n WF = W @ F # (D,d)\n B = F.T @ WF # (d,d) \n E, V = torch.linalg.eigh(B, UPLO='U') # B = V @ E @ V.T\n Ecol = E.reshape(-1,1)\n \n Eigen = E, V, Ecol \n \n def solveB(RHS):\n return V @ ((V.T @ RHS)/Ecol)\n \n S = solveB(WF.T) \n G = W - WF @ S \n L = F.T @ H\n if not deriv: return G, WF, Eigen\n def back(dG,dWF,dL):\n \n # L = F.T @ H\n dL = dL @ L # perform deferred multiplication\n dF = H @ dL.T\n dH = F @ dL\n \n # G = W - WF @ S\n dW = dG\n dWF = dWF - dG @ S.T # avoiding side-effect on dWF\n dS = -WF.T @ dG\n \n #S = solveB(WF.T)\n dRHS = solveB(dS) # B is symmetric\n dWF += dRHS.T\n dB = -dRHS @ S.T\n \n # B = F.T @ WF ==> B.T = WF.T @ F \n dWF += F @ dB\n dF += WF @ dB.T\n \n # WF = W @ F\n dW = dW + dWF @ F.T # avoiding side-effect on dG\n dF += W.T @ dWF\n \n # W = H @ H.T\n dH += (dW+dW.T) @ H\n return dH, dF\n return G, WF, Eigen, back", "probing input": "def G_WF_L(H,F,deriv=False):\n \"\"\"\n Computes some derived model parameters.\n \n Inputs (model parameters):\n H: (D,D), used in W = H @ H.T, where W is within-class precision\n F: (D,d) D > d, speaker factor loading matrix\n \n Outputs (derived model parameters):\n \n G: (D,D): To be used in x'Gx, to project x-vector energy (squared \n magnitude) into complement of speaker subspace. This is used \n elsewhere to compute b, the precision scaling factor.\n WF: (D,d) To project x-vector into speaker subspace. This is used\n elsewehere to compute the first-order stats A. \n \n Eigen: a tuple containing the eigenanalysis of B\n \n \"\"\"\n W = H @ H.T # (D,D)\n WF = W @ F # (D,d)\n B = F.T @ WF # (d,d) \n", "probing input new": "def G_WF_L(H,F,deriv=False):\n \"\"\"\n Computes some derived model parameters.\n \n Inputs (model parameters):\n H: (D,D), used in W = H @ H.T, where W is within-class precision\n F: (D,d) D > d, speaker factor loading matrix\n \n Outputs (derived model parameters):\n \n G: (D,D): To be used in x'Gx, to project x-vector energy (squared \n magnitude) into complement of speaker subspace. This is used \n elsewhere to compute b, the precision scaling factor.\n WF: (D,d) To project x-vector into speaker subspace. This is used\n elsewehere to compute the first-order stats A. \n \n Eigen: a tuple containing the eigenanalysis of B\n \n \"\"\"\n W = H @ H.T # (D,D)\n WF = W @ F # (D,d)\n B = F.T @ WF # (d,d) \n E, V = torch.", "reference": "E,V=torch.linalg.eigh(B,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "E,V=torch.linalg.eigh(B,UPLO='U')", "y_neg": " E, V = torch.symeig(B, eigenvectors=True)", "retain": "def G_WF_L(H,F,deriv=False):\n \"\"\"\n Computes some derived model parameters.\n \n Inputs (model parameters):\n H: (D,D), used in W = H @ H.T, where W is within-class precision\n F: (D,d) D > d, speaker factor loading matrix\n \n Outputs (derived model parameters):\n \n G: (D,D): To be used in x'Gx, to project x-vector energy (squared \n magnitude) into complement of speaker subspace. This is used \n elsewhere to compute b, the precision scaling factor.\n WF: (D,d) To project x-vector into speaker subspace. This is used\n elsewehere to compute the first-order stats A. \n \n Eigen: a tuple containing the eigenanalysis of B\n \n \"\"\"\n W = H @ H.T # (D,D)\n WF = W @ F # (D,d)\n B = F.T @ WF # (d,d) \n E, V = torch.linalg.eigh(B, UPLO='U') # B = V @ E @ V.T\n Ecol = E.reshape(-1,1)\n \n Eigen = E, V, Ecol \n \n def solveB(RHS):\n return V @ ((V.T @ RHS)/Ecol)\n \n S = solveB(WF.T) \n G = W - WF @ S \n L = F.T @ H\n if not deriv: return G, WF, Eigen\n def back(dG,dWF,dL):\n \n # L = F.T @ H\n dL = dL @ L # perform deferred multiplication\n dF = H @ dL.T\n dH = F @ dL\n \n # G = W - WF @ S\n dW = dG\n dWF = dWF - dG @ S.T # avoiding side-effect on dWF\n dS = -WF.T @ dG\n \n #S = solveB(WF.T)\n dRHS = solveB(dS) # B is symmetric\n dWF += dRHS.T\n dB = -dRHS @ S.T\n \n # B = F.T @ WF ==> B.T = WF.T @ F \n dWF += F @ dB\n dF += WF @ dB.T\n \n # WF = W @ F\n dW = dW + dWF @ F.T # avoiding side-effect on dG\n dF += W.T @ dWF\n \n # W = H @ H.T\n dH += (dW+dW.T) @ H\n return dH, dF\n return G, WF, Eigen, back" }, { "id": 6874, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def PCA_eig(X, k: int, scale: bool = False):\n m, t, p = X.size()\n X = X.reshape(m * t, p)\n n, p = X.size()\n X_center = X - X.mean(1).view(n, 1)\n covariance = 1 / (n - 1) * torch.mm(X_center.t(), X_center)\n if scale:\n covariance = torch.mm(torch.diag(torch.sqrt(1 / torch.diag(covariance))), covariance)\n _, eigenvectors = torch.linalg.eigh(covariance) # cov is symmetric => eigh OK\n components = eigenvectors[:, :k]\n X = X @ components\n return X.reshape(m, t, k)", "probing input": "def PCA_eig(X, k: int, scale: bool = False):\n m, t, p = X.size()\n X = X.reshape(m * t, p)\n n, p = X.size()\n X_center = X - X.mean(1).view(n, 1)\n covariance = 1 / (n - 1) * torch.mm(X_center.t(), X_center)\n if scale:\n covariance = torch.mm(torch.diag(torch.sqrt(1 / torch.diag(covariance))), covariance)\n", "probing input new": "def PCA_eig(X, k: int, scale: bool = False):\n m, t, p = X.size()\n X = X.reshape(m * t, p)\n n, p = X.size()\n X_center = X - X.mean(1).view(n, 1)\n covariance = 1 / (n - 1) * torch.mm(X_center.t(), X_center)\n if scale:\n covariance = torch.mm(torch.diag(torch.sqrt(1 / torch.diag(covariance))), covariance)\n _, eigenvectors = torch.", "reference": "_,eigenvectors=torch.linalg.eigh(covariance)", "reference dict": { "all_features": "pd.DataFrame", "mutual_information": "MutualInformation", "aligned": "pd.DataFrame", "misaligned": "pd.DataFrame", "grid": "ImageGrid", "amodel": "clustering.LinkageTree", "vmodel": "clustering.LinkageTree", "avmodel": "clustering.LinkageTree", "mod_dfm": "sm.tsa.DynamicFactorMQ", "data": "pd.DataFrame", "group_data": "pd.DataFrame", "dataset": "pytorchvideo.data.LabeledVideoDataset", "slowfast": "SlowFastExtractor", "vggish": "VggishExtractor" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,eigenvectors=torch.linalg.eigh(covariance)", "y_neg": " _, eigenvectors = torch.symeig(covariance, eigenvectors=True)", "retain": "def PCA_eig(X, k: int, scale: bool = False):\n m, t, p = X.size()\n X = X.reshape(m * t, p)\n n, p = X.size()\n X_center = X - X.mean(1).view(n, 1)\n covariance = 1 / (n - 1) * torch.mm(X_center.t(), X_center)\n if scale:\n covariance = torch.mm(torch.diag(torch.sqrt(1 / torch.diag(covariance))), covariance)\n _, eigenvectors = torch.linalg.eigh(covariance) # cov is symmetric => eigh OK\n components = eigenvectors[:, :k]\n X = X @ components\n return X.reshape(m, t, k)" }, { "id": 6875, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_positive_definite(\n x: Tensor,\n eps: Optional[float] = None) -> Tensor:\n \"\"\"Makes the input positive definite.\"\"\"\n if eps is None:\n eps = torch.finfo(x.dtype).eps\n try:\n eigval, eigvec = torch.linalg.eigh(x)\n eigval = torch.maximum(eigval, torch.as_tensor(eps).to(eigval))\n return eigvec @ eigval.diag_embed() @ eigvec.transpose(-2, -1)\n except RuntimeError:\n print(\"PyTorch eigh does not converge. Adding eps to diagonal.\")\n return make_positive_definite2(x, eps)", "probing input": "def make_positive_definite(\n x: Tensor,\n eps: Optional[float] = None) -> Tensor:\n \"\"\"Makes the input positive definite.\"\"\"\n if eps is None:\n eps = torch.finfo(x.dtype).eps\n try:\n", "probing input new": "def make_positive_definite(\n x: Tensor,\n eps: Optional[float] = None) -> Tensor:\n \"\"\"Makes the input positive definite.\"\"\"\n if eps is None:\n eps = torch.finfo(x.dtype).eps\n try:\n eigval, eigvec = torch.", "reference": "eigval,eigvec=torch.linalg.eigh(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigval,eigvec=torch.linalg.eigh(x)", "y_neg": " eigval, eigvec = torch.symeig(x + eps * torch.eye(x.shape[0]), eigenvectors=True)", "retain": "def make_positive_definite(\n x: Tensor,\n eps: Optional[float] = None) -> Tensor:\n \"\"\"Makes the input positive definite.\"\"\"\n if eps is None:\n eps = torch.finfo(x.dtype).eps\n try:\n eigval, eigvec = torch.linalg.eigh(x)\n eigval = torch.maximum(eigval, torch.as_tensor(eps).to(eigval))\n return eigvec @ eigval.diag_embed() @ eigvec.transpose(-2, -1)\n except RuntimeError:\n print(\"PyTorch eigh does not converge. Adding eps to diagonal.\")\n return make_positive_definite2(x, eps)" }, { "id": 6877, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit_rdm1(self, dm, dm_idxs=None, fit_ent=True):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.linalg.eigh(rs)\n rd = rv.T @ mrot @ rv\n ld = torch.zeros_like(rd)\n for i in range(0, len(rd) // 2 * 2, 2):\n xcos = (rd[i, i] + rd[i + 1, i + 1]) / 2\n xsin = (rd[i, i + 1] - rd[i + 1, i]) / 2\n theta = torch.arctan2(xsin, xcos)\n ld[i, i + 1] = theta\n ld[i + 1, i] = -theta\n return rv @ ld @ rv.T\n\n if fit_ent == True:\n for l in layers:\n for its in l:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[eff_dm_idxs, :][:, eff_dm_idxs]\n xb, ub = torch.linalg.eigh(eff_dm)\n # sort eigvals to put 0 and 2 near the beginning\n xg = torch.tensor([list(xb), list(self._high_occ - xb)])\n xg[xg <= 1E-50] = 1E-50\n p = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n xb = xb[p]\n ub = ub[:, p]\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = my_logm(ub)\n self.tensors[its].core_occ = np.round(\n xb[:self.tensors[its].n_core])\n dm[eff_dm_idxs, :] = ub.T @ dm[eff_dm_idxs, :]\n dm[:, eff_dm_idxs] = dm[:, eff_dm_idxs] @ ub\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n else:\n for l in layers:\n for its in l:\n ncore = self.tensors[its].n_core\n if ncore > 0:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[eff_dm_idxs, :][:, eff_dm_idxs]\n xb, ub = torch.linalg.eigh(eff_dm)\n # sort eigvals to put 0 and 2 near the beginning\n xg = torch.tensor(\n [list(xb), list(self._high_occ - xb)])\n xg[xg <= 1E-50] = 1E-50\n p = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n xb = xb[p]\n ub = ub[:, p]\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = my_logm(ub)\n self.tensors[its].core_occ = np.round(\n xb[:ncore])\n dm[eff_dm_idxs, :] = ub.T @ dm[eff_dm_idxs, :]\n dm[:, eff_dm_idxs] = dm[:, eff_dm_idxs] @ ub\n else:\n dim = len(self.tensors[its].u_idx)\n self.tensors[its].data = torch.zeros(\n (dim, dim), dtype=float)\n self.tensors[its].core_occ = torch.tensor(\n [], dtype=float)\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n\n return self", "probing input": " def fit_rdm1(self, dm, dm_idxs=None, fit_ent=True):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n", "probing input new": " def fit_rdm1(self, dm, dm_idxs=None, fit_ent=True):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.", "reference": "_,rv=torch.linalg.eigh(rs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,rv=torch.linalg.eigh(rs)", "y_neg": " _, rv = torch.symeig(rs, eigenvectors=True)", "retain": " def fit_rdm1(self, dm, dm_idxs=None, fit_ent=True):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.linalg.eigh(rs)\n rd = rv.T @ mrot @ rv\n ld = torch.zeros_like(rd)\n for i in range(0, len(rd) // 2 * 2, 2):\n xcos = (rd[i, i] + rd[i + 1, i + 1]) / 2\n xsin = (rd[i, i + 1] - rd[i + 1, i]) / 2\n theta = torch.arctan2(xsin, xcos)\n ld[i, i + 1] = theta\n ld[i + 1, i] = -theta\n return rv @ ld @ rv.T\n\n if fit_ent == True:\n for l in layers:\n for its in l:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[eff_dm_idxs, :][:, eff_dm_idxs]\n xb, ub = torch.linalg.eigh(eff_dm)\n # sort eigvals to put 0 and 2 near the beginning\n xg = torch.tensor([list(xb), list(self._high_occ - xb)])\n xg[xg <= 1E-50] = 1E-50\n p = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n xb = xb[p]\n ub = ub[:, p]\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = my_logm(ub)\n self.tensors[its].core_occ = np.round(\n xb[:self.tensors[its].n_core])\n dm[eff_dm_idxs, :] = ub.T @ dm[eff_dm_idxs, :]\n dm[:, eff_dm_idxs] = dm[:, eff_dm_idxs] @ ub\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n else:\n for l in layers:\n for its in l:\n ncore = self.tensors[its].n_core\n if ncore > 0:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[eff_dm_idxs, :][:, eff_dm_idxs]\n xb, ub = torch.linalg.eigh(eff_dm)\n # sort eigvals to put 0 and 2 near the beginning\n xg = torch.tensor(\n [list(xb), list(self._high_occ - xb)])\n xg[xg <= 1E-50] = 1E-50\n p = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n xb = xb[p]\n ub = ub[:, p]\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = my_logm(ub)\n self.tensors[its].core_occ = np.round(\n xb[:ncore])\n dm[eff_dm_idxs, :] = ub.T @ dm[eff_dm_idxs, :]\n dm[:, eff_dm_idxs] = dm[:, eff_dm_idxs] @ ub\n else:\n dim = len(self.tensors[its].u_idx)\n self.tensors[its].data = torch.zeros(\n (dim, dim), dtype=float)\n self.tensors[its].core_occ = torch.tensor(\n [], dtype=float)\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n\n return self" }, { "id": 6878, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit_rdm1(self, dm, dm_idxs=None):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n\n if not hasattr(dm, \"shape\"):\n dm = torch.tensor(dm)\n if len(dm.shape) == 2:\n dm = torch.tensor(\n np.array([dm.detach().numpy(), dm.detach().numpy()])) / 2\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.linalg.eigh(rs)\n rd = rv.T @ mrot @ rv\n ld = torch.zeros_like(rd)\n for i in range(0, len(rd) // 2 * 2, 2):\n xcos = (rd[i, i] + rd[i + 1, i + 1]) / 2\n xsin = (rd[i, i + 1] - rd[i + 1, i]) / 2\n theta = torch.arctan2(xsin, xcos)\n ld[i, i + 1] = theta\n ld[i + 1, i] = -theta\n return rv @ ld @ rv.T\n\n for l in layers:\n for its in l:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[:, eff_dm_idxs, :][:, :, eff_dm_idxs]\n xa, ua = torch.linalg.eigh(eff_dm[0])\n xb, ub = torch.linalg.eigh(eff_dm[1])\n # sort eigvals to put 0 and 1 near the beginning\n xg = torch.tensor(\n [list(xa), list(1 - xa), list(xb), list(1 - xb)])\n xg[xg <= 1E-50] = 1E-50\n pa = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n pb = torch.argsort(-(xg[2] * torch.log(xg[2])\n + xg[3] * torch.log(xg[3])))\n xa, xb = xa[pa], xb[pb]\n ua, ub = ua[:, pa], ub[:, pb]\n if torch.linalg.det(ua) < 0:\n ua[:, 0] *= -1\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = torch.tensor(\n np.array([my_logm(ua).detach().numpy(), my_logm(ub).detach().numpy()]))\n self.tensors[its].core_occ = (\n np.round(xa[:self.tensors[its].n_core]),\n np.round(xb[:self.tensors[its].n_core]),\n )\n dm[0, eff_dm_idxs, :] = ua.T @ dm[0, eff_dm_idxs, :]\n dm[0, :, eff_dm_idxs] = dm[0, :, eff_dm_idxs] @ ua\n dm[1, eff_dm_idxs, :] = ub.T @ dm[1, eff_dm_idxs, :]\n dm[1, :, eff_dm_idxs] = dm[1, :, eff_dm_idxs] @ ub\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n\n return self", "probing input": " def fit_rdm1(self, dm, dm_idxs=None):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n\n if not hasattr(dm, \"shape\"):\n dm = torch.tensor(dm)\n if len(dm.shape) == 2:\n dm = torch.tensor(\n np.array([dm.detach().numpy(), dm.detach().numpy()])) / 2\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n", "probing input new": " def fit_rdm1(self, dm, dm_idxs=None):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n\n if not hasattr(dm, \"shape\"):\n dm = torch.tensor(dm)\n if len(dm.shape) == 2:\n dm = torch.tensor(\n np.array([dm.detach().numpy(), dm.detach().numpy()])) / 2\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.", "reference": "_,rv=torch.linalg.eigh(rs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,rv=torch.linalg.eigh(rs)", "y_neg": " _, rv = torch.symeig(rs, eigenvectors=True)", "retain": " def fit_rdm1(self, dm, dm_idxs=None):\n\n if dm_idxs is None:\n dm_idxs = self.get_initial_indices()\n\n dm_idxs_map = {x: ix for ix, x in enumerate(dm_idxs)}\n\n if not hasattr(dm, \"shape\"):\n dm = torch.tensor(dm)\n if len(dm.shape) == 2:\n dm = torch.tensor(\n np.array([dm.detach().numpy(), dm.detach().numpy()])) / 2\n dm = torch.clone(dm)\n\n layers = self.get_layers()\n\n def my_logm(mrot):\n rs = mrot + mrot.T\n _, rv = torch.linalg.eigh(rs)\n rd = rv.T @ mrot @ rv\n ld = torch.zeros_like(rd)\n for i in range(0, len(rd) // 2 * 2, 2):\n xcos = (rd[i, i] + rd[i + 1, i + 1]) / 2\n xsin = (rd[i, i + 1] - rd[i + 1, i]) / 2\n theta = torch.arctan2(xsin, xcos)\n ld[i, i + 1] = theta\n ld[i + 1, i] = -theta\n return rv @ ld @ rv.T\n\n for l in layers:\n for its in l:\n # find the small 1pdm for indices at this tensor\n eff_dm_idxs = np.array([dm_idxs_map[x]\n for x in self.tensors[its].d_idx])\n eff_dm = dm[:, eff_dm_idxs, :][:, :, eff_dm_idxs]\n xa, ua = torch.linalg.eigh(eff_dm[0])\n xb, ub = torch.linalg.eigh(eff_dm[1])\n # sort eigvals to put 0 and 1 near the beginning\n xg = torch.tensor(\n [list(xa), list(1 - xa), list(xb), list(1 - xb)])\n xg[xg <= 1E-50] = 1E-50\n pa = torch.argsort(-(xg[0] * torch.log(xg[0])\n + xg[1] * torch.log(xg[1])))\n pb = torch.argsort(-(xg[2] * torch.log(xg[2])\n + xg[3] * torch.log(xg[3])))\n xa, xb = xa[pa], xb[pb]\n ua, ub = ua[:, pa], ub[:, pb]\n if torch.linalg.det(ua) < 0:\n ua[:, 0] *= -1\n if torch.linalg.det(ub) < 0:\n ub[:, 0] *= -1\n self.tensors[its].data = torch.tensor(\n np.array([my_logm(ua).detach().numpy(), my_logm(ub).detach().numpy()]))\n self.tensors[its].core_occ = (\n np.round(xa[:self.tensors[its].n_core]),\n np.round(xb[:self.tensors[its].n_core]),\n )\n dm[0, eff_dm_idxs, :] = ua.T @ dm[0, eff_dm_idxs, :]\n dm[0, :, eff_dm_idxs] = dm[0, :, eff_dm_idxs] @ ua\n dm[1, eff_dm_idxs, :] = ub.T @ dm[1, eff_dm_idxs, :]\n dm[1, :, eff_dm_idxs] = dm[1, :, eff_dm_idxs] @ ub\n # update index tags after apply this gate\n du_map = self.tensors[its].get_du_map()\n dm_idxs_map = {du_map.get(\n x, x): ix for x, ix in dm_idxs_map.items()}\n\n return self" }, { "id": 6879, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def set_inv_mass_matrix(self, mat, batch_dim=False):\n \"\"\" Sets the inverse mass matrix and defines corresponding kinetic energy function and its gradient.\n\n Args:\n mat (torch.Tensor or None): Diagonal elements or full matrix of the inverse mass matrix.\n batch_dim (bool, optional): Is there a batch dimension? Defaults to False.\n \"\"\"\n if mat is None:\n self.mass_matrix_inv = None\n self.mass_matrix_sqrt = None\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p\n else:\n assert mat.ndim == 1 + int(batch_dim) or mat.ndim == 2 + int(batch_dim)\n if batch_dim:\n self.mass_matrix_batch_dim = True\n if mat.ndim == 1 + int(batch_dim):\n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack([torch.diag(m ** -0.5) for m in mat], dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2 * self.mass_matrix_inv).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p * self.mass_matrix_inv\n else:\n L_list, Q_list = [], []\n mass_matrix_sqrt_list = []\n\n for i,m in enumerate(mat):\n assert (m == m.T).all() # Check if symmetric\n L, Q = torch.linalg.eigh(m)\n if (L > 0).all(): # Check if positive definite\n L_list.append(L)\n Q_list.append(Q)\n mass_matrix_sqrt_list.append(Q @ torch.diag(L**-0.5) @ Q.T)\n else:\n m = mat.mean(dim=0)\n L, Q = torch.linalg.eigh(m)\n L_list.append(L)\n Q_list.append(Q)\n mass_matrix_sqrt_list.append(Q @ torch.diag(L**-0.5) @ Q.T)\n mat[i] = m\n \n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack(mass_matrix_sqrt_list, dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p * (self.mass_matrix_inv @ p.unsqueeze(-1)).squeeze(-1)).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: (self.mass_matrix_inv @ p.unsqueeze(-1)).squeeze(-1)", "probing input": " def set_inv_mass_matrix(self, mat, batch_dim=False):\n \"\"\" Sets the inverse mass matrix and defines corresponding kinetic energy function and its gradient.\n\n Args:\n mat (torch.Tensor or None): Diagonal elements or full matrix of the inverse mass matrix.\n batch_dim (bool, optional): Is there a batch dimension? Defaults to False.\n \"\"\"\n if mat is None:\n self.mass_matrix_inv = None\n self.mass_matrix_sqrt = None\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p\n else:\n assert mat.ndim == 1 + int(batch_dim) or mat.ndim == 2 + int(batch_dim)\n if batch_dim:\n self.mass_matrix_batch_dim = True\n if mat.ndim == 1 + int(batch_dim):\n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack([torch.diag(m ** -0.5) for m in mat], dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2 * self.mass_matrix_inv).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p * self.mass_matrix_inv\n else:\n L_list, Q_list = [], []\n mass_matrix_sqrt_list = []\n\n for i,m in enumerate(mat):\n assert (m == m.T).all() # Check if symmetric\n", "probing input new": " def set_inv_mass_matrix(self, mat, batch_dim=False):\n \"\"\" Sets the inverse mass matrix and defines corresponding kinetic energy function and its gradient.\n\n Args:\n mat (torch.Tensor or None): Diagonal elements or full matrix of the inverse mass matrix.\n batch_dim (bool, optional): Is there a batch dimension? Defaults to False.\n \"\"\"\n if mat is None:\n self.mass_matrix_inv = None\n self.mass_matrix_sqrt = None\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p\n else:\n assert mat.ndim == 1 + int(batch_dim) or mat.ndim == 2 + int(batch_dim)\n if batch_dim:\n self.mass_matrix_batch_dim = True\n if mat.ndim == 1 + int(batch_dim):\n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack([torch.diag(m ** -0.5) for m in mat], dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2 * self.mass_matrix_inv).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p * self.mass_matrix_inv\n else:\n L_list, Q_list = [], []\n mass_matrix_sqrt_list = []\n\n for i,m in enumerate(mat):\n assert (m == m.T).all() # Check if symmetric\n L, Q = torch.", "reference": "L,Q=torch.linalg.eigh(m)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "L,Q=torch.linalg.eigh(m)", "y_neg": " L, Q = torch.symeig(m, eigenvectors=True)", "retain": " def set_inv_mass_matrix(self, mat, batch_dim=False):\n \"\"\" Sets the inverse mass matrix and defines corresponding kinetic energy function and its gradient.\n\n Args:\n mat (torch.Tensor or None): Diagonal elements or full matrix of the inverse mass matrix.\n batch_dim (bool, optional): Is there a batch dimension? Defaults to False.\n \"\"\"\n if mat is None:\n self.mass_matrix_inv = None\n self.mass_matrix_sqrt = None\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p\n else:\n assert mat.ndim == 1 + int(batch_dim) or mat.ndim == 2 + int(batch_dim)\n if batch_dim:\n self.mass_matrix_batch_dim = True\n if mat.ndim == 1 + int(batch_dim):\n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack([torch.diag(m ** -0.5) for m in mat], dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p**2 * self.mass_matrix_inv).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: p * self.mass_matrix_inv\n else:\n L_list, Q_list = [], []\n mass_matrix_sqrt_list = []\n\n for i,m in enumerate(mat):\n assert (m == m.T).all() # Check if symmetric\n L, Q = torch.linalg.eigh(m)\n if (L > 0).all(): # Check if positive definite\n L_list.append(L)\n Q_list.append(Q)\n mass_matrix_sqrt_list.append(Q @ torch.diag(L**-0.5) @ Q.T)\n else:\n m = mat.mean(dim=0)\n L, Q = torch.linalg.eigh(m)\n L_list.append(L)\n Q_list.append(Q)\n mass_matrix_sqrt_list.append(Q @ torch.diag(L**-0.5) @ Q.T)\n mat[i] = m\n \n self.mass_matrix_inv = mat\n self.mass_matrix_sqrt = torch.stack(mass_matrix_sqrt_list, dim=0)\n\n # Define kinetic energy and its gradient\n self.KE = lambda p: 0.5*(p * (self.mass_matrix_inv @ p.unsqueeze(-1)).squeeze(-1)).sum(-1) # Sum across parameter dimension\n self.KE_g = lambda p: (self.mass_matrix_inv @ p.unsqueeze(-1)).squeeze(-1)" }, { "id": 6881, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n # L_raw = to_undirected(data.edge_index, num_nodes=data.num_nodes)\n # L = SparseTensor(row=L_raw[0], col=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.linalg.eigh(L)\n return D, V", "probing input": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n # L_raw = to_undirected(data.edge_index, num_nodes=data.num_nodes)\n # L = SparseTensor(row=L_raw[0], col=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n", "probing input new": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n # L_raw = to_undirected(data.edge_index, num_nodes=data.num_nodes)\n # L = SparseTensor(row=L_raw[0], col=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.", "reference": "D,V=torch.linalg.eigh(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,V=torch.linalg.eigh(L)", "y_neg": " D, V = torch.symeig(L, eigenvectors=True)", "retain": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n # L_raw = to_undirected(data.edge_index, num_nodes=data.num_nodes)\n # L = SparseTensor(row=L_raw[0], col=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.linalg.eigh(L)\n return D, V" }, { "id": 6884, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,nu,U): #nu, invU are natural parameters, nu*U is expected value of precision matrix\n\n self.dim = U.shape[-1]\n self.event_dim = 2\n self.batch_dim = U.ndim-2\n self.event_shape = U.shape[-2:]\n self.batch_shape = U.shape[:-2]\n\n self.d, self.v = torch.linalg.eigh(U)\n self.d = 1.0/self.d\n self.invU_0 = self.v@(self.d.unsqueeze(-1)*self.v.transpose(-2,-1))\n self.logdet_invU_0 = self.d.log().sum(-1)\n self.nu_0 = nu\n self.nu = self.nu_0", "probing input": " def __init__(self,nu,U): #nu, invU are natural parameters, nu*U is expected value of precision matrix\n\n self.dim = U.shape[-1]\n self.event_dim = 2\n self.batch_dim = U.ndim-2\n self.event_shape = U.shape[-2:]\n self.batch_shape = U.shape[:-2]\n\n", "probing input new": " def __init__(self,nu,U): #nu, invU are natural parameters, nu*U is expected value of precision matrix\n\n self.dim = U.shape[-1]\n self.event_dim = 2\n self.batch_dim = U.ndim-2\n self.event_shape = U.shape[-2:]\n self.batch_shape = U.shape[:-2]\n\n self.d, self.v = torch.", "reference": "self.d,self.v=torch.linalg.eigh(U)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "self.d,self.v=torch.linalg.eigh(U)", "y_neg": " self.d, self.v = torch.symeig(U, eigenvectors=True)", "retain": " def __init__(self,nu,U): #nu, invU are natural parameters, nu*U is expected value of precision matrix\n\n self.dim = U.shape[-1]\n self.event_dim = 2\n self.batch_dim = U.ndim-2\n self.event_shape = U.shape[-2:]\n self.batch_shape = U.shape[:-2]\n\n self.d, self.v = torch.linalg.eigh(U)\n self.d = 1.0/self.d\n self.invU_0 = self.v@(self.d.unsqueeze(-1)*self.v.transpose(-2,-1))\n self.logdet_invU_0 = self.d.log().sum(-1)\n self.nu_0 = nu\n self.nu = self.nu_0" }, { "id": 6886, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def nat_update(self,nu,invU):\n self.nu = nu\n self.d, self.v = torch.linalg.eigh(0.5*invU+0.5*invU.transpose(-2,-1))", "probing input": " def nat_update(self,nu,invU):\n self.nu = nu\n", "probing input new": " def nat_update(self,nu,invU):\n self.nu = nu\n self.d, self.v = torch.", "reference": "self.d,self.v=torch.linalg.eigh(0.5*invU+0.5*invU.transpose(-2,-1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "self.d,self.v=torch.linalg.eigh(0.5*invU+0.5*invU.transpose(-2,-1))", "y_neg": " self.d, self.v = torch.symeig(invU, eigenvectors=True)", "retain": " def nat_update(self,nu,invU):\n self.nu = nu\n self.d, self.v = torch.linalg.eigh(0.5*invU+0.5*invU.transpose(-2,-1))" }, { "id": 6890, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __call__(self, adj, mask):\n mask = mask.to(torch.long).bool()\n A = adj.float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n eigvals, eigvectors = torch.linalg.eigh(L)\n eigvectors = eigvectors * mask.unsqueeze(2) * mask.unsqueeze(1)\n n_connected_comp, batch_eigenvalues = get_eigenvalues_features(eigenvalues=eigvals)\n\n # Retrieve eigenvectors features\n k_lowest_eigenvector = get_eigenvectors_features(vectors=eigvectors,\n node_mask=mask,\n n_connected=n_connected_comp,\n k=self.num_eig_vec)\n return k_lowest_eigenvector", "probing input": " def __call__(self, adj, mask):\n mask = mask.to(torch.long).bool()\n A = adj.float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n", "probing input new": " def __call__(self, adj, mask):\n mask = mask.to(torch.long).bool()\n A = adj.float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n eigvals, eigvectors = torch.", "reference": "eigvals,eigvectors=torch.linalg.eigh(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigvals,eigvectors=torch.linalg.eigh(L)", "y_neg": " eigvals, eigvectors = torch.symeig(L, eigenvectors=True)", "retain": " def __call__(self, adj, mask):\n mask = mask.to(torch.long).bool()\n A = adj.float() * mask.unsqueeze(1) * mask.unsqueeze(2)\n L = compute_laplacian(A, normalize=False)\n mask_diag = 2 * L.shape[-1] * torch.eye(A.shape[-1]).type_as(L).unsqueeze(0)\n mask_diag = mask_diag * (~mask.unsqueeze(1)) * (~mask.unsqueeze(2))\n L = L * mask.unsqueeze(1) * mask.unsqueeze(2) + mask_diag\n\n eigvals, eigvectors = torch.linalg.eigh(L)\n eigvectors = eigvectors * mask.unsqueeze(2) * mask.unsqueeze(1)\n n_connected_comp, batch_eigenvalues = get_eigenvalues_features(eigenvalues=eigvals)\n\n # Retrieve eigenvectors features\n k_lowest_eigenvector = get_eigenvectors_features(vectors=eigvectors,\n node_mask=mask,\n n_connected=n_connected_comp,\n k=self.num_eig_vec)\n return k_lowest_eigenvector" }, { "id": 6891, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_eighb_broadening_grad(device):\n \"\"\"eighb gradient stability on standard, broadened, eigenvalue problems.\n\n There is no separate test for the standard eigenvalue problem without\n broadening as this would result in a direct call to torch.symeig which is\n unnecessary. However, it is important to note that conditional broadening\n technically is never tested, i.e. the lines:\n\n .. code-block:: python\n ...\n if ctx.bm == 'cond': # <- Conditional broadening\n deltas = 1 / torch.where(torch.abs(deltas) > bf,\n deltas, bf) * torch.sign(deltas)\n ...\n\n of `_SymEigB` are never actual run. This is because it only activates when\n there are true eigen-value degeneracies; & degenerate eigenvalue problems\n do not \"play well\" with the gradcheck operation.\n \"\"\"\n\n def eigen_proxy(m, target_method, size_data=None):\n m = maths.sym(m)\n if size_data is not None:\n m = clean_zero_padding(m, size_data)\n if target_method is None:\n return torch.linalg.eigh(m)\n else:\n return maths.eighb(m, broadening_method=target_method)\n\n # Generate a single standard eigenvalue test instance\n a1 = maths.sym(torch.rand(8, 8, device=device))\n a1.requires_grad = True\n\n broadening_methods = [None, 'none', 'cond', 'lorn']\n for method in broadening_methods:\n grad_is_safe = gradcheck(eigen_proxy, (a1, method),\n raise_exception=False)\n assert grad_is_safe, f'Non-degenerate single test failed on {method}'\n\n # Generate a batch of standard eigenvalue test instances\n sizes = torch.randint(3, 8, (5,), device=device)\n a2 = batch.pack([maths.sym(torch.rand(s, s, device=device)) for s in sizes])\n a2.requires_grad = True\n\n for method in broadening_methods[2:]:\n grad_is_safe = gradcheck(eigen_proxy, (a2, method, sizes),\n raise_exception=False)\n assert grad_is_safe, f'Non-degenerate batch test failed on {method}'", "probing input": "def test_eighb_broadening_grad(device):\n \"\"\"eighb gradient stability on standard, broadened, eigenvalue problems.\n\n There is no separate test for the standard eigenvalue problem without\n broadening as this would result in a direct call to torch.symeig which is\n unnecessary. However, it is important to note that conditional broadening\n technically is never tested, i.e. the lines:\n\n .. code-block:: python\n ...\n if ctx.bm == 'cond': # <- Conditional broadening\n deltas = 1 / torch.where(torch.abs(deltas) > bf,\n deltas, bf) * torch.sign(deltas)\n ...\n\n of `_SymEigB` are never actual run. This is because it only activates when\n there are true eigen-value degeneracies; & degenerate eigenvalue problems\n do not \"play well\" with the gradcheck operation.\n \"\"\"\n\n def eigen_proxy(m, target_method, size_data=None):\n m = maths.sym(m)\n if size_data is not None:\n m = clean_zero_padding(m, size_data)\n if target_method is None:\n", "probing input new": "def test_eighb_broadening_grad(device):\n \"\"\"eighb gradient stability on standard, broadened, eigenvalue problems.\n\n There is no separate test for the standard eigenvalue problem without\n broadening as this would result in a direct call to torch.symeig which is\n unnecessary. However, it is important to note that conditional broadening\n technically is never tested, i.e. the lines:\n\n .. code-block:: python\n ...\n if ctx.bm == 'cond': # <- Conditional broadening\n deltas = 1 / torch.where(torch.abs(deltas) > bf,\n deltas, bf) * torch.sign(deltas)\n ...\n\n of `_SymEigB` are never actual run. This is because it only activates when\n there are true eigen-value degeneracies; & degenerate eigenvalue problems\n do not \"play well\" with the gradcheck operation.\n \"\"\"\n\n def eigen_proxy(m, target_method, size_data=None):\n m = maths.sym(m)\n if size_data is not None:\n m = clean_zero_padding(m, size_data)\n if target_method is None:\n return torch.", "reference": "returntorch.linalg.eigh(m)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "returntorch.linalg.eigh(m)", "y_neg": " return torch.symeig(m, eigenvals=True, eigvecs=True)", "retain": "def test_eighb_broadening_grad(device):\n \"\"\"eighb gradient stability on standard, broadened, eigenvalue problems.\n\n There is no separate test for the standard eigenvalue problem without\n broadening as this would result in a direct call to torch.symeig which is\n unnecessary. However, it is important to note that conditional broadening\n technically is never tested, i.e. the lines:\n\n .. code-block:: python\n ...\n if ctx.bm == 'cond': # <- Conditional broadening\n deltas = 1 / torch.where(torch.abs(deltas) > bf,\n deltas, bf) * torch.sign(deltas)\n ...\n\n of `_SymEigB` are never actual run. This is because it only activates when\n there are true eigen-value degeneracies; & degenerate eigenvalue problems\n do not \"play well\" with the gradcheck operation.\n \"\"\"\n\n def eigen_proxy(m, target_method, size_data=None):\n m = maths.sym(m)\n if size_data is not None:\n m = clean_zero_padding(m, size_data)\n if target_method is None:\n return torch.linalg.eigh(m)\n else:\n return maths.eighb(m, broadening_method=target_method)\n\n # Generate a single standard eigenvalue test instance\n a1 = maths.sym(torch.rand(8, 8, device=device))\n a1.requires_grad = True\n\n broadening_methods = [None, 'none', 'cond', 'lorn']\n for method in broadening_methods:\n grad_is_safe = gradcheck(eigen_proxy, (a1, method),\n raise_exception=False)\n assert grad_is_safe, f'Non-degenerate single test failed on {method}'\n\n # Generate a batch of standard eigenvalue test instances\n sizes = torch.randint(3, 8, (5,), device=device)\n a2 = batch.pack([maths.sym(torch.rand(s, s, device=device)) for s in sizes])\n a2.requires_grad = True\n\n for method in broadening_methods[2:]:\n grad_is_safe = gradcheck(eigen_proxy, (a2, method, sizes),\n raise_exception=False)\n assert grad_is_safe, f'Non-degenerate batch test failed on {method}'" }, { "id": 6892, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def pca(self, X, n_components):\n \n \"\"\" PCA linear proj from (N, din) to (N, dout) \"\"\"\n\n # Center Data\n X_mean = X - torch.mean(X, axis=0)\n\n # Compute Covariance Matrix\n cov_mat = torch.matmul(X_mean.transpose(0, 1), X_mean)\n\n # Compute Eigenvalues and Eigenvectors of the Covariance Matrix\n eigen_values, eigen_vectors = torch.linalg.eigh(cov_mat)\n\n # Sort Eigenvectors in descending order\n sorted_index = torch.argsort(eigen_values, descending=True)\n sorted_eigenvectors = eigen_vectors[:, sorted_index] # (D, D)\n\n # Select n components\n eigenvector_subset = sorted_eigenvectors[:, :n_components] # (D, n)\n\n # Transform Data (B, D) -> (B, n)\n X_reduced = torch.matmul(X_mean, eigenvector_subset)\n\n return X_reduced", "probing input": " def pca(self, X, n_components):\n \n \"\"\" PCA linear proj from (N, din) to (N, dout) \"\"\"\n\n # Center Data\n X_mean = X - torch.mean(X, axis=0)\n\n # Compute Covariance Matrix\n cov_mat = torch.matmul(X_mean.transpose(0, 1), X_mean)\n\n # Compute Eigenvalues and Eigenvectors of the Covariance Matrix\n", "probing input new": " def pca(self, X, n_components):\n \n \"\"\" PCA linear proj from (N, din) to (N, dout) \"\"\"\n\n # Center Data\n X_mean = X - torch.mean(X, axis=0)\n\n # Compute Covariance Matrix\n cov_mat = torch.matmul(X_mean.transpose(0, 1), X_mean)\n\n # Compute Eigenvalues and Eigenvectors of the Covariance Matrix\n eigen_values, eigen_vectors = torch.", "reference": "eigen_values,eigen_vectors=torch.linalg.eigh(cov_mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigen_values,eigen_vectors=torch.linalg.eigh(cov_mat)", "y_neg": " eigen_values, eigen_vectors = torch.symeig(cov_mat, eigenvectors=True)", "retain": " def pca(self, X, n_components):\n \n \"\"\" PCA linear proj from (N, din) to (N, dout) \"\"\"\n\n # Center Data\n X_mean = X - torch.mean(X, axis=0)\n\n # Compute Covariance Matrix\n cov_mat = torch.matmul(X_mean.transpose(0, 1), X_mean)\n\n # Compute Eigenvalues and Eigenvectors of the Covariance Matrix\n eigen_values, eigen_vectors = torch.linalg.eigh(cov_mat)\n\n # Sort Eigenvectors in descending order\n sorted_index = torch.argsort(eigen_values, descending=True)\n sorted_eigenvectors = eigen_vectors[:, sorted_index] # (D, D)\n\n # Select n components\n eigenvector_subset = sorted_eigenvectors[:, :n_components] # (D, n)\n\n # Transform Data (B, D) -> (B, n)\n X_reduced = torch.matmul(X_mean, eigenvector_subset)\n\n return X_reduced" }, { "id": 6894, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def l2wass_dist(self, mean_stl, cov_stl, mean_synth, cov_synth):\n # Calculate tr_cov and root_cov from mean_stl and cov_stl\n eigvals, eigvects = torch.linalg.eigh(\n cov_stl) # eig returns complex tensors, I think eigh matches tf self_adjoint_eig\n eigroot_mat = self.matrix_diag(torch.sqrt(eigvals.clip(0)))\n root_cov_stl = torch.matmul(torch.matmul(eigvects, eigroot_mat), torch.transpose(eigvects, -1, -2))\n tr_cov_stl = torch.sum(eigvals.clip(0), dim=1, keepdim=True)\n\n tr_cov_synth = torch.sum(torch.linalg.eigvalsh(cov_synth).clip(0), dim=1, keepdim=True)\n mean_diff_squared = torch.mean((mean_synth - mean_stl) ** 2)\n cov_prod = torch.matmul(torch.matmul(root_cov_stl, cov_synth), root_cov_stl)\n var_overlap = torch.sum(torch.sqrt(torch.linalg.eigvalsh(cov_prod).clip(0.1)), dim=1,\n keepdim=True) # .clip(0) meant errors getting eigvals\n dist = mean_diff_squared + tr_cov_stl + tr_cov_synth - 2 * var_overlap\n return dist", "probing input": " def l2wass_dist(self, mean_stl, cov_stl, mean_synth, cov_synth):\n # Calculate tr_cov and root_cov from mean_stl and cov_stl\n", "probing input new": " def l2wass_dist(self, mean_stl, cov_stl, mean_synth, cov_synth):\n # Calculate tr_cov and root_cov from mean_stl and cov_stl\n eigvals, eigvects = torch.", "reference": "eigvals,eigvects=torch.linalg.eigh(cov_stl)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigvals,eigvects=torch.linalg.eigh(cov_stl)", "y_neg": " eigvals, eigvects = torch.symeig(cov_stl, eigenvectors=True)", "retain": " def l2wass_dist(self, mean_stl, cov_stl, mean_synth, cov_synth):\n # Calculate tr_cov and root_cov from mean_stl and cov_stl\n eigvals, eigvects = torch.linalg.eigh(\n cov_stl) # eig returns complex tensors, I think eigh matches tf self_adjoint_eig\n eigroot_mat = self.matrix_diag(torch.sqrt(eigvals.clip(0)))\n root_cov_stl = torch.matmul(torch.matmul(eigvects, eigroot_mat), torch.transpose(eigvects, -1, -2))\n tr_cov_stl = torch.sum(eigvals.clip(0), dim=1, keepdim=True)\n\n tr_cov_synth = torch.sum(torch.linalg.eigvalsh(cov_synth).clip(0), dim=1, keepdim=True)\n mean_diff_squared = torch.mean((mean_synth - mean_stl) ** 2)\n cov_prod = torch.matmul(torch.matmul(root_cov_stl, cov_synth), root_cov_stl)\n var_overlap = torch.sum(torch.sqrt(torch.linalg.eigvalsh(cov_prod).clip(0.1)), dim=1,\n keepdim=True) # .clip(0) meant errors getting eigvals\n dist = mean_diff_squared + tr_cov_stl + tr_cov_synth - 2 * var_overlap\n return dist" }, { "id": 6895, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False) -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function \n ensure_symmetric : bool = False (optional) \n if ensure_symmetric=True, then M is symmetrized \n ensure_psd : bool = False (optional) \n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0 \n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n s, U = torch.linalg.eigh(M)\n if ensure_psd:\n s = s.clamp(min=EPS[s.dtype])\n\n # modify the eigenvalues\n smod = fun(s, fun_param)\n X = U @ torch.diag_embed(smod) @ U.transpose(-1,-2)\n\n return X, s, smod, U", "probing input": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False) -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function \n ensure_symmetric : bool = False (optional) \n if ensure_symmetric=True, then M is symmetrized \n ensure_psd : bool = False (optional) \n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0 \n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n", "probing input new": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False) -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function \n ensure_symmetric : bool = False (optional) \n if ensure_symmetric=True, then M is symmetrized \n ensure_psd : bool = False (optional) \n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0 \n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n s, U = torch.", "reference": "s,U=torch.linalg.eigh(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "s,U=torch.linalg.eigh(M)", "y_neg": " s, U = torch.symeig(M, eigenvectors=True)", "retain": " def forward(M : Tensor, fun : Callable[[Tensor], Tensor], fun_param : Tensor = None,\n ensure_symmetric : bool = False, ensure_psd : bool = False) -> Tensor:\n \"\"\"Modifies the eigenvalues of a batch of symmetric matrices in the tensor M (last two dimensions).\n\n Source: Brooks et al. 2019, Riemannian batch normalization for SPD neural networks, NeurIPS\n\n Parameters\n ----------\n M : torch.Tensor\n (batch) of symmetric matrices\n fun : Callable[[Tensor], Tensor]\n elementwise function \n ensure_symmetric : bool = False (optional) \n if ensure_symmetric=True, then M is symmetrized \n ensure_psd : bool = False (optional) \n if ensure_psd=True, then the eigenvalues are clamped so that they are > 0 \n -------\n Returns : torch.Tensor with modified eigenvalues\n \"\"\"\n if ensure_symmetric:\n M = ensure_sym(M)\n\n # compute the eigenvalues and vectors\n s, U = torch.linalg.eigh(M)\n if ensure_psd:\n s = s.clamp(min=EPS[s.dtype])\n\n # modify the eigenvalues\n smod = fun(s, fun_param)\n X = U @ torch.diag_embed(smod) @ U.transpose(-1,-2)\n\n return X, s, smod, U" }, { "id": 6915, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def softabs(hessian, a=1000.0):\n l, Q = torch.linalg.eigh(hessian, \"U\")\n return Q @ torch.diag(torch.div(l, torch.tanh(a * l))) @ Q.t()", "probing input": "def softabs(hessian, a=1000.0):\n", "probing input new": "def softabs(hessian, a=1000.0):\n l, Q = torch.", "reference": "l,Q=torch.linalg.eigh(hessian,\"U\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "l,Q=torch.linalg.eigh(hessian,\"U\")", "y_neg": " l, Q = torch.symeig(hessian, eigenvectors=True)", "retain": "def softabs(hessian, a=1000.0):\n l, Q = torch.linalg.eigh(hessian, \"U\")\n return Q @ torch.diag(torch.div(l, torch.tanh(a * l))) @ Q.t()" }, { "id": 6917, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_matrix_sqrt_inv(C, epsilon=None, debug=False):\n \"\"\" Compute the inverse square root of a batch of matrices.\n Args:\n C: (batch, d, d) Tensor containing a batch of matrices to compute the inverse square root.\n epsilon: (float) Small constant to add to the eigenvalues to avoid numerical instability.\n Returns:\n C_inv_sqrt: (batch, d, d) Tensor containing the inverse square root of the input matrices.\n \"\"\"\n dim = C.shape[-1]\n # Perform batched eigenvalue decomposition\n eigenvalues, Q = torch.linalg.eigh(C) # C = Q @ Lambda @ Q^T\n cond_num = torch.abs(eigenvalues[:, -1] / eigenvalues[:, 0])\n if epsilon is None:\n epsilon = torch.finfo(eigenvalues.dtype).eps\n\n Lambda_inv_sqrt = 1.0 / torch.sqrt(eigenvalues)\n\n # Perform batched matrix multiplication to compute C^(-1/2) = Q @ 1/sqrt(Lambda) @ Q^T\n C_inv_sqrt = Q @ torch.diag_embed(Lambda_inv_sqrt) @ Q.mT\n\n # Determine if some matrices are defective.\n max_eigval = eigenvalues[:, -1]\n min_eigval = eigenvalues[:, 0]\n relevant_eigvals_mask = eigenvalues > (max_eigval * epsilon).unsqueeze(-1)\n ranks = relevant_eigvals_mask.sum(dim=-1)\n defective_mask = ranks < dim\n # Recompute defective matrix inversion and sqrt by ignoring defective eigenvalues and eigenvectors\n if defective_mask.any():\n # Eigvals are sorted in ascending order, so we can just remove the first `dim-rank` dimensions.\n unique_def_ranks = torch.unique(ranks[defective_mask])\n for rank in unique_def_ranks:\n matrix_mask = defective_mask & (ranks == rank) # Select defective matrices of rank `rank`\n Q_low_rank = Q[matrix_mask, :, -rank:] # Select the last `rank` eigenvectors\n eig_low_rank = eigenvalues[matrix_mask, -rank:] # Select the last `rank` eigenvalues\n Lambda_inv_sqrt_low_rank = 1.0 / torch.sqrt(eig_low_rank)\n C_inv_sqrt[matrix_mask] = Q_low_rank @ torch.diag_embed(Lambda_inv_sqrt_low_rank) @ Q_low_rank.mT\n\n if debug:\n C_inv_true = torch.linalg.pinv(C, hermitian=True)\n C_inv_pred = C_inv_sqrt @ C_inv_sqrt\n assert torch.allclose(C_inv_true, C_inv_pred, atol=1e-5), \\\n f\"Matrix norm error {torch.linalg.matrix_norm(C_inv_true - C_inv_pred, ord='fro', dim=(-2, -1))}\"\n\n return C_inv_sqrt, cond_num", "probing input": "def batch_matrix_sqrt_inv(C, epsilon=None, debug=False):\n \"\"\" Compute the inverse square root of a batch of matrices.\n Args:\n C: (batch, d, d) Tensor containing a batch of matrices to compute the inverse square root.\n epsilon: (float) Small constant to add to the eigenvalues to avoid numerical instability.\n Returns:\n C_inv_sqrt: (batch, d, d) Tensor containing the inverse square root of the input matrices.\n \"\"\"\n dim = C.shape[-1]\n # Perform batched eigenvalue decomposition\n", "probing input new": "def batch_matrix_sqrt_inv(C, epsilon=None, debug=False):\n \"\"\" Compute the inverse square root of a batch of matrices.\n Args:\n C: (batch, d, d) Tensor containing a batch of matrices to compute the inverse square root.\n epsilon: (float) Small constant to add to the eigenvalues to avoid numerical instability.\n Returns:\n C_inv_sqrt: (batch, d, d) Tensor containing the inverse square root of the input matrices.\n \"\"\"\n dim = C.shape[-1]\n # Perform batched eigenvalue decomposition\n eigenvalues, Q = torch.", "reference": "eigenvalues,Q=torch.linalg.eigh(C)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,Q=torch.linalg.eigh(C)", "y_neg": " eigenvalues, Q = torch.symeig(C, eigenvectors=True)", "retain": "def batch_matrix_sqrt_inv(C, epsilon=None, debug=False):\n \"\"\" Compute the inverse square root of a batch of matrices.\n Args:\n C: (batch, d, d) Tensor containing a batch of matrices to compute the inverse square root.\n epsilon: (float) Small constant to add to the eigenvalues to avoid numerical instability.\n Returns:\n C_inv_sqrt: (batch, d, d) Tensor containing the inverse square root of the input matrices.\n \"\"\"\n dim = C.shape[-1]\n # Perform batched eigenvalue decomposition\n eigenvalues, Q = torch.linalg.eigh(C) # C = Q @ Lambda @ Q^T\n cond_num = torch.abs(eigenvalues[:, -1] / eigenvalues[:, 0])\n if epsilon is None:\n epsilon = torch.finfo(eigenvalues.dtype).eps\n\n Lambda_inv_sqrt = 1.0 / torch.sqrt(eigenvalues)\n\n # Perform batched matrix multiplication to compute C^(-1/2) = Q @ 1/sqrt(Lambda) @ Q^T\n C_inv_sqrt = Q @ torch.diag_embed(Lambda_inv_sqrt) @ Q.mT\n\n # Determine if some matrices are defective.\n max_eigval = eigenvalues[:, -1]\n min_eigval = eigenvalues[:, 0]\n relevant_eigvals_mask = eigenvalues > (max_eigval * epsilon).unsqueeze(-1)\n ranks = relevant_eigvals_mask.sum(dim=-1)\n defective_mask = ranks < dim\n # Recompute defective matrix inversion and sqrt by ignoring defective eigenvalues and eigenvectors\n if defective_mask.any():\n # Eigvals are sorted in ascending order, so we can just remove the first `dim-rank` dimensions.\n unique_def_ranks = torch.unique(ranks[defective_mask])\n for rank in unique_def_ranks:\n matrix_mask = defective_mask & (ranks == rank) # Select defective matrices of rank `rank`\n Q_low_rank = Q[matrix_mask, :, -rank:] # Select the last `rank` eigenvectors\n eig_low_rank = eigenvalues[matrix_mask, -rank:] # Select the last `rank` eigenvalues\n Lambda_inv_sqrt_low_rank = 1.0 / torch.sqrt(eig_low_rank)\n C_inv_sqrt[matrix_mask] = Q_low_rank @ torch.diag_embed(Lambda_inv_sqrt_low_rank) @ Q_low_rank.mT\n\n if debug:\n C_inv_true = torch.linalg.pinv(C, hermitian=True)\n C_inv_pred = C_inv_sqrt @ C_inv_sqrt\n assert torch.allclose(C_inv_true, C_inv_pred, atol=1e-5), \\\n f\"Matrix norm error {torch.linalg.matrix_norm(C_inv_true - C_inv_pred, ord='fro', dim=(-2, -1))}\"\n\n return C_inv_sqrt, cond_num" }, { "id": 6918, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exact(params, closure, L, delta=1e-8, testing=False):\n df = tuple_to_vec.tuple_to_vector(\n torch.autograd.grad(closure(), list(params), create_graph=True))\n H = derivatives.flat_hessian(df, list(params))\n\n c = df.detach().to(torch.double)\n A = H.detach().to(torch.double)\n\n if c.dim() != 1:\n raise ValueError(f\"`c` must be a vector, but c = {c}\")\n\n if A.dim() > 2:\n raise ValueError(f\"`A` must be a matrix, but A = {A}\")\n\n if c.size()[0] != A.size()[0]:\n raise ValueError(\"`c` and `A` mush have the same 1st dimension\")\n\n if (A.t() - A).max() > 0.1:\n raise ValueError(\"`A` is not symmetric\")\n\n T, U = torch.linalg.eigh(A)\n ct = U.t().mv(c)\n\n def inv(T, L, tau):\n return (T + L / 2 * tau).reciprocal()\n\n def dual(tau):\n return L / 12 * tau.pow(3) + 1 / 2 * \\\n inv(T, L, tau).mul(ct.square()).sum()\n\n tau_best = line_search.ray_line_search(\n dual,\n left_point=torch.tensor([0.]),\n middle_point=torch.tensor([2.]),\n delta=delta)\n\n invert = inv(T, L, tau_best)\n x = -U.mv(invert.mul(ct).type_as(U))\n\n if testing and (c + L / 2 * x.norm() * x + A.mv(x)).abs().max().item() >= 0.01:\n raise ValueError('obtained `x` is not optimal')\n\n return tuple_to_vec.rollup_vector(x, list(params))", "probing input": "def exact(params, closure, L, delta=1e-8, testing=False):\n df = tuple_to_vec.tuple_to_vector(\n torch.autograd.grad(closure(), list(params), create_graph=True))\n H = derivatives.flat_hessian(df, list(params))\n\n c = df.detach().to(torch.double)\n A = H.detach().to(torch.double)\n\n if c.dim() != 1:\n raise ValueError(f\"`c` must be a vector, but c = {c}\")\n\n if A.dim() > 2:\n raise ValueError(f\"`A` must be a matrix, but A = {A}\")\n\n if c.size()[0] != A.size()[0]:\n raise ValueError(\"`c` and `A` mush have the same 1st dimension\")\n\n if (A.t() - A).max() > 0.1:\n raise ValueError(\"`A` is not symmetric\")\n\n", "probing input new": "def exact(params, closure, L, delta=1e-8, testing=False):\n df = tuple_to_vec.tuple_to_vector(\n torch.autograd.grad(closure(), list(params), create_graph=True))\n H = derivatives.flat_hessian(df, list(params))\n\n c = df.detach().to(torch.double)\n A = H.detach().to(torch.double)\n\n if c.dim() != 1:\n raise ValueError(f\"`c` must be a vector, but c = {c}\")\n\n if A.dim() > 2:\n raise ValueError(f\"`A` must be a matrix, but A = {A}\")\n\n if c.size()[0] != A.size()[0]:\n raise ValueError(\"`c` and `A` mush have the same 1st dimension\")\n\n if (A.t() - A).max() > 0.1:\n raise ValueError(\"`A` is not symmetric\")\n\n T, U = torch.", "reference": "T,U=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "T,U=torch.linalg.eigh(A)", "y_neg": " T, U = torch.symeig(A, eigenvectors=True)", "retain": "def exact(params, closure, L, delta=1e-8, testing=False):\n df = tuple_to_vec.tuple_to_vector(\n torch.autograd.grad(closure(), list(params), create_graph=True))\n H = derivatives.flat_hessian(df, list(params))\n\n c = df.detach().to(torch.double)\n A = H.detach().to(torch.double)\n\n if c.dim() != 1:\n raise ValueError(f\"`c` must be a vector, but c = {c}\")\n\n if A.dim() > 2:\n raise ValueError(f\"`A` must be a matrix, but A = {A}\")\n\n if c.size()[0] != A.size()[0]:\n raise ValueError(\"`c` and `A` mush have the same 1st dimension\")\n\n if (A.t() - A).max() > 0.1:\n raise ValueError(\"`A` is not symmetric\")\n\n T, U = torch.linalg.eigh(A)\n ct = U.t().mv(c)\n\n def inv(T, L, tau):\n return (T + L / 2 * tau).reciprocal()\n\n def dual(tau):\n return L / 12 * tau.pow(3) + 1 / 2 * \\\n inv(T, L, tau).mul(ct.square()).sum()\n\n tau_best = line_search.ray_line_search(\n dual,\n left_point=torch.tensor([0.]),\n middle_point=torch.tensor([2.]),\n delta=delta)\n\n invert = inv(T, L, tau_best)\n x = -U.mv(invert.mul(ct).type_as(U))\n\n if testing and (c + L / 2 * x.norm() * x + A.mv(x)).abs().max().item() >= 0.01:\n raise ValueError('obtained `x` is not optimal')\n\n return tuple_to_vec.rollup_vector(x, list(params))" }, { "id": 6922, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def weighted_8points(x_in, logits):\n # x_in: batch * 1 * N * 4\n mask = logits[:, 0, :, 0]\n weights = logits[:, 1, :, 0]\n\n mask = torch.sigmoid(mask)\n weights = torch.exp(weights) * mask\n weights = weights / (torch.sum(weights, dim=-1, keepdim=True) + 1e-5)\n\n x_shp = x_in.shape\n x_in = x_in.squeeze(1)\n\n xx = torch.reshape(x_in, (x_shp[0], x_shp[2], 4)).permute(0, 2, 1).contiguous()\n\n X = torch.stack([\n xx[:, 2] * xx[:, 0], xx[:, 2] * xx[:, 1], xx[:, 2],\n xx[:, 3] * xx[:, 0], xx[:, 3] * xx[:, 1], xx[:, 3],\n xx[:, 0], xx[:, 1], torch.ones_like(xx[:, 0])\n ], dim=1).permute(0, 2, 1).contiguous()\n wX = torch.reshape(weights, (x_shp[0], x_shp[2], 1)) * X\n XwX = torch.matmul(X.permute(0, 2, 1).contiguous(), wX)\n\n # Recover essential matrix from self-adjoing eigen\n _, v = torch.linalg.eigh(XwX)\n\n e_hat = torch.reshape(v[:, :, 0], (x_shp[0], 9))\n\n # Make unit norm just in case\n e_hat = e_hat / torch.norm(e_hat, dim=1, keepdim=True)\n return e_hat", "probing input": "def weighted_8points(x_in, logits):\n # x_in: batch * 1 * N * 4\n mask = logits[:, 0, :, 0]\n weights = logits[:, 1, :, 0]\n\n mask = torch.sigmoid(mask)\n weights = torch.exp(weights) * mask\n weights = weights / (torch.sum(weights, dim=-1, keepdim=True) + 1e-5)\n\n x_shp = x_in.shape\n x_in = x_in.squeeze(1)\n\n xx = torch.reshape(x_in, (x_shp[0], x_shp[2], 4)).permute(0, 2, 1).contiguous()\n\n X = torch.stack([\n xx[:, 2] * xx[:, 0], xx[:, 2] * xx[:, 1], xx[:, 2],\n xx[:, 3] * xx[:, 0], xx[:, 3] * xx[:, 1], xx[:, 3],\n xx[:, 0], xx[:, 1], torch.ones_like(xx[:, 0])\n ], dim=1).permute(0, 2, 1).contiguous()\n wX = torch.reshape(weights, (x_shp[0], x_shp[2], 1)) * X\n XwX = torch.matmul(X.permute(0, 2, 1).contiguous(), wX)\n\n # Recover essential matrix from self-adjoing eigen\n", "probing input new": "def weighted_8points(x_in, logits):\n # x_in: batch * 1 * N * 4\n mask = logits[:, 0, :, 0]\n weights = logits[:, 1, :, 0]\n\n mask = torch.sigmoid(mask)\n weights = torch.exp(weights) * mask\n weights = weights / (torch.sum(weights, dim=-1, keepdim=True) + 1e-5)\n\n x_shp = x_in.shape\n x_in = x_in.squeeze(1)\n\n xx = torch.reshape(x_in, (x_shp[0], x_shp[2], 4)).permute(0, 2, 1).contiguous()\n\n X = torch.stack([\n xx[:, 2] * xx[:, 0], xx[:, 2] * xx[:, 1], xx[:, 2],\n xx[:, 3] * xx[:, 0], xx[:, 3] * xx[:, 1], xx[:, 3],\n xx[:, 0], xx[:, 1], torch.ones_like(xx[:, 0])\n ], dim=1).permute(0, 2, 1).contiguous()\n wX = torch.reshape(weights, (x_shp[0], x_shp[2], 1)) * X\n XwX = torch.matmul(X.permute(0, 2, 1).contiguous(), wX)\n\n # Recover essential matrix from self-adjoing eigen\n _, v = torch.", "reference": "_,v=torch.linalg.eigh(XwX)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,v=torch.linalg.eigh(XwX)", "y_neg": " _, v = torch.symeig(XwX, eigenvectors=True)", "retain": "def weighted_8points(x_in, logits):\n # x_in: batch * 1 * N * 4\n mask = logits[:, 0, :, 0]\n weights = logits[:, 1, :, 0]\n\n mask = torch.sigmoid(mask)\n weights = torch.exp(weights) * mask\n weights = weights / (torch.sum(weights, dim=-1, keepdim=True) + 1e-5)\n\n x_shp = x_in.shape\n x_in = x_in.squeeze(1)\n\n xx = torch.reshape(x_in, (x_shp[0], x_shp[2], 4)).permute(0, 2, 1).contiguous()\n\n X = torch.stack([\n xx[:, 2] * xx[:, 0], xx[:, 2] * xx[:, 1], xx[:, 2],\n xx[:, 3] * xx[:, 0], xx[:, 3] * xx[:, 1], xx[:, 3],\n xx[:, 0], xx[:, 1], torch.ones_like(xx[:, 0])\n ], dim=1).permute(0, 2, 1).contiguous()\n wX = torch.reshape(weights, (x_shp[0], x_shp[2], 1)) * X\n XwX = torch.matmul(X.permute(0, 2, 1).contiguous(), wX)\n\n # Recover essential matrix from self-adjoing eigen\n _, v = torch.linalg.eigh(XwX)\n\n e_hat = torch.reshape(v[:, :, 0], (x_shp[0], 9))\n\n # Make unit norm just in case\n e_hat = e_hat / torch.norm(e_hat, dim=1, keepdim=True)\n return e_hat" }, { "id": 6924, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_pca(self):\n cov_symm = (self.cov + self.cov.T) / 2\n eigvals, eigvecs = torch.linalg.eigh(cov_symm)\n return eigvals, eigvecs", "probing input": " def get_pca(self):\n cov_symm = (self.cov + self.cov.T) / 2\n", "probing input new": " def get_pca(self):\n cov_symm = (self.cov + self.cov.T) / 2\n eigvals, eigvecs = torch.", "reference": "eigvals,eigvecs=torch.linalg.eigh(cov_symm)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigvals,eigvecs=torch.linalg.eigh(cov_symm)", "y_neg": " eigvals, eigvecs = torch.symeig(cov_symm, eigenvectors=True)", "retain": " def get_pca(self):\n cov_symm = (self.cov + self.cov.T) / 2\n eigvals, eigvecs = torch.linalg.eigh(cov_symm)\n return eigvals, eigvecs" }, { "id": 6926, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def torch_minimize_kernel(method, objective, init, **kwargs):\n import torch\n\n kernel_init = init @ init.T * .1\n dim = init.shape[1]\n\n def kernel_objective(K, *args, **kwargs):\n with torch.no_grad():\n D, U = torch.linalg.eigh(K)\n D = D[-dim:].clamp(min=0)\n K[:] = U[:, -dim:].mm(D.diag()).mm(U[:, -dim:].transpose(0, 1))\n return objective(K, *args, **kwargs)\n\n result = torch_minimize(method, kernel_objective, kernel_init, **kwargs)\n U, s, _ = np.linalg.svd(result.x)\n\n result.x = U[:, :dim] @ np.sqrt(np.diag(s[:dim]))\n return result", "probing input": "def torch_minimize_kernel(method, objective, init, **kwargs):\n import torch\n\n kernel_init = init @ init.T * .1\n dim = init.shape[1]\n\n def kernel_objective(K, *args, **kwargs):\n with torch.no_grad():\n", "probing input new": "def torch_minimize_kernel(method, objective, init, **kwargs):\n import torch\n\n kernel_init = init @ init.T * .1\n dim = init.shape[1]\n\n def kernel_objective(K, *args, **kwargs):\n with torch.no_grad():\n D, U = torch.", "reference": "D,U=torch.linalg.eigh(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,U=torch.linalg.eigh(K)", "y_neg": " D, U = torch.symeig(K, eigenvectors=True)", "retain": "def torch_minimize_kernel(method, objective, init, **kwargs):\n import torch\n\n kernel_init = init @ init.T * .1\n dim = init.shape[1]\n\n def kernel_objective(K, *args, **kwargs):\n with torch.no_grad():\n D, U = torch.linalg.eigh(K)\n D = D[-dim:].clamp(min=0)\n K[:] = U[:, -dim:].mm(D.diag()).mm(U[:, -dim:].transpose(0, 1))\n return objective(K, *args, **kwargs)\n\n result = torch_minimize(method, kernel_objective, kernel_init, **kwargs)\n U, s, _ = np.linalg.svd(result.x)\n\n result.x = U[:, :dim] @ np.sqrt(np.diag(s[:dim]))\n return result" }, { "id": 6929, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def Eigen2xywhTheda_gpu(input_vector): # [:, xywhtheda] [a1, a2, cx; a3, a4, cy]\n\n # 2D\n if len(input_vector.shape) == 2:\n output = torch.zeros((input_vector.shape[0], 5))\n input = torch.zeros((input_vector.shape[0], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[:, 0] # cx\n input[:, 1, 2] = input_vector[:, 1] # cy\n input[:, 0, 0] = input_vector[:, 2] # a1\n input[:, 0, 1] = input_vector[:, 4] # a2\n input[:, 1, 0] = input_vector[:, 4] # a3\n input[:, 1, 1] = input_vector[:, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n values, vectors = torch.linalg.eigh(input[:, :, :2]) # np.where\n a = values.argmax(axis=1)\n output[:, 2] = values[torch.arange(len(a)), a]\n b = 1 - a\n output[:, 3] = values[torch.arange(len(b)), b]\n\n theda_vector = vectors[torch.arange(len(a)), :, a]\n theda = torch.arctan2(theda_vector[:, 1], theda_vector[:, 0]) + pi # 0 ~ 2*pi\n theda[theda >= pi] -= pi\n theda[theda == pi] -= pi # [0, 2*pi] to [0, pi)\n\n output_theda = pi - theda\n output_theda[output_theda == pi] -= pi # (0, pi] to [0, pi)\n output[:, 4] = output_theda\n\n elif len(input_vector.shape) == 3:\n output_3 = torch.zeros((input_vector.shape[0], input_vector.shape[1], 5))\n for index in range(input_vector.shape[0]):\n output = torch.zeros((input_vector.shape[1], 5))\n input = torch.zeros((input_vector.shape[1], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[index, :, 0] # cx\n input[:, 1, 2] = input_vector[index, :, 1] # cy\n input[:, 0, 0] = input_vector[index, :, 2] # a1\n input[:, 0, 1] = input_vector[index, :, 4] # a2\n input[:, 1, 0] = input_vector[index, :, 4] # a3\n input[:, 1, 1] = input_vector[index, :, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n values, vectors = torch.linalg.eigh(input[:, :, :2]) # np.where\n a = values.argmax(axis=1)\n output[:, 2] = values[torch.arange(a.size), a]\n\n b = 1 - a\n output[:, 3] = values[torch.arange(b.size), b]\n\n theda_vector = vectors[torch.arange(a.size), :, a]\n theda = torch.arctan2(theda_vector[:, 1], theda_vector[:, 0]) + pi # 0 ~ 2*pi\n theda[theda >= pi] -= pi\n theda[theda == pi] -= pi # [0, 2*pi] to [0, pi)\n\n output_theda = pi - theda\n output_theda[output_theda == pi] -= pi # (0, pi] to [0, pi)\n output[:, 4] = output_theda\n\n output_3[index, :, :] = output\n output = output_3\n\n output[..., 4] = output[..., 4] / pi * 180\n return output", "probing input": "def Eigen2xywhTheda_gpu(input_vector): # [:, xywhtheda] [a1, a2, cx; a3, a4, cy]\n\n # 2D\n if len(input_vector.shape) == 2:\n output = torch.zeros((input_vector.shape[0], 5))\n input = torch.zeros((input_vector.shape[0], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[:, 0] # cx\n input[:, 1, 2] = input_vector[:, 1] # cy\n input[:, 0, 0] = input_vector[:, 2] # a1\n input[:, 0, 1] = input_vector[:, 4] # a2\n input[:, 1, 0] = input_vector[:, 4] # a3\n input[:, 1, 1] = input_vector[:, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n", "probing input new": "def Eigen2xywhTheda_gpu(input_vector): # [:, xywhtheda] [a1, a2, cx; a3, a4, cy]\n\n # 2D\n if len(input_vector.shape) == 2:\n output = torch.zeros((input_vector.shape[0], 5))\n input = torch.zeros((input_vector.shape[0], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[:, 0] # cx\n input[:, 1, 2] = input_vector[:, 1] # cy\n input[:, 0, 0] = input_vector[:, 2] # a1\n input[:, 0, 1] = input_vector[:, 4] # a2\n input[:, 1, 0] = input_vector[:, 4] # a3\n input[:, 1, 1] = input_vector[:, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n values, vectors = torch.", "reference": "values,vectors=torch.linalg.eigh(input[:,:,:2])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "values,vectors=torch.linalg.eigh(input[:,:,:2])", "y_neg": " values, vectors = torch.symeig(input, eigenvectors=True)", "retain": "def Eigen2xywhTheda_gpu(input_vector): # [:, xywhtheda] [a1, a2, cx; a3, a4, cy]\n\n # 2D\n if len(input_vector.shape) == 2:\n output = torch.zeros((input_vector.shape[0], 5))\n input = torch.zeros((input_vector.shape[0], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[:, 0] # cx\n input[:, 1, 2] = input_vector[:, 1] # cy\n input[:, 0, 0] = input_vector[:, 2] # a1\n input[:, 0, 1] = input_vector[:, 4] # a2\n input[:, 1, 0] = input_vector[:, 4] # a3\n input[:, 1, 1] = input_vector[:, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n values, vectors = torch.linalg.eigh(input[:, :, :2]) # np.where\n a = values.argmax(axis=1)\n output[:, 2] = values[torch.arange(len(a)), a]\n b = 1 - a\n output[:, 3] = values[torch.arange(len(b)), b]\n\n theda_vector = vectors[torch.arange(len(a)), :, a]\n theda = torch.arctan2(theda_vector[:, 1], theda_vector[:, 0]) + pi # 0 ~ 2*pi\n theda[theda >= pi] -= pi\n theda[theda == pi] -= pi # [0, 2*pi] to [0, pi)\n\n output_theda = pi - theda\n output_theda[output_theda == pi] -= pi # (0, pi] to [0, pi)\n output[:, 4] = output_theda\n\n elif len(input_vector.shape) == 3:\n output_3 = torch.zeros((input_vector.shape[0], input_vector.shape[1], 5))\n for index in range(input_vector.shape[0]):\n output = torch.zeros((input_vector.shape[1], 5))\n input = torch.zeros((input_vector.shape[1], 2, 3)) # Vector to Matrix\n input[:, 0, 2] = input_vector[index, :, 0] # cx\n input[:, 1, 2] = input_vector[index, :, 1] # cy\n input[:, 0, 0] = input_vector[index, :, 2] # a1\n input[:, 0, 1] = input_vector[index, :, 4] # a2\n input[:, 1, 0] = input_vector[index, :, 4] # a3\n input[:, 1, 1] = input_vector[index, :, 3] # a4\n\n output[:, 0] = input[:, 0, 2] # cx\n output[:, 1] = input[:, 1, 2] # cy\n\n values, vectors = torch.linalg.eigh(input[:, :, :2]) # np.where\n a = values.argmax(axis=1)\n output[:, 2] = values[torch.arange(a.size), a]\n\n b = 1 - a\n output[:, 3] = values[torch.arange(b.size), b]\n\n theda_vector = vectors[torch.arange(a.size), :, a]\n theda = torch.arctan2(theda_vector[:, 1], theda_vector[:, 0]) + pi # 0 ~ 2*pi\n theda[theda >= pi] -= pi\n theda[theda == pi] -= pi # [0, 2*pi] to [0, pi)\n\n output_theda = pi - theda\n output_theda[output_theda == pi] -= pi # (0, pi] to [0, pi)\n output[:, 4] = output_theda\n\n output_3[index, :, :] = output\n output = output_3\n\n output[..., 4] = output[..., 4] / pi * 180\n return output" }, { "id": 6933, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_code_stats(code, device):\n\tcode = code.to(torch.float64).to(device)\n\tn = code.size(0)\n\tm = code.size(2)\n\ts = torch.zeros(m, dtype = torch.float64, device = device)\n\tsxy = torch.zeros(m, m, dtype = torch.float64, device = device)\n\tsv = torch.zeros(m, dtype = torch.float64, device = device)\n\n\tfor code_batch in code.split(1024):\n\t\tmean, std = code_batch.unbind(1)\n\t\ts.add_(mean.sum(0))\n\t\tsxy.add_(mean.t() @ mean)\n\t\tsv.add_(std.pow(2).sum(0))\n\n\tex = s.cpu() / n\n\tcov = sxy.cpu() / n - ex.unsqueeze(0) * ex.unsqueeze(1)\n\tev = sv.cpu() / n\n\n\tfull_var = torch.diag(cov) + ev\n\tfull_std = full_var.sqrt()\n\tvar_ratio = torch.diag(cov) / full_var\n\n\tnormalized_cov = cov / (full_std.unsqueeze(0) * full_std.unsqueeze(1))\n\n\teigval, eigvec = torch.linalg.eigh(normalized_cov)\n\n\tstats = {\n\t\t'mean': ex.to(torch.float32),\n\t\t'std': full_std.to(torch.float32),\n\t\t'var_ratio': var_ratio.to(torch.float32),\n\t\t'eigval': eigval.to(torch.float32),\n\t\t'eigvec': eigvec.to(torch.float32)\n\t}\n\treturn stats", "probing input": "def get_code_stats(code, device):\n\tcode = code.to(torch.float64).to(device)\n\tn = code.size(0)\n\tm = code.size(2)\n\ts = torch.zeros(m, dtype = torch.float64, device = device)\n\tsxy = torch.zeros(m, m, dtype = torch.float64, device = device)\n\tsv = torch.zeros(m, dtype = torch.float64, device = device)\n\n\tfor code_batch in code.split(1024):\n\t\tmean, std = code_batch.unbind(1)\n\t\ts.add_(mean.sum(0))\n\t\tsxy.add_(mean.t() @ mean)\n\t\tsv.add_(std.pow(2).sum(0))\n\n\tex = s.cpu() / n\n\tcov = sxy.cpu() / n - ex.unsqueeze(0) * ex.unsqueeze(1)\n\tev = sv.cpu() / n\n\n\tfull_var = torch.diag(cov) + ev\n\tfull_std = full_var.sqrt()\n\tvar_ratio = torch.diag(cov) / full_var\n\n\tnormalized_cov = cov / (full_std.unsqueeze(0) * full_std.unsqueeze(1))\n\n", "probing input new": "def get_code_stats(code, device):\n\tcode = code.to(torch.float64).to(device)\n\tn = code.size(0)\n\tm = code.size(2)\n\ts = torch.zeros(m, dtype = torch.float64, device = device)\n\tsxy = torch.zeros(m, m, dtype = torch.float64, device = device)\n\tsv = torch.zeros(m, dtype = torch.float64, device = device)\n\n\tfor code_batch in code.split(1024):\n\t\tmean, std = code_batch.unbind(1)\n\t\ts.add_(mean.sum(0))\n\t\tsxy.add_(mean.t() @ mean)\n\t\tsv.add_(std.pow(2).sum(0))\n\n\tex = s.cpu() / n\n\tcov = sxy.cpu() / n - ex.unsqueeze(0) * ex.unsqueeze(1)\n\tev = sv.cpu() / n\n\n\tfull_var = torch.diag(cov) + ev\n\tfull_std = full_var.sqrt()\n\tvar_ratio = torch.diag(cov) / full_var\n\n\tnormalized_cov = cov / (full_std.unsqueeze(0) * full_std.unsqueeze(1))\n\n\teigval, eigvec = torch.", "reference": "eigval,eigvec=torch.linalg.eigh(normalized_cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigval,eigvec=torch.linalg.eigh(normalized_cov)", "y_neg": "\teigval, eigvec = torch.symeig(normalized_cov, eigenvectors = True)", "retain": "def get_code_stats(code, device):\n\tcode = code.to(torch.float64).to(device)\n\tn = code.size(0)\n\tm = code.size(2)\n\ts = torch.zeros(m, dtype = torch.float64, device = device)\n\tsxy = torch.zeros(m, m, dtype = torch.float64, device = device)\n\tsv = torch.zeros(m, dtype = torch.float64, device = device)\n\n\tfor code_batch in code.split(1024):\n\t\tmean, std = code_batch.unbind(1)\n\t\ts.add_(mean.sum(0))\n\t\tsxy.add_(mean.t() @ mean)\n\t\tsv.add_(std.pow(2).sum(0))\n\n\tex = s.cpu() / n\n\tcov = sxy.cpu() / n - ex.unsqueeze(0) * ex.unsqueeze(1)\n\tev = sv.cpu() / n\n\n\tfull_var = torch.diag(cov) + ev\n\tfull_std = full_var.sqrt()\n\tvar_ratio = torch.diag(cov) / full_var\n\n\tnormalized_cov = cov / (full_std.unsqueeze(0) * full_std.unsqueeze(1))\n\n\teigval, eigvec = torch.linalg.eigh(normalized_cov)\n\n\tstats = {\n\t\t'mean': ex.to(torch.float32),\n\t\t'std': full_std.to(torch.float32),\n\t\t'var_ratio': var_ratio.to(torch.float32),\n\t\t'eigval': eigval.to(torch.float32),\n\t\t'eigvec': eigvec.to(torch.float32)\n\t}\n\treturn stats" }, { "id": 6943, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def negative_log_likelihood(self, space_coordinates, time_coordinates, stData):\n \"\"\"\n Calculates the negative log-likelihood of the MultiTaskGP_IMC model.\n\n Args:\n space_coordinates (torch.Tensor): Tensor containing the space coordinates.\n time_coordinates (torch.Tensor): Tensor containing the time coordinates.\n stData (torch.Tensor): Tensor containing the data.\n\n Returns:\n The negative log-likelihood value.\n \"\"\"\n latlong_K = self.latlong_kernel(space_coordinates[:, 0:2], space_coordinates[:, 0:2])\n elevation_K = self.elevation_kernel(space_coordinates[:, 2:3], space_coordinates[:, 2:3])\n\n spatial_K = latlong_K * elevation_K + torch.eye(latlong_K.size(0)) * JITTER\n temporal_K = self.temporal_kernel(time_coordinates, time_coordinates) + torch.eye(time_coordinates.size(0)) * JITTER\n\n # Matrix Eigendecomposition\n eigen_value_s, eigen_vector_s = torch.linalg.eigh(spatial_K, UPLO='L')\n eigen_value_t, eigen_vector_t = torch.linalg.eigh(temporal_K, UPLO='L')\n\n eigen_vector_st = kronecker(eigen_vector_t, eigen_vector_s)\n eigen_value_st = kronecker(eigen_value_t.view(-1, 1), eigen_value_s.view(-1, 1)).view(-1)\n eigen_value_st_plus_noise_inverse = 1. / (eigen_value_st + torch.exp(self.log_noise_variance))\n\n Lambda_st = eigen_value_st_plus_noise_inverse.diag_embed()\n A = torch.flatten(eigen_vector_t.transpose(-2, -1) @ stData.transpose(-2, -1) @ eigen_vector_s).unsqueeze(-1) \n self.alpha = Lambda_st @ A\n self.Lambda_st = Lambda_st\n self.eigen_vector_st = eigen_vector_st\n\n nll = 0\n nll += 0.5 * (eigen_value_st + torch.exp(self.log_noise_variance)).log().sum()\n nll += 0.5 * (A.transpose(-2, -1) @ self.alpha).sum()\n return nll", "probing input": " def negative_log_likelihood(self, space_coordinates, time_coordinates, stData):\n \"\"\"\n Calculates the negative log-likelihood of the MultiTaskGP_IMC model.\n\n Args:\n space_coordinates (torch.Tensor): Tensor containing the space coordinates.\n time_coordinates (torch.Tensor): Tensor containing the time coordinates.\n stData (torch.Tensor): Tensor containing the data.\n\n Returns:\n The negative log-likelihood value.\n \"\"\"\n latlong_K = self.latlong_kernel(space_coordinates[:, 0:2], space_coordinates[:, 0:2])\n elevation_K = self.elevation_kernel(space_coordinates[:, 2:3], space_coordinates[:, 2:3])\n\n spatial_K = latlong_K * elevation_K + torch.eye(latlong_K.size(0)) * JITTER\n temporal_K = self.temporal_kernel(time_coordinates, time_coordinates) + torch.eye(time_coordinates.size(0)) * JITTER\n\n # Matrix Eigendecomposition\n", "probing input new": " def negative_log_likelihood(self, space_coordinates, time_coordinates, stData):\n \"\"\"\n Calculates the negative log-likelihood of the MultiTaskGP_IMC model.\n\n Args:\n space_coordinates (torch.Tensor): Tensor containing the space coordinates.\n time_coordinates (torch.Tensor): Tensor containing the time coordinates.\n stData (torch.Tensor): Tensor containing the data.\n\n Returns:\n The negative log-likelihood value.\n \"\"\"\n latlong_K = self.latlong_kernel(space_coordinates[:, 0:2], space_coordinates[:, 0:2])\n elevation_K = self.elevation_kernel(space_coordinates[:, 2:3], space_coordinates[:, 2:3])\n\n spatial_K = latlong_K * elevation_K + torch.eye(latlong_K.size(0)) * JITTER\n temporal_K = self.temporal_kernel(time_coordinates, time_coordinates) + torch.eye(time_coordinates.size(0)) * JITTER\n\n # Matrix Eigendecomposition\n eigen_value_s, eigen_vector_s = torch.", "reference": "eigen_value_s,eigen_vector_s=torch.linalg.eigh(spatial_K,UPLO='L')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigen_value_s,eigen_vector_s=torch.linalg.eigh(spatial_K,UPLO='L')", "y_neg": " eigen_value_s, eigen_vector_s = torch.symeig(spatial_K, eigenvectors=True)", "retain": " def negative_log_likelihood(self, space_coordinates, time_coordinates, stData):\n \"\"\"\n Calculates the negative log-likelihood of the MultiTaskGP_IMC model.\n\n Args:\n space_coordinates (torch.Tensor): Tensor containing the space coordinates.\n time_coordinates (torch.Tensor): Tensor containing the time coordinates.\n stData (torch.Tensor): Tensor containing the data.\n\n Returns:\n The negative log-likelihood value.\n \"\"\"\n latlong_K = self.latlong_kernel(space_coordinates[:, 0:2], space_coordinates[:, 0:2])\n elevation_K = self.elevation_kernel(space_coordinates[:, 2:3], space_coordinates[:, 2:3])\n\n spatial_K = latlong_K * elevation_K + torch.eye(latlong_K.size(0)) * JITTER\n temporal_K = self.temporal_kernel(time_coordinates, time_coordinates) + torch.eye(time_coordinates.size(0)) * JITTER\n\n # Matrix Eigendecomposition\n eigen_value_s, eigen_vector_s = torch.linalg.eigh(spatial_K, UPLO='L')\n eigen_value_t, eigen_vector_t = torch.linalg.eigh(temporal_K, UPLO='L')\n\n eigen_vector_st = kronecker(eigen_vector_t, eigen_vector_s)\n eigen_value_st = kronecker(eigen_value_t.view(-1, 1), eigen_value_s.view(-1, 1)).view(-1)\n eigen_value_st_plus_noise_inverse = 1. / (eigen_value_st + torch.exp(self.log_noise_variance))\n\n Lambda_st = eigen_value_st_plus_noise_inverse.diag_embed()\n A = torch.flatten(eigen_vector_t.transpose(-2, -1) @ stData.transpose(-2, -1) @ eigen_vector_s).unsqueeze(-1) \n self.alpha = Lambda_st @ A\n self.Lambda_st = Lambda_st\n self.eigen_vector_st = eigen_vector_st\n\n nll = 0\n nll += 0.5 * (eigen_value_st + torch.exp(self.log_noise_variance)).log().sum()\n nll += 0.5 * (A.transpose(-2, -1) @ self.alpha).sum()\n return nll" }, { "id": 6952, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_norm_connection_laplacian_with_edge_weights_produces_valid_laplacian(graph_id, d, orth_trans):\n # Fix the random seed\n torch.random.manual_seed(0)\n np.random.seed(0)\n\n # Build a test graph\n graph = nx.graph_atlas(graph_id)\n size = len(graph)\n data = from_networkx(graph)\n\n # Construct the model\n model = NormConnectionLaplacianBuilder(\n size, edge_index=data.edge_index, d=d, orth_map=orth_trans, add_lp=True, add_hp=True)\n # Generate maps\n samples = data.edge_index.size(1)\n if orth_trans in [\"householder\", \"euler\"]:\n map_params = torch.FloatTensor(size=(samples, d * (d - 1) // 2)).uniform_(-1.0, 1.0)\n else:\n map_params = torch.FloatTensor(size=(samples, d * (d + 1) // 2)).uniform_(-1.0, 1.0)\n\n edge_weights = lap.get_random_edge_weights(data.edge_index)\n # Use edge weights\n maps = model.orth_transform(map_params)\n\n L, _ = model(map_params, edge_weights)\n L = torch.sparse_coo_tensor(L[0], L[1], size=(size*(d+2), size*(d+2)), dtype=torch.float64).to_dense()\n Q, _ = torch.linalg.eigh(L)\n\n # Check that L is semi-positive definite.\n eps = 1e-6\n assert torch.equal(L, L.T)\n assert torch.all(Q >= 0 - eps), Q\n assert torch.all(Q <= 2. + eps), Q\n\n # Append fixed submaps to the restriction maps.\n values = [1.0, -1.0]\n L_dense = build_dense_laplacian(size, data.edge_index, maps, d, normalised=True, values=values,\n edge_weights=edge_weights)\n assert torch.allclose(L, L_dense, atol=eps)", "probing input": "def test_norm_connection_laplacian_with_edge_weights_produces_valid_laplacian(graph_id, d, orth_trans):\n # Fix the random seed\n torch.random.manual_seed(0)\n np.random.seed(0)\n\n # Build a test graph\n graph = nx.graph_atlas(graph_id)\n size = len(graph)\n data = from_networkx(graph)\n\n # Construct the model\n model = NormConnectionLaplacianBuilder(\n size, edge_index=data.edge_index, d=d, orth_map=orth_trans, add_lp=True, add_hp=True)\n # Generate maps\n samples = data.edge_index.size(1)\n if orth_trans in [\"householder\", \"euler\"]:\n map_params = torch.FloatTensor(size=(samples, d * (d - 1) // 2)).uniform_(-1.0, 1.0)\n else:\n map_params = torch.FloatTensor(size=(samples, d * (d + 1) // 2)).uniform_(-1.0, 1.0)\n\n edge_weights = lap.get_random_edge_weights(data.edge_index)\n # Use edge weights\n maps = model.orth_transform(map_params)\n\n L, _ = model(map_params, edge_weights)\n L = torch.sparse_coo_tensor(L[0], L[1], size=(size*(d+2), size*(d+2)), dtype=torch.float64).to_dense()\n", "probing input new": "def test_norm_connection_laplacian_with_edge_weights_produces_valid_laplacian(graph_id, d, orth_trans):\n # Fix the random seed\n torch.random.manual_seed(0)\n np.random.seed(0)\n\n # Build a test graph\n graph = nx.graph_atlas(graph_id)\n size = len(graph)\n data = from_networkx(graph)\n\n # Construct the model\n model = NormConnectionLaplacianBuilder(\n size, edge_index=data.edge_index, d=d, orth_map=orth_trans, add_lp=True, add_hp=True)\n # Generate maps\n samples = data.edge_index.size(1)\n if orth_trans in [\"householder\", \"euler\"]:\n map_params = torch.FloatTensor(size=(samples, d * (d - 1) // 2)).uniform_(-1.0, 1.0)\n else:\n map_params = torch.FloatTensor(size=(samples, d * (d + 1) // 2)).uniform_(-1.0, 1.0)\n\n edge_weights = lap.get_random_edge_weights(data.edge_index)\n # Use edge weights\n maps = model.orth_transform(map_params)\n\n L, _ = model(map_params, edge_weights)\n L = torch.sparse_coo_tensor(L[0], L[1], size=(size*(d+2), size*(d+2)), dtype=torch.float64).to_dense()\n Q, _ = torch.", "reference": "Q,_=torch.linalg.eigh(L)", "reference dict": { "model": "NormConnectionLaplacianBuilder" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "Q,_=torch.linalg.eigh(L)", "y_neg": " Q, _ = torch.symeig(L, eigenvectors=True)", "retain": "def test_norm_connection_laplacian_with_edge_weights_produces_valid_laplacian(graph_id, d, orth_trans):\n # Fix the random seed\n torch.random.manual_seed(0)\n np.random.seed(0)\n\n # Build a test graph\n graph = nx.graph_atlas(graph_id)\n size = len(graph)\n data = from_networkx(graph)\n\n # Construct the model\n model = NormConnectionLaplacianBuilder(\n size, edge_index=data.edge_index, d=d, orth_map=orth_trans, add_lp=True, add_hp=True)\n # Generate maps\n samples = data.edge_index.size(1)\n if orth_trans in [\"householder\", \"euler\"]:\n map_params = torch.FloatTensor(size=(samples, d * (d - 1) // 2)).uniform_(-1.0, 1.0)\n else:\n map_params = torch.FloatTensor(size=(samples, d * (d + 1) // 2)).uniform_(-1.0, 1.0)\n\n edge_weights = lap.get_random_edge_weights(data.edge_index)\n # Use edge weights\n maps = model.orth_transform(map_params)\n\n L, _ = model(map_params, edge_weights)\n L = torch.sparse_coo_tensor(L[0], L[1], size=(size*(d+2), size*(d+2)), dtype=torch.float64).to_dense()\n Q, _ = torch.linalg.eigh(L)\n\n # Check that L is semi-positive definite.\n eps = 1e-6\n assert torch.equal(L, L.T)\n assert torch.all(Q >= 0 - eps), Q\n assert torch.all(Q <= 2. + eps), Q\n\n # Append fixed submaps to the restriction maps.\n values = [1.0, -1.0]\n L_dense = build_dense_laplacian(size, data.edge_index, maps, d, normalised=True, values=values,\n edge_weights=edge_weights)\n assert torch.allclose(L, L_dense, atol=eps)" }, { "id": 6953, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def tensor_exp(self, t):#4dim\n # condition: t is symmetric!\n s, u = torch.linalg.eigh(t)\n return u @ torch.diag_embed(torch.exp(s)) @ u.permute(0, 1, 3, 2)", "probing input": " def tensor_exp(self, t):#4dim\n # condition: t is symmetric!\n", "probing input new": " def tensor_exp(self, t):#4dim\n # condition: t is symmetric!\n s, u = torch.", "reference": "s,u=torch.linalg.eigh(t)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "s,u=torch.linalg.eigh(t)", "y_neg": " s, u = torch.symeig(t, eigenvectors=True)", "retain": " def tensor_exp(self, t):#4dim\n # condition: t is symmetric!\n s, u = torch.linalg.eigh(t)\n return u @ torch.diag_embed(torch.exp(s)) @ u.permute(0, 1, 3, 2)" }, { "id": 6954, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, a: Tensor, method: str = 'cond', factor: float = 1E-12\n ) -> Tuple[Tensor, Tensor]:\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Finds the eigenvalues and eigenvectors of a real symmetric\n matrix using the torch.symeig function.\n\n Arguments:\n a: A real symmetric matrix whose eigenvalues & eigenvectors will\n be computed.\n method: Broadening method to used, available options are:\n\n - \"cond\" for conditional broadening.\n - \"lorn\" for Lorentzian broadening.\n\n See class doc-string for more info on these methods.\n [DEFAULT='cond']\n factor: Degree of broadening (broadening factor). [Default=1E-12]\n\n Returns:\n w: The eigenvalues, in ascending order.\n v: The eigenvectors.\n\n Notes:\n The ctx argument is auto-parsed by PyTorch & is used to pass data\n from the .forward() method to the .backward() method. This is not\n normally described in the docstring but has been done here to act\n as an example.\n\n Warnings:\n Under no circumstances should `factor` be a torch.tensor entity.\n The `method` and `factor` parameters MUST be passed as positional\n arguments and NOT keyword arguments.\n\n \"\"\"\n # Check that the method is of a known type\n if method not in _SymEigB.KNOWN_METHODS:\n raise ValueError('Unknown broadening method selected.')\n\n # Compute eigen-values & vectors using torch.symeig.\n w, v = torch.linalg.eigh(a)\n\n # Save tensors that will be needed in the backward pass\n ctx.save_for_backward(w, v)\n\n # Save the broadening factor and the selected broadening method.\n ctx.bf, ctx.bm = factor, method\n\n # Store dtype/device to prevent dtype/device mixing\n ctx.dtype, ctx.device = a.dtype, a.device\n\n # Return the eigenvalues and eigenvectors\n return w, v", "probing input": " def forward(ctx, a: Tensor, method: str = 'cond', factor: float = 1E-12\n ) -> Tuple[Tensor, Tensor]:\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Finds the eigenvalues and eigenvectors of a real symmetric\n matrix using the torch.symeig function.\n\n Arguments:\n a: A real symmetric matrix whose eigenvalues & eigenvectors will\n be computed.\n method: Broadening method to used, available options are:\n\n - \"cond\" for conditional broadening.\n - \"lorn\" for Lorentzian broadening.\n\n See class doc-string for more info on these methods.\n [DEFAULT='cond']\n factor: Degree of broadening (broadening factor). [Default=1E-12]\n\n Returns:\n w: The eigenvalues, in ascending order.\n v: The eigenvectors.\n\n Notes:\n The ctx argument is auto-parsed by PyTorch & is used to pass data\n from the .forward() method to the .backward() method. This is not\n normally described in the docstring but has been done here to act\n as an example.\n\n Warnings:\n Under no circumstances should `factor` be a torch.tensor entity.\n The `method` and `factor` parameters MUST be passed as positional\n arguments and NOT keyword arguments.\n\n \"\"\"\n # Check that the method is of a known type\n if method not in _SymEigB.KNOWN_METHODS:\n raise ValueError('Unknown broadening method selected.')\n\n # Compute eigen-values & vectors using torch.symeig.\n", "probing input new": " def forward(ctx, a: Tensor, method: str = 'cond', factor: float = 1E-12\n ) -> Tuple[Tensor, Tensor]:\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Finds the eigenvalues and eigenvectors of a real symmetric\n matrix using the torch.symeig function.\n\n Arguments:\n a: A real symmetric matrix whose eigenvalues & eigenvectors will\n be computed.\n method: Broadening method to used, available options are:\n\n - \"cond\" for conditional broadening.\n - \"lorn\" for Lorentzian broadening.\n\n See class doc-string for more info on these methods.\n [DEFAULT='cond']\n factor: Degree of broadening (broadening factor). [Default=1E-12]\n\n Returns:\n w: The eigenvalues, in ascending order.\n v: The eigenvectors.\n\n Notes:\n The ctx argument is auto-parsed by PyTorch & is used to pass data\n from the .forward() method to the .backward() method. This is not\n normally described in the docstring but has been done here to act\n as an example.\n\n Warnings:\n Under no circumstances should `factor` be a torch.tensor entity.\n The `method` and `factor` parameters MUST be passed as positional\n arguments and NOT keyword arguments.\n\n \"\"\"\n # Check that the method is of a known type\n if method not in _SymEigB.KNOWN_METHODS:\n raise ValueError('Unknown broadening method selected.')\n\n # Compute eigen-values & vectors using torch.symeig.\n w, v = torch.", "reference": "w,v=torch.linalg.eigh(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "w,v=torch.linalg.eigh(a)", "y_neg": " w, v = torch.symeig(a, eigenvectors=True)", "retain": " def forward(ctx, a: Tensor, method: str = 'cond', factor: float = 1E-12\n ) -> Tuple[Tensor, Tensor]:\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Finds the eigenvalues and eigenvectors of a real symmetric\n matrix using the torch.symeig function.\n\n Arguments:\n a: A real symmetric matrix whose eigenvalues & eigenvectors will\n be computed.\n method: Broadening method to used, available options are:\n\n - \"cond\" for conditional broadening.\n - \"lorn\" for Lorentzian broadening.\n\n See class doc-string for more info on these methods.\n [DEFAULT='cond']\n factor: Degree of broadening (broadening factor). [Default=1E-12]\n\n Returns:\n w: The eigenvalues, in ascending order.\n v: The eigenvectors.\n\n Notes:\n The ctx argument is auto-parsed by PyTorch & is used to pass data\n from the .forward() method to the .backward() method. This is not\n normally described in the docstring but has been done here to act\n as an example.\n\n Warnings:\n Under no circumstances should `factor` be a torch.tensor entity.\n The `method` and `factor` parameters MUST be passed as positional\n arguments and NOT keyword arguments.\n\n \"\"\"\n # Check that the method is of a known type\n if method not in _SymEigB.KNOWN_METHODS:\n raise ValueError('Unknown broadening method selected.')\n\n # Compute eigen-values & vectors using torch.symeig.\n w, v = torch.linalg.eigh(a)\n\n # Save tensors that will be needed in the backward pass\n ctx.save_for_backward(w, v)\n\n # Save the broadening factor and the selected broadening method.\n ctx.bf, ctx.bm = factor, method\n\n # Store dtype/device to prevent dtype/device mixing\n ctx.dtype, ctx.device = a.dtype, a.device\n\n # Return the eigenvalues and eigenvectors\n return w, v" }, { "id": 6962, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def generalized_eigh(A: Tensor, B: Tensor) -> tuple:\n r\"\"\"A workaround to solve a real symmetric generalized eigenvalue problem :math:`Av = \\lambda Bv` using the eigenvalue decomposition of :math:`B^{-1/2}AB^{-1/2}`. This method is not numerically efficient.\n\n Parameters\n ----------\n A : Tensor\n\n B : Tensor\n\n Returns\n -------\n tuple\n Eigenvalues and eigenvectors of the generalized eigenvalue problem.\n \"\"\"\n Lambda, Q = torch.linalg.eigh(B)\n rsqrt_Lambda = torch.diag(Lambda.rsqrt())\n rsqrt_B = Q @ rsqrt_Lambda\n _A = 0.5 * (\n rsqrt_B.T @ (A @ rsqrt_B) + rsqrt_B.T @ ((A.T) @ rsqrt_B)\n ) # Force Symmetrization\n values, _tmp_vecs = torch.linalg.eigh(_A)\n vectors = rsqrt_B @ _tmp_vecs\n return values, vectors", "probing input": "def generalized_eigh(A: Tensor, B: Tensor) -> tuple:\n r\"\"\"A workaround to solve a real symmetric generalized eigenvalue problem :math:`Av = \\lambda Bv` using the eigenvalue decomposition of :math:`B^{-1/2}AB^{-1/2}`. This method is not numerically efficient.\n\n Parameters\n ----------\n A : Tensor\n\n B : Tensor\n\n Returns\n -------\n tuple\n Eigenvalues and eigenvectors of the generalized eigenvalue problem.\n \"\"\"\n", "probing input new": "def generalized_eigh(A: Tensor, B: Tensor) -> tuple:\n r\"\"\"A workaround to solve a real symmetric generalized eigenvalue problem :math:`Av = \\lambda Bv` using the eigenvalue decomposition of :math:`B^{-1/2}AB^{-1/2}`. This method is not numerically efficient.\n\n Parameters\n ----------\n A : Tensor\n\n B : Tensor\n\n Returns\n -------\n tuple\n Eigenvalues and eigenvectors of the generalized eigenvalue problem.\n \"\"\"\n Lambda, Q = torch.", "reference": "Lambda,Q=torch.linalg.eigh(B)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "Lambda,Q=torch.linalg.eigh(B)", "y_neg": " Lambda, Q = torch.symeig(B.t() @ A @ B, eigenvectors=True)", "retain": "def generalized_eigh(A: Tensor, B: Tensor) -> tuple:\n r\"\"\"A workaround to solve a real symmetric generalized eigenvalue problem :math:`Av = \\lambda Bv` using the eigenvalue decomposition of :math:`B^{-1/2}AB^{-1/2}`. This method is not numerically efficient.\n\n Parameters\n ----------\n A : Tensor\n\n B : Tensor\n\n Returns\n -------\n tuple\n Eigenvalues and eigenvectors of the generalized eigenvalue problem.\n \"\"\"\n Lambda, Q = torch.linalg.eigh(B)\n rsqrt_Lambda = torch.diag(Lambda.rsqrt())\n rsqrt_B = Q @ rsqrt_Lambda\n _A = 0.5 * (\n rsqrt_B.T @ (A @ rsqrt_B) + rsqrt_B.T @ ((A.T) @ rsqrt_B)\n ) # Force Symmetrization\n values, _tmp_vecs = torch.linalg.eigh(_A)\n vectors = rsqrt_B @ _tmp_vecs\n return values, vectors" }, { "id": 6970, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sym_matrix_pow(matrix: torch.Tensor, p: float) -> torch.Tensor:\n r\"\"\"\n Power of a matrix using Eigen Decomposition.\n Args:\n matrix: a batch of matrices\n p: power\n Returns:\n Power of a matrix\n \"\"\"\n vals, vecs = torch.linalg.eigh(matrix)\n vals[vals > 0] = vals[vals > 0].pow(p)\n matrix_pow = vecs @ torch.diag(vals) @ vecs.T\n return matrix_pow", "probing input": "def sym_matrix_pow(matrix: torch.Tensor, p: float) -> torch.Tensor:\n r\"\"\"\n Power of a matrix using Eigen Decomposition.\n Args:\n matrix: a batch of matrices\n p: power\n Returns:\n Power of a matrix\n \"\"\"\n", "probing input new": "def sym_matrix_pow(matrix: torch.Tensor, p: float) -> torch.Tensor:\n r\"\"\"\n Power of a matrix using Eigen Decomposition.\n Args:\n matrix: a batch of matrices\n p: power\n Returns:\n Power of a matrix\n \"\"\"\n vals, vecs = torch.", "reference": "vals,vecs=torch.linalg.eigh(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "vals,vecs=torch.linalg.eigh(matrix)", "y_neg": " vals, vecs = torch.symeig(matrix, eigenvectors=True)", "retain": "def sym_matrix_pow(matrix: torch.Tensor, p: float) -> torch.Tensor:\n r\"\"\"\n Power of a matrix using Eigen Decomposition.\n Args:\n matrix: a batch of matrices\n p: power\n Returns:\n Power of a matrix\n \"\"\"\n vals, vecs = torch.linalg.eigh(matrix)\n vals[vals > 0] = vals[vals > 0].pow(p)\n matrix_pow = vecs @ torch.diag(vals) @ vecs.T\n return matrix_pow" }, { "id": 6971, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sorted_eig(cov): # For now we sort 'by convention'. For PCA the sorting is key.\n lambdas, vs = torch.linalg.eigh(cov) # cov is symmetric so we can use eigh instead of eig\n lambdas, indices = torch.sort(lambdas, dim=0, descending=True)\n vs = torch.index_select(vs, 0, indices)\n return lambdas, vs", "probing input": "def sorted_eig(cov): # For now we sort 'by convention'. For PCA the sorting is key.\n", "probing input new": "def sorted_eig(cov): # For now we sort 'by convention'. For PCA the sorting is key.\n lambdas, vs = torch.", "reference": "lambdas,vs=torch.linalg.eigh(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "lambdas,vs=torch.linalg.eigh(cov)", "y_neg": " lambdas, vs = torch.symeig(cov, eigenvectors=True)", "retain": "def sorted_eig(cov): # For now we sort 'by convention'. For PCA the sorting is key.\n lambdas, vs = torch.linalg.eigh(cov) # cov is symmetric so we can use eigh instead of eig\n lambdas, indices = torch.sort(lambdas, dim=0, descending=True)\n vs = torch.index_select(vs, 0, indices)\n return lambdas, vs" }, { "id": 6980, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def quaternion_average(self, Q1, weights):\n Q1 = Q1 + eps\n # print(\"\\n\\n-------Quaternions-----------\\n{}\".format(Q1))\n weights = F.normalize(weights, p=1, dim=1)\n outer = weights[(...,) + (None,) * 2] * (Q1.unsqueeze(dim=-1) @ Q1.unsqueeze(dim=3))\n M = outer.sum(1, keepdim=True)\n M = M + (1e-6) * torch.randn_like(M)\n\n eigs, eigvect = torch.linalg.eigh(M.view(-1, M.shape[-2], M.shape[-1]).cpu())\n eigs = eigs.to(engine.device)\n eigvect = eigvect.to(engine.device)\n normalized_eigs = torch.div(eigs, eigs.sum(dim=1).unsqueeze(1))\n normalized_max_eig = normalized_eigs[:, -1].view(M.shape[0], M.shape[-3], 1)\n avg_quats = eigvect[:, -1, :].view(M.shape[:-1])\n\n return normalized_max_eig, avg_quats", "probing input": " def quaternion_average(self, Q1, weights):\n Q1 = Q1 + eps\n # print(\"\\n\\n-------Quaternions-----------\\n{}\".format(Q1))\n weights = F.normalize(weights, p=1, dim=1)\n outer = weights[(...,) + (None,) * 2] * (Q1.unsqueeze(dim=-1) @ Q1.unsqueeze(dim=3))\n M = outer.sum(1, keepdim=True)\n M = M + (1e-6) * torch.randn_like(M)\n\n", "probing input new": " def quaternion_average(self, Q1, weights):\n Q1 = Q1 + eps\n # print(\"\\n\\n-------Quaternions-----------\\n{}\".format(Q1))\n weights = F.normalize(weights, p=1, dim=1)\n outer = weights[(...,) + (None,) * 2] * (Q1.unsqueeze(dim=-1) @ Q1.unsqueeze(dim=3))\n M = outer.sum(1, keepdim=True)\n M = M + (1e-6) * torch.randn_like(M)\n\n eigs, eigvect = torch.", "reference": "eigs,eigvect=torch.linalg.eigh(M.view(-1,M.shape[-2],M.shape[-1]).cpu())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigs,eigvect=torch.linalg.eigh(M.view(-1,M.shape[-2],M.shape[-1]).cpu())", "y_neg": " eigs, eigvect = torch.symeig(outer, eigenvectors=True)", "retain": " def quaternion_average(self, Q1, weights):\n Q1 = Q1 + eps\n # print(\"\\n\\n-------Quaternions-----------\\n{}\".format(Q1))\n weights = F.normalize(weights, p=1, dim=1)\n outer = weights[(...,) + (None,) * 2] * (Q1.unsqueeze(dim=-1) @ Q1.unsqueeze(dim=3))\n M = outer.sum(1, keepdim=True)\n M = M + (1e-6) * torch.randn_like(M)\n\n eigs, eigvect = torch.linalg.eigh(M.view(-1, M.shape[-2], M.shape[-1]).cpu())\n eigs = eigs.to(engine.device)\n eigvect = eigvect.to(engine.device)\n normalized_eigs = torch.div(eigs, eigs.sum(dim=1).unsqueeze(1))\n normalized_max_eig = normalized_eigs[:, -1].view(M.shape[0], M.shape[-3], 1)\n avg_quats = eigvect[:, -1, :].view(M.shape[:-1])\n\n return normalized_max_eig, avg_quats" }, { "id": 6983, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, A):\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Parameters\n ----------\n A: torch.Tensor\n The symmetric matrix to be diagonalized. Shape: ``(*BA, q, q)``.\n\n Returns\n -------\n eival: torch.Tensor\n Eigenvalues of the linear operator.\n eivec: torch.Tensor\n Eigenvectors of the linear operator.\n\n \"\"\"\n eival, eivec = torch.linalg.eigh(A)\n ctx.save_for_backward(eival, eivec)\n return eival, eivec", "probing input": " def forward(ctx, A):\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Parameters\n ----------\n A: torch.Tensor\n The symmetric matrix to be diagonalized. Shape: ``(*BA, q, q)``.\n\n Returns\n -------\n eival: torch.Tensor\n Eigenvalues of the linear operator.\n eivec: torch.Tensor\n Eigenvectors of the linear operator.\n\n \"\"\"\n", "probing input new": " def forward(ctx, A):\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Parameters\n ----------\n A: torch.Tensor\n The symmetric matrix to be diagonalized. Shape: ``(*BA, q, q)``.\n\n Returns\n -------\n eival: torch.Tensor\n Eigenvalues of the linear operator.\n eivec: torch.Tensor\n Eigenvectors of the linear operator.\n\n \"\"\"\n eival, eivec = torch.", "reference": "eival,eivec=torch.linalg.eigh(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eival,eivec=torch.linalg.eigh(A)", "y_neg": " eival, eivec = torch.symeig(A, eigenvectors=True)", "retain": " def forward(ctx, A):\n \"\"\"Calculate the eigenvalues and eigenvectors of a symmetric matrix.\n\n Parameters\n ----------\n A: torch.Tensor\n The symmetric matrix to be diagonalized. Shape: ``(*BA, q, q)``.\n\n Returns\n -------\n eival: torch.Tensor\n Eigenvalues of the linear operator.\n eivec: torch.Tensor\n Eigenvectors of the linear operator.\n\n \"\"\"\n eival, eivec = torch.linalg.eigh(A)\n ctx.save_for_backward(eival, eivec)\n return eival, eivec" }, { "id": 6988, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res, inv_quad_res = linear_op.sqrt_inv_matmul(rhs, lhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = lhs_copy @ matrix_inv_root @ rhs_copy\n inv_quad_actual = (lhs_copy @ matrix_inv_root).pow(2).sum(dim=-1)\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(inv_quad_res, inv_quad_actual, **self.tolerances[\"sqrt_inv_matmul\"])", "probing input": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res, inv_quad_res = linear_op.sqrt_inv_matmul(rhs, lhs)\n", "probing input new": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res, inv_quad_res = linear_op.sqrt_inv_matmul(rhs, lhs)\n evals, evecs = torch.", "reference": "evals,evecs=torch.linalg.eigh(evaluated)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,evecs=torch.linalg.eigh(evaluated)", "y_neg": " evals, evecs = torch.symeig(linear_op, eigenvectors=True)", "retain": " def test_sqrt_inv_matmul(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n lhs = torch.randn(*linear_op.shape[:-2], 2, linear_op.size(-1)).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res, inv_quad_res = linear_op.sqrt_inv_matmul(rhs, lhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = lhs_copy @ matrix_inv_root @ rhs_copy\n inv_quad_actual = (lhs_copy @ matrix_inv_root).pow(2).sum(dim=-1)\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])\n self.assertAllClose(inv_quad_res, inv_quad_actual, **self.tolerances[\"sqrt_inv_matmul\"])" }, { "id": 6989, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_sqrt_inv_matmul_no_lhs(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res = linear_op.sqrt_inv_matmul(rhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = matrix_inv_root @ rhs_copy\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])", "probing input": " def test_sqrt_inv_matmul_no_lhs(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res = linear_op.sqrt_inv_matmul(rhs)\n", "probing input new": " def test_sqrt_inv_matmul_no_lhs(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res = linear_op.sqrt_inv_matmul(rhs)\n evals, evecs = torch.", "reference": "evals,evecs=torch.linalg.eigh(evaluated)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "evals,evecs=torch.linalg.eigh(evaluated)", "y_neg": " evals, evecs = torch.symeig(sqrt_inv_matmul_res, eigenvectors=True)", "retain": " def test_sqrt_inv_matmul_no_lhs(self):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n if len(linear_op.batch_shape):\n return\n\n linear_op_copy = linear_op.clone().detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n\n # Create a test right hand side and left hand side\n rhs = torch.randn(*linear_op.shape[:-1], 3).requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n\n # Perform forward pass\n sqrt_inv_matmul_res = linear_op.sqrt_inv_matmul(rhs)\n evals, evecs = torch.linalg.eigh(evaluated)\n matrix_inv_root = evecs @ (evals.sqrt().reciprocal().unsqueeze(-1) * evecs.mT)\n sqrt_inv_matmul_actual = matrix_inv_root @ rhs_copy\n\n # Check forward pass\n self.assertAllClose(sqrt_inv_matmul_res, sqrt_inv_matmul_actual, **self.tolerances[\"sqrt_inv_matmul\"])" }, { "id": 6991, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, ref, runtime_dict=None):\n if (runtime_dict is not None) and self.enabled:\n if 'base_bxyz' in runtime_dict:\n # computing volumes\n base_bxyz = runtime_dict['base_bxyz']\n \n e_base, e_voxel, e_weight = self.voxel_graph(base_bxyz, ref)\n\n num_voxels = ref.bcenter.shape[0]\n\n ref.bxyz = scatter(base_bxyz[e_base], e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n ref.volume = scatter(torch.ones_like(e_base), e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n mask = (ref.volume > 0.5)\n ref.volume_mask = mask\n\n ref.bxyz[mask] = ref.bxyz[mask] / ref.volume[mask, None]\n ref.bxyz[~mask] = ref.bcenter[~mask]\n\n point_d = base_bxyz[e_base, 1:] - ref.bxyz[e_voxel, 1:]\n point_ddT = point_d.unsqueeze(-1) * point_d.unsqueeze(-2)\n voxel_ddT = scatter(point_ddT, e_voxel, dim=0,\n dim_size=num_voxels, reduce='mean')\n\n if True:\n voxel_eigvals, voxel_eigvecs = torch.linalg.eigh(voxel_ddT)\n #voxel_eigvals, voxel_eigvecs = np.linalg.eigh(voxel_ddT.detach().cpu().numpy())\n #voxel_eigvals = torch.from_numpy(voxel_eigvals).to(voxel_ddT)\n #voxel_eigvecs = torch.from_numpy(voxel_eigvecs).to(voxel_ddT)\n ref.eigvals = voxel_eigvals\n ref.eigvecs = voxel_eigvecs\n point_l1_proj = (point_d.unsqueeze(-2) @ ref.eigvecs[e_voxel])[:, 0]\n ref.l1_proj_max = scatter(point_l1_proj, e_voxel, dim=0,\n dim_size=num_voxels, reduce='max')\n ref.l1_proj_min = scatter(point_l1_proj, e_voxel, dim=0,\n dim_size=num_voxels, reduce='min')\n\n #import polyscope as ps; ps.init(); ps.set_up_dir('z_up')\n\n #ps.register_point_cloud('voxel_centers', ref.bcenter[:, 1:].detach().cpu().numpy(), radius=2e-4)\n #ps.register_point_cloud('base', base_bxyz[:, 1:].detach().cpu().numpy(), radius=4e-5)\n #centers = torch.cat([ref.bcenter, base_bxyz], dim=0)[:, 1:].detach().cpu().numpy()\n #edges = torch.stack([e_base+num_voxels, e_voxel], dim=-1).detach().cpu().numpy()\n #ps.register_curve_network('edges', centers, edges, radius=2e-5)\n #ps.show()\n #import ipdb; ipdb.set_trace()\n \n return ref", "probing input": " def forward(self, ref, runtime_dict=None):\n if (runtime_dict is not None) and self.enabled:\n if 'base_bxyz' in runtime_dict:\n # computing volumes\n base_bxyz = runtime_dict['base_bxyz']\n \n e_base, e_voxel, e_weight = self.voxel_graph(base_bxyz, ref)\n\n num_voxels = ref.bcenter.shape[0]\n\n ref.bxyz = scatter(base_bxyz[e_base], e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n ref.volume = scatter(torch.ones_like(e_base), e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n mask = (ref.volume > 0.5)\n ref.volume_mask = mask\n\n ref.bxyz[mask] = ref.bxyz[mask] / ref.volume[mask, None]\n ref.bxyz[~mask] = ref.bcenter[~mask]\n\n point_d = base_bxyz[e_base, 1:] - ref.bxyz[e_voxel, 1:]\n point_ddT = point_d.unsqueeze(-1) * point_d.unsqueeze(-2)\n voxel_ddT = scatter(point_ddT, e_voxel, dim=0,\n dim_size=num_voxels, reduce='mean')\n\n if True:\n", "probing input new": " def forward(self, ref, runtime_dict=None):\n if (runtime_dict is not None) and self.enabled:\n if 'base_bxyz' in runtime_dict:\n # computing volumes\n base_bxyz = runtime_dict['base_bxyz']\n \n e_base, e_voxel, e_weight = self.voxel_graph(base_bxyz, ref)\n\n num_voxels = ref.bcenter.shape[0]\n\n ref.bxyz = scatter(base_bxyz[e_base], e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n ref.volume = scatter(torch.ones_like(e_base), e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n mask = (ref.volume > 0.5)\n ref.volume_mask = mask\n\n ref.bxyz[mask] = ref.bxyz[mask] / ref.volume[mask, None]\n ref.bxyz[~mask] = ref.bcenter[~mask]\n\n point_d = base_bxyz[e_base, 1:] - ref.bxyz[e_voxel, 1:]\n point_ddT = point_d.unsqueeze(-1) * point_d.unsqueeze(-2)\n voxel_ddT = scatter(point_ddT, e_voxel, dim=0,\n dim_size=num_voxels, reduce='mean')\n\n if True:\n voxel_eigvals, voxel_eigvecs = torch.", "reference": "voxel_eigvals,voxel_eigvecs=torch.linalg.eigh(voxel_ddT)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "voxel_eigvals,voxel_eigvecs=torch.linalg.eigh(voxel_ddT)", "y_neg": " voxel_eigvals, voxel_eigvecs = torch.symeig(voxel_ddT, eigenvectors=True)", "retain": " def forward(self, ref, runtime_dict=None):\n if (runtime_dict is not None) and self.enabled:\n if 'base_bxyz' in runtime_dict:\n # computing volumes\n base_bxyz = runtime_dict['base_bxyz']\n \n e_base, e_voxel, e_weight = self.voxel_graph(base_bxyz, ref)\n\n num_voxels = ref.bcenter.shape[0]\n\n ref.bxyz = scatter(base_bxyz[e_base], e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n ref.volume = scatter(torch.ones_like(e_base), e_voxel, dim=0,\n dim_size=num_voxels, reduce='sum')\n mask = (ref.volume > 0.5)\n ref.volume_mask = mask\n\n ref.bxyz[mask] = ref.bxyz[mask] / ref.volume[mask, None]\n ref.bxyz[~mask] = ref.bcenter[~mask]\n\n point_d = base_bxyz[e_base, 1:] - ref.bxyz[e_voxel, 1:]\n point_ddT = point_d.unsqueeze(-1) * point_d.unsqueeze(-2)\n voxel_ddT = scatter(point_ddT, e_voxel, dim=0,\n dim_size=num_voxels, reduce='mean')\n\n if True:\n voxel_eigvals, voxel_eigvecs = torch.linalg.eigh(voxel_ddT)\n #voxel_eigvals, voxel_eigvecs = np.linalg.eigh(voxel_ddT.detach().cpu().numpy())\n #voxel_eigvals = torch.from_numpy(voxel_eigvals).to(voxel_ddT)\n #voxel_eigvecs = torch.from_numpy(voxel_eigvecs).to(voxel_ddT)\n ref.eigvals = voxel_eigvals\n ref.eigvecs = voxel_eigvecs\n point_l1_proj = (point_d.unsqueeze(-2) @ ref.eigvecs[e_voxel])[:, 0]\n ref.l1_proj_max = scatter(point_l1_proj, e_voxel, dim=0,\n dim_size=num_voxels, reduce='max')\n ref.l1_proj_min = scatter(point_l1_proj, e_voxel, dim=0,\n dim_size=num_voxels, reduce='min')\n\n #import polyscope as ps; ps.init(); ps.set_up_dir('z_up')\n\n #ps.register_point_cloud('voxel_centers', ref.bcenter[:, 1:].detach().cpu().numpy(), radius=2e-4)\n #ps.register_point_cloud('base', base_bxyz[:, 1:].detach().cpu().numpy(), radius=4e-5)\n #centers = torch.cat([ref.bcenter, base_bxyz], dim=0)[:, 1:].detach().cpu().numpy()\n #edges = torch.stack([e_base+num_voxels, e_voxel], dim=-1).detach().cpu().numpy()\n #ps.register_curve_network('edges', centers, edges, radius=2e-5)\n #ps.show()\n #import ipdb; ipdb.set_trace()\n \n return ref" }, { "id": 6994, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _step(\n gradient: torch.Tensor,\n hessian: torch.Tensor,\n trust_radius: torch.Tensor,\n config: LevenbergMarquardtConfig,\n) -> tuple[torch.Tensor, torch.Tensor, bool, torch.Tensor]:\n \"\"\"Compute the next Levenberg–Marquardt step.\n\n Args:\n gradient: The gradient with ``shape=(n,)``.\n hessian: The hessian with ``shape=(n, n)``.\n trust_radius: The target trust radius.\n config: The optimizer config.\n\n Notes:\n * the code to 'excise' certain parameters is for now removed until its clear\n it is needed.\n * only trust region is implemented (i.e., only trust0 > 0 is supported)\n\n Returns:\n The step with ``shape=(n,)``, the expected improvement with ``shape=()``,\n a boolean indicating whether the damping factor was adjusted, and the damping\n factor with ``shape=(1,)``.\n \"\"\"\n from scipy import optimize\n\n eigenvalues, _ = torch.linalg.eigh(hessian)\n eigenvalue_smallest = eigenvalues.min()\n\n if eigenvalue_smallest < config.min_eigenvalue:\n # Mix in SD step if Hessian minimum eigenvalue is negative - experimental.\n adjacency = (\n max(config.min_eigenvalue, 0.01 * abs(eigenvalue_smallest))\n - eigenvalue_smallest\n )\n\n _LOGGER.info(\n f\"hessian has a small or negative eigenvalue ({eigenvalue_smallest:.1e}), \"\n f\"mixing in some steepest descent ({adjacency:.1e}) to correct this.\"\n )\n hessian += adjacency * torch.eye(\n hessian.shape[0], device=hessian.device, dtype=hessian.dtype\n )\n\n damping_factor = torch.tensor(1.0)\n\n dx, improvement = _solver(damping_factor, gradient, hessian)\n dx_norm = torch.linalg.norm(dx)\n\n adjust_damping = bool(dx_norm > trust_radius)\n\n if adjust_damping:\n # LPW tried a few optimizers and found Brent works well, but also that the\n # tolerance is fractional - if the optimized value is zero it takes a lot of\n # meaningless steps.\n damping_factor = optimize.brent(\n _damping_factor_loss_fn,\n (\n gradient.detach().cpu(),\n hessian.detach().cpu(),\n trust_radius.detach().cpu(),\n ),\n brack=(config.min_damping_factor, config.min_damping_factor * 4),\n tol=1.0e-6 if config.mode.lower() == _ADAPTIVE else 1.0e-4,\n )\n\n dx, improvement = _solver(damping_factor, gradient, hessian)\n\n return dx, improvement, adjust_damping, damping_factor", "probing input": "def _step(\n gradient: torch.Tensor,\n hessian: torch.Tensor,\n trust_radius: torch.Tensor,\n config: LevenbergMarquardtConfig,\n) -> tuple[torch.Tensor, torch.Tensor, bool, torch.Tensor]:\n \"\"\"Compute the next Levenberg–Marquardt step.\n\n Args:\n gradient: The gradient with ``shape=(n,)``.\n hessian: The hessian with ``shape=(n, n)``.\n trust_radius: The target trust radius.\n config: The optimizer config.\n\n Notes:\n * the code to 'excise' certain parameters is for now removed until its clear\n it is needed.\n * only trust region is implemented (i.e., only trust0 > 0 is supported)\n\n Returns:\n The step with ``shape=(n,)``, the expected improvement with ``shape=()``,\n a boolean indicating whether the damping factor was adjusted, and the damping\n factor with ``shape=(1,)``.\n \"\"\"\n from scipy import optimize\n\n", "probing input new": "def _step(\n gradient: torch.Tensor,\n hessian: torch.Tensor,\n trust_radius: torch.Tensor,\n config: LevenbergMarquardtConfig,\n) -> tuple[torch.Tensor, torch.Tensor, bool, torch.Tensor]:\n \"\"\"Compute the next Levenberg–Marquardt step.\n\n Args:\n gradient: The gradient with ``shape=(n,)``.\n hessian: The hessian with ``shape=(n, n)``.\n trust_radius: The target trust radius.\n config: The optimizer config.\n\n Notes:\n * the code to 'excise' certain parameters is for now removed until its clear\n it is needed.\n * only trust region is implemented (i.e., only trust0 > 0 is supported)\n\n Returns:\n The step with ``shape=(n,)``, the expected improvement with ``shape=()``,\n a boolean indicating whether the damping factor was adjusted, and the damping\n factor with ``shape=(1,)``.\n \"\"\"\n from scipy import optimize\n\n eigenvalues, _ = torch.", "reference": "eigenvalues,_=torch.linalg.eigh(hessian)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "eigenvalues,_=torch.linalg.eigh(hessian)", "y_neg": " eigenvalues, _ = torch.symeig(hessian, eigenvectors=True)", "retain": "def _step(\n gradient: torch.Tensor,\n hessian: torch.Tensor,\n trust_radius: torch.Tensor,\n config: LevenbergMarquardtConfig,\n) -> tuple[torch.Tensor, torch.Tensor, bool, torch.Tensor]:\n \"\"\"Compute the next Levenberg–Marquardt step.\n\n Args:\n gradient: The gradient with ``shape=(n,)``.\n hessian: The hessian with ``shape=(n, n)``.\n trust_radius: The target trust radius.\n config: The optimizer config.\n\n Notes:\n * the code to 'excise' certain parameters is for now removed until its clear\n it is needed.\n * only trust region is implemented (i.e., only trust0 > 0 is supported)\n\n Returns:\n The step with ``shape=(n,)``, the expected improvement with ``shape=()``,\n a boolean indicating whether the damping factor was adjusted, and the damping\n factor with ``shape=(1,)``.\n \"\"\"\n from scipy import optimize\n\n eigenvalues, _ = torch.linalg.eigh(hessian)\n eigenvalue_smallest = eigenvalues.min()\n\n if eigenvalue_smallest < config.min_eigenvalue:\n # Mix in SD step if Hessian minimum eigenvalue is negative - experimental.\n adjacency = (\n max(config.min_eigenvalue, 0.01 * abs(eigenvalue_smallest))\n - eigenvalue_smallest\n )\n\n _LOGGER.info(\n f\"hessian has a small or negative eigenvalue ({eigenvalue_smallest:.1e}), \"\n f\"mixing in some steepest descent ({adjacency:.1e}) to correct this.\"\n )\n hessian += adjacency * torch.eye(\n hessian.shape[0], device=hessian.device, dtype=hessian.dtype\n )\n\n damping_factor = torch.tensor(1.0)\n\n dx, improvement = _solver(damping_factor, gradient, hessian)\n dx_norm = torch.linalg.norm(dx)\n\n adjust_damping = bool(dx_norm > trust_radius)\n\n if adjust_damping:\n # LPW tried a few optimizers and found Brent works well, but also that the\n # tolerance is fractional - if the optimized value is zero it takes a lot of\n # meaningless steps.\n damping_factor = optimize.brent(\n _damping_factor_loss_fn,\n (\n gradient.detach().cpu(),\n hessian.detach().cpu(),\n trust_radius.detach().cpu(),\n ),\n brack=(config.min_damping_factor, config.min_damping_factor * 4),\n tol=1.0e-6 if config.mode.lower() == _ADAPTIVE else 1.0e-4,\n )\n\n dx, improvement = _solver(damping_factor, gradient, hessian)\n\n return dx, improvement, adjust_damping, damping_factor" }, { "id": 6997, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n if ODhat.numel() == 0:\n raise FullyTransparentException(\"ODhat is empty\")\n\n # compute eigenvectors\n try:\n _, eigvecs = torch.linalg.eigh(cov(ODhat.T))\n except Exception as e:\n if \"LinAlgError\" in e.__class__.__name__: # should be torch._C._LinalgError but that's not exposed\n raise FullyTransparentException(\"could not compute eigenvectors\")\n raise e\n eigvecs = eigvecs[:, [1, 2]]\n\n HE = self.__find_HE(ODhat, eigvecs, alpha)\n\n C = self.__find_concentration(OD, HE)\n maxC = torch.stack([percentile(C[0, :], 99), percentile(C[1, :], 99)])\n\n return HE, C, maxC", "probing input": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n if ODhat.numel() == 0:\n raise FullyTransparentException(\"ODhat is empty\")\n\n # compute eigenvectors\n try:\n", "probing input new": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n if ODhat.numel() == 0:\n raise FullyTransparentException(\"ODhat is empty\")\n\n # compute eigenvectors\n try:\n _, eigvecs = torch.", "reference": "_,eigvecs=torch.linalg.eigh(cov(ODhat.T))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,eigvecs=torch.linalg.eigh(cov(ODhat.T))", "y_neg": " _, eigvecs = torch.symeig(ODhat, eigenvectors=True)", "retain": " def __compute_matrices(self, I, Io, alpha, beta):\n OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta)\n\n if ODhat.numel() == 0:\n raise FullyTransparentException(\"ODhat is empty\")\n\n # compute eigenvectors\n try:\n _, eigvecs = torch.linalg.eigh(cov(ODhat.T))\n except Exception as e:\n if \"LinAlgError\" in e.__class__.__name__: # should be torch._C._LinalgError but that's not exposed\n raise FullyTransparentException(\"could not compute eigenvectors\")\n raise e\n eigvecs = eigvecs[:, [1, 2]]\n\n HE = self.__find_HE(ODhat, eigvecs, alpha)\n\n C = self.__find_concentration(OD, HE)\n maxC = torch.stack([percentile(C[0, :], 99), percentile(C[1, :], 99)])\n\n return HE, C, maxC" }, { "id": 7004, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _extract_shape(idx, x, j, cur_center):\n _a = []\n for i in range(len(idx)):\n if idx[i] == j:\n if torch.sum(cur_center)==0:\n opt_x = x[i]\n else:\n opt_x = _sbd(cur_center, x[i])\n _a.append(opt_x)\n \n if len(_a) == 0:\n indices = torch.randperm(x.shape[0])[:1]\n return torch.squeeze(x[indices].clone())\n #return torch.zeros((x.shape[1]))\n\n a = torch.stack(_a)\n \n columns = a.shape[1]\n y = zscore(a, axis=1, ddof=1)\n \n s = y[:, :, 0].transpose(0, 1).mm(y[:, :, 0])\n\n p = torch.empty((columns, columns), device=\"cuda\", dtype=torch.float32)\n p.fill_(1.0 / columns)\n p = torch.eye(columns, device=\"cuda\", dtype=torch.float32) - p\n\n m = p.mm(s).mm(p)\n _, vec = torch.linalg.eigh(m,UPLO='U')\n centroid = vec[:, -1]\n\n finddistance1 = torch.norm(a.sub(centroid.reshape((x.shape[1], 1))), 2, dim=(1, 2)).sum()\n finddistance2 = torch.norm(a.add(centroid.reshape((x.shape[1], 1))), 2, dim=(1, 2)).sum()\n\n if finddistance1 >= finddistance2:\n centroid.mul_(-1)\n\n return zscore(centroid, ddof=1)", "probing input": "def _extract_shape(idx, x, j, cur_center):\n _a = []\n for i in range(len(idx)):\n if idx[i] == j:\n if torch.sum(cur_center)==0:\n opt_x = x[i]\n else:\n opt_x = _sbd(cur_center, x[i])\n _a.append(opt_x)\n \n if len(_a) == 0:\n indices = torch.randperm(x.shape[0])[:1]\n return torch.squeeze(x[indices].clone())\n #return torch.zeros((x.shape[1]))\n\n a = torch.stack(_a)\n \n columns = a.shape[1]\n y = zscore(a, axis=1, ddof=1)\n \n s = y[:, :, 0].transpose(0, 1).mm(y[:, :, 0])\n\n p = torch.empty((columns, columns), device=\"cuda\", dtype=torch.float32)\n p.fill_(1.0 / columns)\n p = torch.eye(columns, device=\"cuda\", dtype=torch.float32) - p\n\n m = p.mm(s).mm(p)\n", "probing input new": "def _extract_shape(idx, x, j, cur_center):\n _a = []\n for i in range(len(idx)):\n if idx[i] == j:\n if torch.sum(cur_center)==0:\n opt_x = x[i]\n else:\n opt_x = _sbd(cur_center, x[i])\n _a.append(opt_x)\n \n if len(_a) == 0:\n indices = torch.randperm(x.shape[0])[:1]\n return torch.squeeze(x[indices].clone())\n #return torch.zeros((x.shape[1]))\n\n a = torch.stack(_a)\n \n columns = a.shape[1]\n y = zscore(a, axis=1, ddof=1)\n \n s = y[:, :, 0].transpose(0, 1).mm(y[:, :, 0])\n\n p = torch.empty((columns, columns), device=\"cuda\", dtype=torch.float32)\n p.fill_(1.0 / columns)\n p = torch.eye(columns, device=\"cuda\", dtype=torch.float32) - p\n\n m = p.mm(s).mm(p)\n _, vec = torch.", "reference": "_,vec=torch.linalg.eigh(m,UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "_,vec=torch.linalg.eigh(m,UPLO='U')", "y_neg": " _, vec = torch.symeig(m, eigenvectors=True)", "retain": "def _extract_shape(idx, x, j, cur_center):\n _a = []\n for i in range(len(idx)):\n if idx[i] == j:\n if torch.sum(cur_center)==0:\n opt_x = x[i]\n else:\n opt_x = _sbd(cur_center, x[i])\n _a.append(opt_x)\n \n if len(_a) == 0:\n indices = torch.randperm(x.shape[0])[:1]\n return torch.squeeze(x[indices].clone())\n #return torch.zeros((x.shape[1]))\n\n a = torch.stack(_a)\n \n columns = a.shape[1]\n y = zscore(a, axis=1, ddof=1)\n \n s = y[:, :, 0].transpose(0, 1).mm(y[:, :, 0])\n\n p = torch.empty((columns, columns), device=\"cuda\", dtype=torch.float32)\n p.fill_(1.0 / columns)\n p = torch.eye(columns, device=\"cuda\", dtype=torch.float32) - p\n\n m = p.mm(s).mm(p)\n _, vec = torch.linalg.eigh(m,UPLO='U')\n centroid = vec[:, -1]\n\n finddistance1 = torch.norm(a.sub(centroid.reshape((x.shape[1], 1))), 2, dim=(1, 2)).sum()\n finddistance2 = torch.norm(a.add(centroid.reshape((x.shape[1], 1))), 2, dim=(1, 2)).sum()\n\n if finddistance1 >= finddistance2:\n centroid.mul_(-1)\n\n return zscore(centroid, ddof=1)" }, { "id": 7005, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.linalg.eigh(L)\n return D, V", "probing input": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n", "probing input new": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.", "reference": "D,V=torch.linalg.eigh(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,V=torch.linalg.eigh(L)", "y_neg": " D, V = torch.symeig(L, eigenvectors=True)", "retain": "def EVD_Laplacian(data, norm=None):\n L_raw = get_laplacian(to_undirected(data.edge_index, num_nodes=data.num_nodes), \n normalization=norm, num_nodes=data.num_nodes)\n L = SparseTensor(row=L_raw[0][0], col=L_raw[0][1], value=L_raw[1], sparse_sizes=(data.num_nodes, data.num_nodes)).to_dense()\n\n D, V = torch.linalg.eigh(L)\n return D, V" }, { "id": 7007, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _fit(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute the principal components of the reference data.\n\n We compute the principal components of the reference data using the kernel matrix and then\n return the largest `n_components` eigenvectors. These are then normalized to have length\n equal to `1/eigenvalue`. Note that this differs from the linear case where we remove the\n largest eigenvectors.\n\n Parameters\n ----------\n x\n The reference data.\n\n Returns\n -------\n The principal components of the reference data.\n\n Raises\n ------\n ValueError\n If `n_components` is greater than or equal to the number of reference samples.\n \"\"\"\n if self.n_components >= x.shape[0]:\n raise ValueError(\"n_components must be less than the number of reference instances.\")\n\n self.x_ref = x\n K = self.compute_kernel_mat(x)\n D, V = torch.linalg.eigh(K)\n pcs = V / torch.sqrt(D)[None, :]\n return pcs[:, -self.n_components:]", "probing input": " def _fit(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute the principal components of the reference data.\n\n We compute the principal components of the reference data using the kernel matrix and then\n return the largest `n_components` eigenvectors. These are then normalized to have length\n equal to `1/eigenvalue`. Note that this differs from the linear case where we remove the\n largest eigenvectors.\n\n Parameters\n ----------\n x\n The reference data.\n\n Returns\n -------\n The principal components of the reference data.\n\n Raises\n ------\n ValueError\n If `n_components` is greater than or equal to the number of reference samples.\n \"\"\"\n if self.n_components >= x.shape[0]:\n raise ValueError(\"n_components must be less than the number of reference instances.\")\n\n self.x_ref = x\n K = self.compute_kernel_mat(x)\n", "probing input new": " def _fit(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute the principal components of the reference data.\n\n We compute the principal components of the reference data using the kernel matrix and then\n return the largest `n_components` eigenvectors. These are then normalized to have length\n equal to `1/eigenvalue`. Note that this differs from the linear case where we remove the\n largest eigenvectors.\n\n Parameters\n ----------\n x\n The reference data.\n\n Returns\n -------\n The principal components of the reference data.\n\n Raises\n ------\n ValueError\n If `n_components` is greater than or equal to the number of reference samples.\n \"\"\"\n if self.n_components >= x.shape[0]:\n raise ValueError(\"n_components must be less than the number of reference instances.\")\n\n self.x_ref = x\n K = self.compute_kernel_mat(x)\n D, V = torch.", "reference": "D,V=torch.linalg.eigh(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "D,V=torch.linalg.eigh(K)", "y_neg": " D, V = torch.symeig(K, eigenvectors=True)", "retain": " def _fit(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute the principal components of the reference data.\n\n We compute the principal components of the reference data using the kernel matrix and then\n return the largest `n_components` eigenvectors. These are then normalized to have length\n equal to `1/eigenvalue`. Note that this differs from the linear case where we remove the\n largest eigenvectors.\n\n Parameters\n ----------\n x\n The reference data.\n\n Returns\n -------\n The principal components of the reference data.\n\n Raises\n ------\n ValueError\n If `n_components` is greater than or equal to the number of reference samples.\n \"\"\"\n if self.n_components >= x.shape[0]:\n raise ValueError(\"n_components must be less than the number of reference instances.\")\n\n self.x_ref = x\n K = self.compute_kernel_mat(x)\n D, V = torch.linalg.eigh(K)\n pcs = V / torch.sqrt(D)[None, :]\n return pcs[:, -self.n_components:]" }, { "id": 7014, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterative_reweighted_ransac(points, pillars, w0, num_pillars, sigma2, stopping_delta=1e-2):\n \"\"\"\n Args:\n points.bxyz [N, 4]: (batch, x, y, z)\n pillars: dict()\n num_pillars: number of pillars\n w0 [N, 1]: per-point weight\n Returns:\n points.plane_fitting_error [N]: dist from point to the final plane\n \"\"\"\n assert len(w0.shape) == 2, \"w0 must be a two dimensional tensor\"\n w = w0\n point_xyz = points.bxyz[:, 1:4]\n for itr in range(50):\n center = segment_coo(\n point_xyz*w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n )\n weight_sum = segment_coo(\n w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n ) + 1e-6\n pillars.center = center / weight_sum\n\n point_d = point_xyz - pillars.center[points.pillar_idx]\n point_ddT = (w[:, :, None] * point_d[:, :, None]) * point_d[:, None, :]\n pillar_cov = segment_coo(\n point_ddT,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='mean'\n )\n\n S, Q = torch.linalg.eigh(pillar_cov)\n pillars.normal = Q[:, :, 0]\n points.plane_fitting_error = (point_d * pillars.normal[points.pillar_idx]).sum(-1).abs()\n new_w = (sigma2 / (points.plane_fitting_error.square() + sigma2)).reshape(-1)\n dist_w = (0.5**2)/(point_d.square().sum(dim=-1) + 0.5**2)\n new_w = (new_w * dist_w).reshape(-1, 1)\n delta_w = (new_w - w).abs()\n if delta_w.max() < stopping_delta:\n break\n w = new_w\n\n return points, pillars", "probing input": "def iterative_reweighted_ransac(points, pillars, w0, num_pillars, sigma2, stopping_delta=1e-2):\n \"\"\"\n Args:\n points.bxyz [N, 4]: (batch, x, y, z)\n pillars: dict()\n num_pillars: number of pillars\n w0 [N, 1]: per-point weight\n Returns:\n points.plane_fitting_error [N]: dist from point to the final plane\n \"\"\"\n assert len(w0.shape) == 2, \"w0 must be a two dimensional tensor\"\n w = w0\n point_xyz = points.bxyz[:, 1:4]\n for itr in range(50):\n center = segment_coo(\n point_xyz*w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n )\n weight_sum = segment_coo(\n w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n ) + 1e-6\n pillars.center = center / weight_sum\n\n point_d = point_xyz - pillars.center[points.pillar_idx]\n point_ddT = (w[:, :, None] * point_d[:, :, None]) * point_d[:, None, :]\n pillar_cov = segment_coo(\n point_ddT,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='mean'\n )\n\n", "probing input new": "def iterative_reweighted_ransac(points, pillars, w0, num_pillars, sigma2, stopping_delta=1e-2):\n \"\"\"\n Args:\n points.bxyz [N, 4]: (batch, x, y, z)\n pillars: dict()\n num_pillars: number of pillars\n w0 [N, 1]: per-point weight\n Returns:\n points.plane_fitting_error [N]: dist from point to the final plane\n \"\"\"\n assert len(w0.shape) == 2, \"w0 must be a two dimensional tensor\"\n w = w0\n point_xyz = points.bxyz[:, 1:4]\n for itr in range(50):\n center = segment_coo(\n point_xyz*w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n )\n weight_sum = segment_coo(\n w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n ) + 1e-6\n pillars.center = center / weight_sum\n\n point_d = point_xyz - pillars.center[points.pillar_idx]\n point_ddT = (w[:, :, None] * point_d[:, :, None]) * point_d[:, None, :]\n pillar_cov = segment_coo(\n point_ddT,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='mean'\n )\n\n S, Q = torch.", "reference": "S,Q=torch.linalg.eigh(pillar_cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "S,Q=torch.linalg.eigh(pillar_cov)", "y_neg": " S, Q = torch.symeig(pillar_cov, eigenvectors=True)", "retain": "def iterative_reweighted_ransac(points, pillars, w0, num_pillars, sigma2, stopping_delta=1e-2):\n \"\"\"\n Args:\n points.bxyz [N, 4]: (batch, x, y, z)\n pillars: dict()\n num_pillars: number of pillars\n w0 [N, 1]: per-point weight\n Returns:\n points.plane_fitting_error [N]: dist from point to the final plane\n \"\"\"\n assert len(w0.shape) == 2, \"w0 must be a two dimensional tensor\"\n w = w0\n point_xyz = points.bxyz[:, 1:4]\n for itr in range(50):\n center = segment_coo(\n point_xyz*w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n )\n weight_sum = segment_coo(\n w,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='sum'\n ) + 1e-6\n pillars.center = center / weight_sum\n\n point_d = point_xyz - pillars.center[points.pillar_idx]\n point_ddT = (w[:, :, None] * point_d[:, :, None]) * point_d[:, None, :]\n pillar_cov = segment_coo(\n point_ddT,\n points.pillar_idx,\n dim_size=num_pillars,\n reduce='mean'\n )\n\n S, Q = torch.linalg.eigh(pillar_cov)\n pillars.normal = Q[:, :, 0]\n points.plane_fitting_error = (point_d * pillars.normal[points.pillar_idx]).sum(-1).abs()\n new_w = (sigma2 / (points.plane_fitting_error.square() + sigma2)).reshape(-1)\n dist_w = (0.5**2)/(point_d.square().sum(dim=-1) + 0.5**2)\n new_w = (new_w * dist_w).reshape(-1, 1)\n delta_w = (new_w - w).abs()\n if delta_w.max() < stopping_delta:\n break\n w = new_w\n\n return points, pillars" }, { "id": 7016, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sym_eig_trunc(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(pack(x, nheavyatom, nH), UPLO='U')\n e = torch.zeros((x.shape[0]),dtype=dtype,device=device)\n e[:(nheavyatom*4+nH)] = e0\n else:#need to add large diagonal values to replace 0 padding\n #Gershgorin circle theorem estimate upper bounds of eigenvalues\n x0 = pack(x, nheavyatom, nH)\n nmol, size, _ = x0.shape\n\n aii = x0.diagonal(dim1=1,dim2=2)\n ri = torch.sum(torch.abs(x0),dim=2)-torch.abs(aii)\n hN = torch.max(aii+ri,dim=1)[0]\n dE = hN - torch.min(aii-ri,dim=1)[0] #(maximal - minimal) get range\n\n norb = nheavyatom*4+nH\n pnorb = size - norb\n nn = torch.max(pnorb).item()\n dx = 0.005\n mutipler = torch.arange(1.0+dx, 1.0+nn*dx+dx, dx, dtype=dtype, device=device)[:nn]\n ind = torch.arange(size, dtype=torch.int64, device=device)\n cond = pnorb>0\n for i in range(nmol):\n if cond[i]:\n x0[i,ind[norb[i]:], ind[norb[i]:]] = mutipler[:pnorb[i]]*dE[i]+hN[i]\n try:\n # e0,v = torch.symeig(x0,eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(x0, UPLO='U')\n except:\n if torch.isnan(x0).any():\n print(x0)\n #print(x0.detach().data.numpy())\n # e0,v = torch.symeig(x0,eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(x0, UPLO='U')\n e = torch.zeros((nmol, x.shape[-1]),dtype=dtype,device=device)\n e[...,:size] = e0\n for i in range(nmol):\n if cond[i]:\n e[i,norb[i]:size] = 0.0\n\n if eig_only:\n return e, v\n\n # each column of v is a eigenvectors\n # P_alpha_beta = 2.0 * |sum_i c_{i,alpha}*c_{i,beta}, i \\in occupied MO\n if x.dim()==2:\n if CHECK_DEGENERACY:\n t = construct_P(e, v, nocc)\n else:\n t = 2.0*torch.matmul(v[:,:nocc], v[:,:nocc].transpose(0,1))\n else:\n \"\"\"\n t = torch.zeros_like(v)\n for i in range(v.shape[0]):\n t[i] = torch.matmul(v[i,:,:nocc[i]], v[i, :,:nocc[i]].transpose(0,1))\n\n t*=2.0\n \"\"\"\n if CHECK_DEGENERACY:\n t = torch.stack(list(map(lambda a,b,n : construct_P(a, b, n), e, v, nocc)))\n else:\n #list(map(lambda a,n : print('norm', torch.norm(v, dim=0), n), v, nocc))\n #print(torch.norm())\n t = 2.0*torch.stack(list(map(lambda a,n : torch.matmul(a[:,:n], a[:,:n].transpose(0,1)), v, nocc)))\n P = unpack(t, nheavyatom, nH, x.shape[-1])\n\n return e,P, v", "probing input": "def sym_eig_trunc(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n", "probing input new": "def sym_eig_trunc(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.", "reference": "e0,v=torch.linalg.eigh(pack(x,nheavyatom,nH),UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e0,v=torch.linalg.eigh(pack(x,nheavyatom,nH),UPLO='U')", "y_neg": " e0, v = torch.symeig(x,eigenvectors=True,upper=True)", "retain": "def sym_eig_trunc(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(pack(x, nheavyatom, nH), UPLO='U')\n e = torch.zeros((x.shape[0]),dtype=dtype,device=device)\n e[:(nheavyatom*4+nH)] = e0\n else:#need to add large diagonal values to replace 0 padding\n #Gershgorin circle theorem estimate upper bounds of eigenvalues\n x0 = pack(x, nheavyatom, nH)\n nmol, size, _ = x0.shape\n\n aii = x0.diagonal(dim1=1,dim2=2)\n ri = torch.sum(torch.abs(x0),dim=2)-torch.abs(aii)\n hN = torch.max(aii+ri,dim=1)[0]\n dE = hN - torch.min(aii-ri,dim=1)[0] #(maximal - minimal) get range\n\n norb = nheavyatom*4+nH\n pnorb = size - norb\n nn = torch.max(pnorb).item()\n dx = 0.005\n mutipler = torch.arange(1.0+dx, 1.0+nn*dx+dx, dx, dtype=dtype, device=device)[:nn]\n ind = torch.arange(size, dtype=torch.int64, device=device)\n cond = pnorb>0\n for i in range(nmol):\n if cond[i]:\n x0[i,ind[norb[i]:], ind[norb[i]:]] = mutipler[:pnorb[i]]*dE[i]+hN[i]\n try:\n # e0,v = torch.symeig(x0,eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(x0, UPLO='U')\n except:\n if torch.isnan(x0).any():\n print(x0)\n #print(x0.detach().data.numpy())\n # e0,v = torch.symeig(x0,eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(x0, UPLO='U')\n e = torch.zeros((nmol, x.shape[-1]),dtype=dtype,device=device)\n e[...,:size] = e0\n for i in range(nmol):\n if cond[i]:\n e[i,norb[i]:size] = 0.0\n\n if eig_only:\n return e, v\n\n # each column of v is a eigenvectors\n # P_alpha_beta = 2.0 * |sum_i c_{i,alpha}*c_{i,beta}, i \\in occupied MO\n if x.dim()==2:\n if CHECK_DEGENERACY:\n t = construct_P(e, v, nocc)\n else:\n t = 2.0*torch.matmul(v[:,:nocc], v[:,:nocc].transpose(0,1))\n else:\n \"\"\"\n t = torch.zeros_like(v)\n for i in range(v.shape[0]):\n t[i] = torch.matmul(v[i,:,:nocc[i]], v[i, :,:nocc[i]].transpose(0,1))\n\n t*=2.0\n \"\"\"\n if CHECK_DEGENERACY:\n t = torch.stack(list(map(lambda a,b,n : construct_P(a, b, n), e, v, nocc)))\n else:\n #list(map(lambda a,n : print('norm', torch.norm(v, dim=0), n), v, nocc))\n #print(torch.norm())\n t = 2.0*torch.stack(list(map(lambda a,n : torch.matmul(a[:,:n], a[:,:n].transpose(0,1)), v, nocc)))\n P = unpack(t, nheavyatom, nH, x.shape[-1])\n\n return e,P, v" }, { "id": 7017, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sym_eig_trunc1(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(pack(x, nheavyatom, nH), UPLO='U')\n e = torch.zeros((x.shape[0]),dtype=dtype,device=device)\n e[:(nheavyatom*4+nH)] = e0\n else:#need to add large diagonal values to replace 0 padding\n #Gershgorin circle theorem estimate upper bounds of eigenvalues\n\n # e0, v0 = list(zip(*list(map(\n # lambda a,b,c: torch.symeig(pack(a,b,c),eigenvectors=True,upper=True),\n # x,nheavyatom, nH))))\n e0, v0 = list(zip(*list(map(\n lambda a,b,c: torch.linalg.eigh(pack(a,b,c), UPLO='U'),\n x,nheavyatom, nH))))\n if CHECK_DEGENERACY:\n P0 = list(map(\n lambda e, v, nc : construct_P(e,v,nc),\n e0, v0,nocc))\n else:\n P0 = list(map(\n lambda v, nc : 2.0*torch.matmul(v[:,:nc], v[:,:nc].transpose(0,1)),\n v0,nocc))\n #\n nmol = x.shape[0]\n norb = nheavyatom*4+nH\n e=torch.zeros(x.shape[:2], dtype=dtype, device=device)\n P = torch.zeros_like(x)\n for i in range(nmol):\n e[i,:norb[i]] = e0[i]\n P[i] = unpack(P0[i], nheavyatom[i], nH[i], x.shape[-1])\n\n if eig_only:\n return e, v0\n\n # each column of v is a eigenvectors\n # P_alpha_beta = 2.0 * |sum_i c_{i,alpha}*c_{i,beta}, i \\in occupied MO\n\n return e,P, v0", "probing input": "def sym_eig_trunc1(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n", "probing input new": "def sym_eig_trunc1(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.", "reference": "e0,v=torch.linalg.eigh(pack(x,nheavyatom,nH),UPLO='U')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.symeig" ], "replacement api": "torch.linalg.eigh", "expected call": "torch.linalg.eigh", "y_pos": "e0,v=torch.linalg.eigh(pack(x,nheavyatom,nH),UPLO='U')", "y_neg": " e0, v = torch.symeig(x,eigenvectors=True,upper=True)", "retain": "def sym_eig_trunc1(x,nheavyatom,nH,nocc, eig_only=False):\n\n dtype = x.dtype\n device = x.device\n if x.dim()==2:\n # e0,v = torch.symeig(pack(x, nheavyatom, nH),eigenvectors=True,upper=True)\n e0, v = torch.linalg.eigh(pack(x, nheavyatom, nH), UPLO='U')\n e = torch.zeros((x.shape[0]),dtype=dtype,device=device)\n e[:(nheavyatom*4+nH)] = e0\n else:#need to add large diagonal values to replace 0 padding\n #Gershgorin circle theorem estimate upper bounds of eigenvalues\n\n # e0, v0 = list(zip(*list(map(\n # lambda a,b,c: torch.symeig(pack(a,b,c),eigenvectors=True,upper=True),\n # x,nheavyatom, nH))))\n e0, v0 = list(zip(*list(map(\n lambda a,b,c: torch.linalg.eigh(pack(a,b,c), UPLO='U'),\n x,nheavyatom, nH))))\n if CHECK_DEGENERACY:\n P0 = list(map(\n lambda e, v, nc : construct_P(e,v,nc),\n e0, v0,nocc))\n else:\n P0 = list(map(\n lambda v, nc : 2.0*torch.matmul(v[:,:nc], v[:,:nc].transpose(0,1)),\n v0,nocc))\n #\n nmol = x.shape[0]\n norb = nheavyatom*4+nH\n e=torch.zeros(x.shape[:2], dtype=dtype, device=device)\n P = torch.zeros_like(x)\n for i in range(nmol):\n e[i,:norb[i]] = e0[i]\n P[i] = unpack(P0[i], nheavyatom[i], nH[i], x.shape[-1])\n\n if eig_only:\n return e, v0\n\n # each column of v is a eigenvectors\n # P_alpha_beta = 2.0 * |sum_i c_{i,alpha}*c_{i,beta}, i \\in occupied MO\n\n return e,P, v0" }, { "id": 7022, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7025, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.to(dtype=torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.to(dtype=torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if(quats is not None and normalize_quats):\n", "probing input new": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.to(dtype=torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.to(dtype=torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7028, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max([torch.linalg.norm(_vec) for _vec in\n [a, b, c, a + b, b + c, a + c, a + b + c]])\n # This sphere should be within shape_min in each direction\n # Therefore shape_min >= Rmax * (R^-1 or G^-1)\n shape_min = (Rmax * (torch.linalg.inv(basis).norm(dim=0)))\n shape_min = torch.ceil(shape_min)\n iGridX = np.arange(-shape_min[0], shape_min[0] + 1)\n iGridY = np.arange(-shape_min[1], shape_min[1] + 1)\n iGridZ = np.arange(-shape_min[2], shape_min[2] + 1)\n # Reduce grid for any orthogonal basis vector\n if np.dot(a, b) == 0 == np.dot(a, c):\n iGridX = np.arange(-1., 2.)\n if np.dot(b, a) == 0 == np.dot(b, c):\n iGridY = np.arange(-1., 2.)\n if np.dot(c, a) == 0 == np.dot(c, b):\n iGridZ = np.arange(-1., 2.)\n iGrid = np.array([x.flatten() for x in np.meshgrid(iGridX, iGridY, iGridZ)]).T\n iGrid = iGrid[np.where((iGrid ** 2).sum(axis=1) > 0)[0]] # eliminate origin\n return torch.tensor(iGrid), torch.tensor(iGrid) @ basis.T", "probing input": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n", "probing input new": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max([torch.", "reference": "Rmax=np.max([torch.linalg.norm(_vec)for_vecin[a,b,c,a+b,b+c,a+c,a+b+c]])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "Rmax=np.max([torch.linalg.norm(_vec)for_vecin[a,b,c,a+b,b+c,a+c,a+b+c]])", "y_neg": " Rmax = np.max([torch.norm(a), torch.norm(b), torch.norm(c)])", "retain": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max([torch.linalg.norm(_vec) for _vec in\n [a, b, c, a + b, b + c, a + c, a + b + c]])\n # This sphere should be within shape_min in each direction\n # Therefore shape_min >= Rmax * (R^-1 or G^-1)\n shape_min = (Rmax * (torch.linalg.inv(basis).norm(dim=0)))\n shape_min = torch.ceil(shape_min)\n iGridX = np.arange(-shape_min[0], shape_min[0] + 1)\n iGridY = np.arange(-shape_min[1], shape_min[1] + 1)\n iGridZ = np.arange(-shape_min[2], shape_min[2] + 1)\n # Reduce grid for any orthogonal basis vector\n if np.dot(a, b) == 0 == np.dot(a, c):\n iGridX = np.arange(-1., 2.)\n if np.dot(b, a) == 0 == np.dot(b, c):\n iGridY = np.arange(-1., 2.)\n if np.dot(c, a) == 0 == np.dot(c, b):\n iGridZ = np.arange(-1., 2.)\n iGrid = np.array([x.flatten() for x in np.meshgrid(iGridX, iGridY, iGridZ)]).T\n iGrid = iGrid[np.where((iGrid ** 2).sum(axis=1) > 0)[0]] # eliminate origin\n return torch.tensor(iGrid), torch.tensor(iGrid) @ basis.T" }, { "id": 7029, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def axis_angle_from_quat(quat, eps=1.0e-6):\n \"\"\"Convert tensor of quaternions to tensor of axis-angles.\"\"\"\n # Reference: https://github.com/facebookresearch/pytorch3d/blob/bee31c48d3d36a8ea268f9835663c52ff4a476ec/pytorch3d/transforms/rotation_conversions.py#L516-L544\n\n mag = torch.linalg.norm(quat[:, 1:4], dim=1)\n half_angle = torch.atan2(mag, quat[:, 0])\n angle = 2.0 * half_angle\n sin_half_angle_over_angle = torch.where(\n torch.abs(angle) > eps, torch.sin(half_angle) / angle, 1 / 2 - angle**2.0 / 48\n )\n axis_angle = quat[:, 1:4] / sin_half_angle_over_angle.unsqueeze(-1)\n\n return axis_angle", "probing input": "def axis_angle_from_quat(quat, eps=1.0e-6):\n \"\"\"Convert tensor of quaternions to tensor of axis-angles.\"\"\"\n # Reference: https://github.com/facebookresearch/pytorch3d/blob/bee31c48d3d36a8ea268f9835663c52ff4a476ec/pytorch3d/transforms/rotation_conversions.py#L516-L544\n\n", "probing input new": "def axis_angle_from_quat(quat, eps=1.0e-6):\n \"\"\"Convert tensor of quaternions to tensor of axis-angles.\"\"\"\n # Reference: https://github.com/facebookresearch/pytorch3d/blob/bee31c48d3d36a8ea268f9835663c52ff4a476ec/pytorch3d/transforms/rotation_conversions.py#L516-L544\n\n mag = torch.", "reference": "mag=torch.linalg.norm(quat[:,1:4],dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(quat[:,1:4],dim=1)", "y_neg": " mag = torch.norm(quat, p=2, dim=-1, keepdim=True)", "retain": "def axis_angle_from_quat(quat, eps=1.0e-6):\n \"\"\"Convert tensor of quaternions to tensor of axis-angles.\"\"\"\n # Reference: https://github.com/facebookresearch/pytorch3d/blob/bee31c48d3d36a8ea268f9835663c52ff4a476ec/pytorch3d/transforms/rotation_conversions.py#L516-L544\n\n mag = torch.linalg.norm(quat[:, 1:4], dim=1)\n half_angle = torch.atan2(mag, quat[:, 0])\n angle = 2.0 * half_angle\n sin_half_angle_over_angle = torch.where(\n torch.abs(angle) > eps, torch.sin(half_angle) / angle, 1 / 2 - angle**2.0 / 48\n )\n axis_angle = quat[:, 1:4] / sin_half_angle_over_angle.unsqueeze(-1)\n\n return axis_angle" }, { "id": 7031, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_weight_map(\n rays,\n jitter_rays,\n cfg,\n weights=None,\n softmax=True\n):\n ray_dim = rays.shape[-1] // 2\n\n # Angles\n angles = torch.acos(\n torch.clip(\n dot(rays[..., ray_dim:], jitter_rays[..., ray_dim:]),\n -1 + 1e-8, 1 - 1e-8\n )\n ).detach()\n\n # Distances\n dists = torch.linalg.norm(\n rays[..., :ray_dim] - jitter_rays[..., :ray_dim],\n dim=-1\n ).detach()\n\n # Weights\n if weights is None:\n weights = torch.zeros_like(angles)\n\n if softmax:\n weights = torch.nn.functional.softmax(\n 0.5 * -(torch.square(angles / cfg.angle_std) + torch.square(dists / cfg.dist_std)) + weights, dim=0\n )[..., None]\n else:\n #print(\"Angle:\", angles.max(), angles.mean(), cfg.angle_std)\n #print(\"Dist:\", dists.max(), dists.mean(), cfg.dist_std)\n\n weights = torch.exp(\n 0.5 * -(torch.square(angles / cfg.angle_std) + torch.square(dists / cfg.dist_std)) + weights\n )[..., None]\n\n # Normalization constant\n constant = np.power(2 * np.pi * cfg.angle_std * cfg.angle_std, -1.0 / 2.0) \\\n * np.power(2 * np.pi * cfg.dist_std * cfg.dist_std, -1.0 / 2.0)\n\n return weights / constant", "probing input": "def get_weight_map(\n rays,\n jitter_rays,\n cfg,\n weights=None,\n softmax=True\n):\n ray_dim = rays.shape[-1] // 2\n\n # Angles\n angles = torch.acos(\n torch.clip(\n dot(rays[..., ray_dim:], jitter_rays[..., ray_dim:]),\n -1 + 1e-8, 1 - 1e-8\n )\n ).detach()\n\n # Distances\n", "probing input new": "def get_weight_map(\n rays,\n jitter_rays,\n cfg,\n weights=None,\n softmax=True\n):\n ray_dim = rays.shape[-1] // 2\n\n # Angles\n angles = torch.acos(\n torch.clip(\n dot(rays[..., ray_dim:], jitter_rays[..., ray_dim:]),\n -1 + 1e-8, 1 - 1e-8\n )\n ).detach()\n\n # Distances\n dists = torch.", "reference": "dists=torch.linalg.norm(rays[...,:ray_dim]-jitter_rays[...,:ray_dim],dim=-1).detach()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dists=torch.linalg.norm(rays[...,:ray_dim]-jitter_rays[...,:ray_dim],dim=-1).detach()", "y_neg": " dists = torch.norm(", "retain": "def get_weight_map(\n rays,\n jitter_rays,\n cfg,\n weights=None,\n softmax=True\n):\n ray_dim = rays.shape[-1] // 2\n\n # Angles\n angles = torch.acos(\n torch.clip(\n dot(rays[..., ray_dim:], jitter_rays[..., ray_dim:]),\n -1 + 1e-8, 1 - 1e-8\n )\n ).detach()\n\n # Distances\n dists = torch.linalg.norm(\n rays[..., :ray_dim] - jitter_rays[..., :ray_dim],\n dim=-1\n ).detach()\n\n # Weights\n if weights is None:\n weights = torch.zeros_like(angles)\n\n if softmax:\n weights = torch.nn.functional.softmax(\n 0.5 * -(torch.square(angles / cfg.angle_std) + torch.square(dists / cfg.dist_std)) + weights, dim=0\n )[..., None]\n else:\n #print(\"Angle:\", angles.max(), angles.mean(), cfg.angle_std)\n #print(\"Dist:\", dists.max(), dists.mean(), cfg.dist_std)\n\n weights = torch.exp(\n 0.5 * -(torch.square(angles / cfg.angle_std) + torch.square(dists / cfg.dist_std)) + weights\n )[..., None]\n\n # Normalization constant\n constant = np.power(2 * np.pi * cfg.angle_std * cfg.angle_std, -1.0 / 2.0) \\\n * np.power(2 * np.pi * cfg.dist_std * cfg.dist_std, -1.0 / 2.0)\n\n return weights / constant" }, { "id": 7040, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def so3exp(self, phi):\n angle = torch.linalg.norm(phi)\n # Near phi==0, use first order Taylor expansion\n if torch.abs(angle) < 1e-8:\n skew_phi = self.skew(phi)\n return self.Id3 + skew_phi\n axis = phi / angle\n skew_axis = self.skew(axis)\n s = torch.sin(angle)\n c = torch.cos(angle)\n return c * self.Id3 + (1 - c) * torch.outer(axis, axis) + s * skew_axis", "probing input": " def so3exp(self, phi):\n", "probing input new": " def so3exp(self, phi):\n angle = torch.", "reference": "angle=torch.linalg.norm(phi)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "angle=torch.linalg.norm(phi)", "y_neg": " angle = torch.norm(phi, p=2, dim=-1, keepdim=True)", "retain": " def so3exp(self, phi):\n angle = torch.linalg.norm(phi)\n # Near phi==0, use first order Taylor expansion\n if torch.abs(angle) < 1e-8:\n skew_phi = self.skew(phi)\n return self.Id3 + skew_phi\n axis = phi / angle\n skew_axis = self.skew(axis)\n s = torch.sin(angle)\n c = torch.cos(angle)\n return c * self.Id3 + (1 - c) * torch.outer(axis, axis) + s * skew_axis" }, { "id": 7043, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute(self, simulation_output: SimulationOutputCLE) -> torch.Tensor:\n # calculate the speed error between simulated and recorded ego over the course of the simulation.\n simulated_centroid = simulation_output.simulated_ego_states[:, :2]\n simulated_velocity = simulated_centroid[1:] - simulated_centroid[:-1]\n simulated_speed = torch.linalg.norm(simulated_velocity, dim=1)\n\n recorded_centroid = simulation_output.recorded_ego_states[:, :2]\n recorded_velocity = recorded_centroid[1:] - recorded_centroid[:-1]\n recorded_speed = torch.linalg.norm(recorded_velocity, dim=1)\n\n # TODO: Replace 10 by (1 / step_time)\n return (simulated_speed - recorded_speed) * 10", "probing input": " def compute(self, simulation_output: SimulationOutputCLE) -> torch.Tensor:\n # calculate the speed error between simulated and recorded ego over the course of the simulation.\n simulated_centroid = simulation_output.simulated_ego_states[:, :2]\n simulated_velocity = simulated_centroid[1:] - simulated_centroid[:-1]\n", "probing input new": " def compute(self, simulation_output: SimulationOutputCLE) -> torch.Tensor:\n # calculate the speed error between simulated and recorded ego over the course of the simulation.\n simulated_centroid = simulation_output.simulated_ego_states[:, :2]\n simulated_velocity = simulated_centroid[1:] - simulated_centroid[:-1]\n simulated_speed = torch.", "reference": "simulated_speed=torch.linalg.norm(simulated_velocity,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "simulated_speed=torch.linalg.norm(simulated_velocity,dim=1)", "y_neg": " simulated_speed = torch.norm(simulated_velocity, p=2, dim=-1)", "retain": " def compute(self, simulation_output: SimulationOutputCLE) -> torch.Tensor:\n # calculate the speed error between simulated and recorded ego over the course of the simulation.\n simulated_centroid = simulation_output.simulated_ego_states[:, :2]\n simulated_velocity = simulated_centroid[1:] - simulated_centroid[:-1]\n simulated_speed = torch.linalg.norm(simulated_velocity, dim=1)\n\n recorded_centroid = simulation_output.recorded_ego_states[:, :2]\n recorded_velocity = recorded_centroid[1:] - recorded_centroid[:-1]\n recorded_speed = torch.linalg.norm(recorded_velocity, dim=1)\n\n # TODO: Replace 10 by (1 / step_time)\n return (simulated_speed - recorded_speed) * 10" }, { "id": 7046, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def calc_accel(preds, target):\n \"\"\"\n Mean joint acceleration error\n often referred to as \"Protocol #1\" in many papers.\n \"\"\"\n assert preds.shape == target.shape, print(preds.shape,\n target.shape) # BxJx3\n assert preds.dim() == 3\n # Expects BxJx3\n # valid_mask = torch.BoolTensor(target[:, :, 0].shape)\n accel_gt = target[:-2] - 2 * target[1:-1] + target[2:]\n accel_pred = preds[:-2] - 2 * preds[1:-1] + preds[2:]\n normed = torch.linalg.norm(accel_pred - accel_gt, dim=-1)\n accel_seq = normed.mean(1)\n return accel_seq", "probing input": "def calc_accel(preds, target):\n \"\"\"\n Mean joint acceleration error\n often referred to as \"Protocol #1\" in many papers.\n \"\"\"\n assert preds.shape == target.shape, print(preds.shape,\n target.shape) # BxJx3\n assert preds.dim() == 3\n # Expects BxJx3\n # valid_mask = torch.BoolTensor(target[:, :, 0].shape)\n accel_gt = target[:-2] - 2 * target[1:-1] + target[2:]\n accel_pred = preds[:-2] - 2 * preds[1:-1] + preds[2:]\n", "probing input new": "def calc_accel(preds, target):\n \"\"\"\n Mean joint acceleration error\n often referred to as \"Protocol #1\" in many papers.\n \"\"\"\n assert preds.shape == target.shape, print(preds.shape,\n target.shape) # BxJx3\n assert preds.dim() == 3\n # Expects BxJx3\n # valid_mask = torch.BoolTensor(target[:, :, 0].shape)\n accel_gt = target[:-2] - 2 * target[1:-1] + target[2:]\n accel_pred = preds[:-2] - 2 * preds[1:-1] + preds[2:]\n ", "reference": "normed=torch.linalg.norm(accel_pred-accel_gt,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "linalg.qr": "torch.linalg.qr", "linalg.lu_factor": "torch.linalg.lu_factor", "linalg.matrix_rank": "torch.linalg.matrix_rank", "linalg.eigh": "torch.linalg.eigh", "linalg.svd": "torch.linalg.svd", "linalg.lu_solve": "torch.linalg.lu_solve", "linalg.multi_dot": "torch.linalg.multi_dot", "linalg.solve": "torch.linalg.solve", "linalg.eig": "torch.linalg.eig", "linalg.cholesky": "torch.linalg.cholesky", "linalg.norm": "torch.linalg.norm", "linalg.lstsq": "torch.linalg.lstsq", "linalg.solve_triangular": "torch.linalg.solve_triangular" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "normed=torch.linalg.norm(accel_pred-accel_gt,dim=-1)", "y_neg": " accel_error = torch.norm(accel_gt - accel_pred, p='fro', dim=-1)", "retain": "def calc_accel(preds, target):\n \"\"\"\n Mean joint acceleration error\n often referred to as \"Protocol #1\" in many papers.\n \"\"\"\n assert preds.shape == target.shape, print(preds.shape,\n target.shape) # BxJx3\n assert preds.dim() == 3\n # Expects BxJx3\n # valid_mask = torch.BoolTensor(target[:, :, 0].shape)\n accel_gt = target[:-2] - 2 * target[1:-1] + target[2:]\n accel_pred = preds[:-2] - 2 * preds[1:-1] + preds[2:]\n normed = torch.linalg.norm(accel_pred - accel_gt, dim=-1)\n accel_seq = normed.mean(1)\n return accel_seq" }, { "id": 7048, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.linalg.norm(w,dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w/theta\n tan = torch.tan(0.5*theta)\n\n t = T[:,:3,3]\n wnorm_x_t = torch.cross(w_norm,t)\n V_inv_t = t - (0.5 * t) * wnorm_x_t + (1.0 - theta/(2.0*tan)) * torch.cross(w_norm, wnorm_x_t)\n xi = torch.cat((w, V_inv_t),dim=-1)\n\n return xi", "probing input": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n", "probing input new": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.", "reference": "theta=torch.linalg.norm(w,dim=(1))", "reference dict": { "w": "SO3_logmap" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(w,dim=(1))", "y_neg": " theta = torch.log(torch.norm(T[:,:3,:3]) + eps)", "retain": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.linalg.norm(w,dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w/theta\n tan = torch.tan(0.5*theta)\n\n t = T[:,:3,3]\n wnorm_x_t = torch.cross(w_norm,t)\n V_inv_t = t - (0.5 * t) * wnorm_x_t + (1.0 - theta/(2.0*tan)) * torch.cross(w_norm, wnorm_x_t)\n xi = torch.cat((w, V_inv_t),dim=-1)\n\n return xi" }, { "id": 7049, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if ((rot_mats is None and quats is None) or\n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if ((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or\n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if (quats is not None):\n quats = quats.to(dtype=torch.float32)\n if (rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if (quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if ((rot_mats is None and quats is None) or\n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if ((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or\n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if (quats is not None):\n quats = quats.to(dtype=torch.float32)\n if (rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if (quats is not None and normalize_quats):\n", "probing input new": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if ((rot_mats is None and quats is None) or\n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if ((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or\n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if (quats is not None):\n quats = quats.to(dtype=torch.float32)\n if (rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if (quats is not None and normalize_quats):\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if ((rot_mats is None and quats is None) or\n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if ((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or\n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if (quats is not None):\n quats = quats.to(dtype=torch.float32)\n if (rot_mats is not None):\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if (quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7052, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def est_directional_similarity(xs: torch.Tensor, n_est: int = 1000) -> torch.Tensor:\n \"\"\"xs: (batch, nx). Returns (n_est, ) between 0 and 1.\"\"\"\n # xs: (batch, nx)\n batch, nx = xs.shape\n\n # Center first.\n xs = xs - torch.mean(xs, dim=0, keepdim=True)\n\n rand_idxs1 = torch.randint(batch, [n_est], dtype=torch.long)\n rand_idxs2 = torch.randint(batch, [n_est], dtype=torch.long)\n\n # (n_est, nx)\n xs1 = xs[rand_idxs1]\n # (n_est, nx)\n xs2 = xs[rand_idxs2]\n\n # Normalize to unit vector.\n xs1 /= torch.linalg.norm(xs1, dim=1, keepdim=True)\n xs2 /= torch.linalg.norm(xs2, dim=1, keepdim=True)\n\n # (n_est, )\n cos_angle = torch.sum(xs1 * xs2, dim=1).clip(-1.0, 1.0)\n assert cos_angle.shape == (n_est,)\n\n # Should be in [0, pi).\n angle = torch.acos(cos_angle)\n assert (0 <= angle).all()\n assert (angle <= torch.pi).all()\n\n D_ij = 1.0 - angle / torch.pi\n assert D_ij.shape == (n_est,)\n\n return D_ij", "probing input": "def est_directional_similarity(xs: torch.Tensor, n_est: int = 1000) -> torch.Tensor:\n \"\"\"xs: (batch, nx). Returns (n_est, ) between 0 and 1.\"\"\"\n # xs: (batch, nx)\n batch, nx = xs.shape\n\n # Center first.\n xs = xs - torch.mean(xs, dim=0, keepdim=True)\n\n rand_idxs1 = torch.randint(batch, [n_est], dtype=torch.long)\n rand_idxs2 = torch.randint(batch, [n_est], dtype=torch.long)\n\n # (n_est, nx)\n xs1 = xs[rand_idxs1]\n # (n_est, nx)\n xs2 = xs[rand_idxs2]\n\n # Normalize to unit vector.\n", "probing input new": "def est_directional_similarity(xs: torch.Tensor, n_est: int = 1000) -> torch.Tensor:\n \"\"\"xs: (batch, nx). Returns (n_est, ) between 0 and 1.\"\"\"\n # xs: (batch, nx)\n batch, nx = xs.shape\n\n # Center first.\n xs = xs - torch.mean(xs, dim=0, keepdim=True)\n\n rand_idxs1 = torch.randint(batch, [n_est], dtype=torch.long)\n rand_idxs2 = torch.randint(batch, [n_est], dtype=torch.long)\n\n # (n_est, nx)\n xs1 = xs[rand_idxs1]\n # (n_est, nx)\n xs2 = xs[rand_idxs2]\n\n # Normalize to unit vector.\n xs1 /= torch.", "reference": "xs1/=torch.linalg.norm(xs1,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "xs1/=torch.linalg.norm(xs1,dim=1,keepdim=True)", "y_neg": " xs1 /= torch.norm(xs1, dim=1, keepdim=True)", "retain": "def est_directional_similarity(xs: torch.Tensor, n_est: int = 1000) -> torch.Tensor:\n \"\"\"xs: (batch, nx). Returns (n_est, ) between 0 and 1.\"\"\"\n # xs: (batch, nx)\n batch, nx = xs.shape\n\n # Center first.\n xs = xs - torch.mean(xs, dim=0, keepdim=True)\n\n rand_idxs1 = torch.randint(batch, [n_est], dtype=torch.long)\n rand_idxs2 = torch.randint(batch, [n_est], dtype=torch.long)\n\n # (n_est, nx)\n xs1 = xs[rand_idxs1]\n # (n_est, nx)\n xs2 = xs[rand_idxs2]\n\n # Normalize to unit vector.\n xs1 /= torch.linalg.norm(xs1, dim=1, keepdim=True)\n xs2 /= torch.linalg.norm(xs2, dim=1, keepdim=True)\n\n # (n_est, )\n cos_angle = torch.sum(xs1 * xs2, dim=1).clip(-1.0, 1.0)\n assert cos_angle.shape == (n_est,)\n\n # Should be in [0, pi).\n angle = torch.acos(cos_angle)\n assert (0 <= angle).all()\n assert (angle <= torch.pi).all()\n\n D_ij = 1.0 - angle / torch.pi\n assert D_ij.shape == (n_est,)\n\n return D_ij" }, { "id": 7053, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_mean_drift_term(mf_x: torch.Tensor, xi: torch.Tensor) -> torch.Tensor:\n \"\"\"Decompose the polarize dynamic Eq (18) in paper into 2 parts for faster computation:\n f_polarize(x,p,ξ)\n = E_{y~p}[a(x,y,ξ) * bar_y], where a(x,y,ξ) = sign()*sign()\n and bar_y = y / |y|^{0.5}\n = sign() * E_{y~p}[sign() * bar_y], since sign() is independent of y\n = A(x,ξ) * B(p,ξ)\n Hence, bar_f_polarize = bar_A(x,ξ) * bar_B(p,ξ)\n This function computes only bar_B(p,ξ).\n \"\"\"\n # mf_x: (B, *, D), xi: (*, D)\n # output: (*, D)\n\n B, Ts, D = mf_x.shape[0], mf_x.shape[1:-1], mf_x.shape[-1]\n assert xi.shape == (*Ts, D)\n\n mf_x_norm = torch.linalg.norm(mf_x, dim=-1, keepdim=True)\n assert torch.all(mf_x_norm > 0.0)\n\n normalized_mf_x = mf_x / torch.sqrt(mf_x_norm)\n assert normalized_mf_x.shape == (B, *Ts, D)\n\n # Compute the mean drift term: 1/J sum_j a(y_j) y_j / sqrt(| y_j |).\n mf_agree_j = opinion_thresh(torch.sum(mf_x * xi, dim=-1, keepdim=True))\n assert mf_agree_j.shape == (B, *Ts, 1)\n\n mean_drift_term = torch.mean(mf_agree_j * normalized_mf_x, dim=0)\n assert mean_drift_term.shape == (*Ts, D)\n\n mean_drift_term_norm = torch.linalg.norm(mean_drift_term, dim=-1, keepdim=True)\n mean_drift_term = mean_drift_term / torch.sqrt(mean_drift_term_norm)\n assert mean_drift_term.shape == (*Ts, D)\n\n return mean_drift_term", "probing input": "def compute_mean_drift_term(mf_x: torch.Tensor, xi: torch.Tensor) -> torch.Tensor:\n \"\"\"Decompose the polarize dynamic Eq (18) in paper into 2 parts for faster computation:\n f_polarize(x,p,ξ)\n = E_{y~p}[a(x,y,ξ) * bar_y], where a(x,y,ξ) = sign()*sign()\n and bar_y = y / |y|^{0.5}\n = sign() * E_{y~p}[sign() * bar_y], since sign() is independent of y\n = A(x,ξ) * B(p,ξ)\n Hence, bar_f_polarize = bar_A(x,ξ) * bar_B(p,ξ)\n This function computes only bar_B(p,ξ).\n \"\"\"\n # mf_x: (B, *, D), xi: (*, D)\n # output: (*, D)\n\n B, Ts, D = mf_x.shape[0], mf_x.shape[1:-1], mf_x.shape[-1]\n assert xi.shape == (*Ts, D)\n\n", "probing input new": "def compute_mean_drift_term(mf_x: torch.Tensor, xi: torch.Tensor) -> torch.Tensor:\n \"\"\"Decompose the polarize dynamic Eq (18) in paper into 2 parts for faster computation:\n f_polarize(x,p,ξ)\n = E_{y~p}[a(x,y,ξ) * bar_y], where a(x,y,ξ) = sign()*sign()\n and bar_y = y / |y|^{0.5}\n = sign() * E_{y~p}[sign() * bar_y], since sign() is independent of y\n = A(x,ξ) * B(p,ξ)\n Hence, bar_f_polarize = bar_A(x,ξ) * bar_B(p,ξ)\n This function computes only bar_B(p,ξ).\n \"\"\"\n # mf_x: (B, *, D), xi: (*, D)\n # output: (*, D)\n\n B, Ts, D = mf_x.shape[0], mf_x.shape[1:-1], mf_x.shape[-1]\n assert xi.shape == (*Ts, D)\n\n mf_x_", "reference": "mf_x_norm=torch.linalg.norm(mf_x,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mf_x_norm=torch.linalg.norm(mf_x,dim=-1,keepdim=True)", "y_neg": " mf_x_bar = mf_x / torch.norm(mf_x, p=2, dim=-1, keepdim=True)", "retain": "def compute_mean_drift_term(mf_x: torch.Tensor, xi: torch.Tensor) -> torch.Tensor:\n \"\"\"Decompose the polarize dynamic Eq (18) in paper into 2 parts for faster computation:\n f_polarize(x,p,ξ)\n = E_{y~p}[a(x,y,ξ) * bar_y], where a(x,y,ξ) = sign()*sign()\n and bar_y = y / |y|^{0.5}\n = sign() * E_{y~p}[sign() * bar_y], since sign() is independent of y\n = A(x,ξ) * B(p,ξ)\n Hence, bar_f_polarize = bar_A(x,ξ) * bar_B(p,ξ)\n This function computes only bar_B(p,ξ).\n \"\"\"\n # mf_x: (B, *, D), xi: (*, D)\n # output: (*, D)\n\n B, Ts, D = mf_x.shape[0], mf_x.shape[1:-1], mf_x.shape[-1]\n assert xi.shape == (*Ts, D)\n\n mf_x_norm = torch.linalg.norm(mf_x, dim=-1, keepdim=True)\n assert torch.all(mf_x_norm > 0.0)\n\n normalized_mf_x = mf_x / torch.sqrt(mf_x_norm)\n assert normalized_mf_x.shape == (B, *Ts, D)\n\n # Compute the mean drift term: 1/J sum_j a(y_j) y_j / sqrt(| y_j |).\n mf_agree_j = opinion_thresh(torch.sum(mf_x * xi, dim=-1, keepdim=True))\n assert mf_agree_j.shape == (B, *Ts, 1)\n\n mean_drift_term = torch.mean(mf_agree_j * normalized_mf_x, dim=0)\n assert mean_drift_term.shape == (*Ts, D)\n\n mean_drift_term_norm = torch.linalg.norm(mean_drift_term, dim=-1, keepdim=True)\n mean_drift_term = mean_drift_term / torch.sqrt(mean_drift_term_norm)\n assert mean_drift_term.shape == (*Ts, D)\n\n return mean_drift_term" }, { "id": 7054, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def build_xis(T, D) -> torch.Tensor:\n # Generate random unit vectors.\n rng = np.random.default_rng(seed=4078213)\n xis = rng.standard_normal([T, D])\n\n # Construct a xis that has some degree of \"continuous\" over time, as a brownian motion.\n xi = xis[0]\n bm_xis = [xi]\n std = 0.4\n dt = 1.0 / T\n for t in range(1, T):\n xi = xi - (2.0 * xi) * dt + std * math.sqrt(dt) * xis[t]\n bm_xis.append(xi)\n assert len(bm_xis) == xis.shape[0]\n\n xis = torch.Tensor(np.stack(bm_xis))\n xis /= torch.linalg.norm(xis, dim=-1, keepdim=True)\n\n # Just safeguard if the self.xis becomes different.\n print(\"USING BM XI! xis.sum(): {}\".format(torch.sum(xis)))\n assert xis.shape == (T, D)\n return xis", "probing input": "def build_xis(T, D) -> torch.Tensor:\n # Generate random unit vectors.\n rng = np.random.default_rng(seed=4078213)\n xis = rng.standard_normal([T, D])\n\n # Construct a xis that has some degree of \"continuous\" over time, as a brownian motion.\n xi = xis[0]\n bm_xis = [xi]\n std = 0.4\n dt = 1.0 / T\n for t in range(1, T):\n xi = xi - (2.0 * xi) * dt + std * math.sqrt(dt) * xis[t]\n bm_xis.append(xi)\n assert len(bm_xis) == xis.shape[0]\n\n xis = torch.Tensor(np.stack(bm_xis))\n", "probing input new": "def build_xis(T, D) -> torch.Tensor:\n # Generate random unit vectors.\n rng = np.random.default_rng(seed=4078213)\n xis = rng.standard_normal([T, D])\n\n # Construct a xis that has some degree of \"continuous\" over time, as a brownian motion.\n xi = xis[0]\n bm_xis = [xi]\n std = 0.4\n dt = 1.0 / T\n for t in range(1, T):\n xi = xi - (2.0 * xi) * dt + std * math.sqrt(dt) * xis[t]\n bm_xis.append(xi)\n assert len(bm_xis) == xis.shape[0]\n\n xis = torch.Tensor(np.stack(bm_xis))\n xis /= torch.", "reference": "xis/=torch.linalg.norm(xis,dim=-1,keepdim=True)", "reference dict": { "xis": "torch.Tensor" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "xis/=torch.linalg.norm(xis,dim=-1,keepdim=True)", "y_neg": " xis /= torch.norm(xis, dim=-1, keepdim=True)", "retain": "def build_xis(T, D) -> torch.Tensor:\n # Generate random unit vectors.\n rng = np.random.default_rng(seed=4078213)\n xis = rng.standard_normal([T, D])\n\n # Construct a xis that has some degree of \"continuous\" over time, as a brownian motion.\n xi = xis[0]\n bm_xis = [xi]\n std = 0.4\n dt = 1.0 / T\n for t in range(1, T):\n xi = xi - (2.0 * xi) * dt + std * math.sqrt(dt) * xis[t]\n bm_xis.append(xi)\n assert len(bm_xis) == xis.shape[0]\n\n xis = torch.Tensor(np.stack(bm_xis))\n xis /= torch.linalg.norm(xis, dim=-1, keepdim=True)\n\n # Just safeguard if the self.xis becomes different.\n print(\"USING BM XI! xis.sum(): {}\".format(torch.sum(xis)))\n assert xis.shape == (T, D)\n return xis" }, { "id": 7057, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, initial_states, controls):\n # The dynamics model is a simple random walk model.\n # The controls are null.\n N, state_dim = initial_states.shape\n self.state_dim = state_dim\n\n accel = controls[:, :3] - initial_states[:,10:13]\n accel_mag = torch.linalg.norm(accel, dim=1)\n# print(\"Accel mag: \", accel_mag)\n accel_body = torch.zeros(N, 3)\n# accel_body[:, 1] = accel_mag\n accel_enu = tf.quaternion_apply(tf.quaternion_invert(initial_states[:,6:10].detach().clone()), accel_body)\n# print(\"Accel enu: \", accel_enu)\n omega = controls[:, 3:6] - initial_states[:,13:]\n# omega = torch.zeros(N, 3)\n\n pos_vel, pos_vel_cov = self.pos_vel_model(initial_states[:,:6], accel_enu)\n quat, quat_cov = self.quat_model(initial_states[:,6:10], omega)\n imu_bias, imu_bias_cov = self.imu_bias_model(initial_states[:,10:], None)\n\n # Combine the covariance matrices\n cholseky_matrix = torch.zeros((N, 16, 16))\n cholseky_matrix[:, 0:6, 0:6] = pos_vel_cov\n cholseky_matrix[:, 6:10, 6:10] = quat_cov\n cholseky_matrix[:, 10:, 10:] = imu_bias_cov\n\n return torch.cat((pos_vel, quat, imu_bias), axis=1), cholseky_matrix", "probing input": " def forward(self, initial_states, controls):\n # The dynamics model is a simple random walk model.\n # The controls are null.\n N, state_dim = initial_states.shape\n self.state_dim = state_dim\n\n accel = controls[:, :3] - initial_states[:,10:13]\n", "probing input new": " def forward(self, initial_states, controls):\n # The dynamics model is a simple random walk model.\n # The controls are null.\n N, state_dim = initial_states.shape\n self.state_dim = state_dim\n\n accel = controls[:, :3] - initial_states[:,10:13]\n accel_mag = torch.", "reference": "accel_mag=torch.linalg.norm(accel,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "accel_mag=torch.linalg.norm(accel,dim=1)", "y_neg": " accel_mag = torch.norm(accel, p=2, dim=1)", "retain": " def forward(self, initial_states, controls):\n # The dynamics model is a simple random walk model.\n # The controls are null.\n N, state_dim = initial_states.shape\n self.state_dim = state_dim\n\n accel = controls[:, :3] - initial_states[:,10:13]\n accel_mag = torch.linalg.norm(accel, dim=1)\n# print(\"Accel mag: \", accel_mag)\n accel_body = torch.zeros(N, 3)\n# accel_body[:, 1] = accel_mag\n accel_enu = tf.quaternion_apply(tf.quaternion_invert(initial_states[:,6:10].detach().clone()), accel_body)\n# print(\"Accel enu: \", accel_enu)\n omega = controls[:, 3:6] - initial_states[:,13:]\n# omega = torch.zeros(N, 3)\n\n pos_vel, pos_vel_cov = self.pos_vel_model(initial_states[:,:6], accel_enu)\n quat, quat_cov = self.quat_model(initial_states[:,6:10], omega)\n imu_bias, imu_bias_cov = self.imu_bias_model(initial_states[:,10:], None)\n\n # Combine the covariance matrices\n cholseky_matrix = torch.zeros((N, 16, 16))\n cholseky_matrix[:, 0:6, 0:6] = pos_vel_cov\n cholseky_matrix[:, 6:10, 6:10] = quat_cov\n cholseky_matrix[:, 10:, 10:] = imu_bias_cov\n\n return torch.cat((pos_vel, quat, imu_bias), axis=1), cholseky_matrix" }, { "id": 7058, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, text):\n tokens = clip.tokenize(text).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z", "probing input": " def forward(self, text):\n tokens = clip.tokenize(text).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n", "probing input new": " def forward(self, text):\n tokens = clip.tokenize(text).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.", "reference": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "y_neg": " z = z / torch.norm(z, dim=-1, keepdim=True)", "retain": " def forward(self, text):\n tokens = clip.tokenize(text).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z" }, { "id": 7060, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_dtype(self, device):\n def run_test_case(input_size, ord, keepdim, from_dtype, to_dtype, compare_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'from_dtype={from_dtype}, to_dtype={to_dtype}')\n input = torch.randn(*input_size, dtype=from_dtype, device=device)\n result = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=from_dtype)\n self.assertEqual(result.dtype, from_dtype, msg=msg)\n result_converted = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype)\n self.assertEqual(result_converted.dtype, to_dtype, msg=msg)\n self.assertEqual(result.to(compare_dtype), result_converted.to(compare_dtype), msg=msg)\n\n result_out_converted = torch.empty_like(result_converted)\n torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype, out=result_out_converted)\n self.assertEqual(result_out_converted.dtype, to_dtype, msg=msg)\n self.assertEqual(result_converted, result_out_converted, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n ord_matrix = [1, -1, 2, -2, inf, -inf, None]\n S = 10\n test_cases = [\n ((S, ), ord_vector),\n ((S, S), ord_matrix),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings in test_cases:\n for ord in ord_settings:\n # float to double\n run_test_case(input_size, ord, keepdim, torch.float, torch.double, torch.float)\n # double to float\n run_test_case(input_size, ord, keepdim, torch.double, torch.double, torch.float)\n\n # Make sure that setting dtype != out.dtype raises an error\n dtype_pairs = [\n (torch.float, torch.double),\n (torch.double, torch.float),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings in test_cases:\n for ord in ord_settings:\n for dtype, out_dtype in dtype_pairs:\n input = torch.rand(*input_size)\n result = torch.Tensor().to(out_dtype)\n with self.assertRaisesRegex(RuntimeError, r'provided dtype must match dtype of result'):\n torch.linalg.norm(input, ord=ord, keepdim=keepdim, dtype=dtype, out=result)\n\n # TODO: Once dtype arg is supported in nuclear and frobenius norms, remove the following test\n # and add 'nuc' and 'fro' to ord_matrix above\n for ord in ['nuc', 'fro']:\n input = torch.randn(10, 10, device=device)\n with self.assertRaisesRegex(RuntimeError, f\"ord=\\'{ord}\\' does not yet support the dtype argument\"):\n torch.linalg.norm(input, ord, dtype=torch.float)", "probing input": " def test_norm_dtype(self, device):\n def run_test_case(input_size, ord, keepdim, from_dtype, to_dtype, compare_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'from_dtype={from_dtype}, to_dtype={to_dtype}')\n input = torch.randn(*input_size, dtype=from_dtype, device=device)\n", "probing input new": " def test_norm_dtype(self, device):\n def run_test_case(input_size, ord, keepdim, from_dtype, to_dtype, compare_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'from_dtype={from_dtype}, to_dtype={to_dtype}')\n input = torch.randn(*input_size, dtype=from_dtype, device=device)\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,keepdim=keepdim,dtype=from_dtype)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,keepdim=keepdim,dtype=from_dtype)", "y_neg": " result = torch.norm(input, ord=ord, keepdim=keepdim, dtype=to_dtype, device=device)", "retain": " def test_norm_dtype(self, device):\n def run_test_case(input_size, ord, keepdim, from_dtype, to_dtype, compare_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'from_dtype={from_dtype}, to_dtype={to_dtype}')\n input = torch.randn(*input_size, dtype=from_dtype, device=device)\n result = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=from_dtype)\n self.assertEqual(result.dtype, from_dtype, msg=msg)\n result_converted = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype)\n self.assertEqual(result_converted.dtype, to_dtype, msg=msg)\n self.assertEqual(result.to(compare_dtype), result_converted.to(compare_dtype), msg=msg)\n\n result_out_converted = torch.empty_like(result_converted)\n torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype, out=result_out_converted)\n self.assertEqual(result_out_converted.dtype, to_dtype, msg=msg)\n self.assertEqual(result_converted, result_out_converted, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n ord_matrix = [1, -1, 2, -2, inf, -inf, None]\n S = 10\n test_cases = [\n ((S, ), ord_vector),\n ((S, S), ord_matrix),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings in test_cases:\n for ord in ord_settings:\n # float to double\n run_test_case(input_size, ord, keepdim, torch.float, torch.double, torch.float)\n # double to float\n run_test_case(input_size, ord, keepdim, torch.double, torch.double, torch.float)\n\n # Make sure that setting dtype != out.dtype raises an error\n dtype_pairs = [\n (torch.float, torch.double),\n (torch.double, torch.float),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings in test_cases:\n for ord in ord_settings:\n for dtype, out_dtype in dtype_pairs:\n input = torch.rand(*input_size)\n result = torch.Tensor().to(out_dtype)\n with self.assertRaisesRegex(RuntimeError, r'provided dtype must match dtype of result'):\n torch.linalg.norm(input, ord=ord, keepdim=keepdim, dtype=dtype, out=result)\n\n # TODO: Once dtype arg is supported in nuclear and frobenius norms, remove the following test\n # and add 'nuc' and 'fro' to ord_matrix above\n for ord in ['nuc', 'fro']:\n input = torch.randn(10, 10, device=device)\n with self.assertRaisesRegex(RuntimeError, f\"ord=\\'{ord}\\' does not yet support the dtype argument\"):\n torch.linalg.norm(input, ord, dtype=torch.float)" }, { "id": 7061, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_vector(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n self.assertEqual(result, result_numpy, msg=msg)\n\n result_out = torch.empty_like(result)\n torch.linalg.norm(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, ), ord_vector, None),\n ((S, ), ord_vector, 0),\n ((S, S, S), ord_vector, 0),\n ((S, S, S), ord_vector, 1),\n ((S, S, S), ord_vector, 2),\n ((S, S, S), ord_vector, -1),\n ((S, S, S), ord_vector, -2),\n ]\n L = 1_000_000\n if dtype == torch.double:\n test_cases.append(((L, ), ord_vector, None))\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)", "probing input": " def test_norm_vector(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n", "probing input new": " def test_norm_vector(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,dim,keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,dim,keepdim)", "y_neg": " result = torch.norm(input, p=p, dim=dim, keepdim=keepdim)", "retain": " def test_norm_vector(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n self.assertEqual(result, result_numpy, msg=msg)\n\n result_out = torch.empty_like(result)\n torch.linalg.norm(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, ), ord_vector, None),\n ((S, ), ord_vector, 0),\n ((S, S, S), ord_vector, 0),\n ((S, S, S), ord_vector, 1),\n ((S, S, S), ord_vector, 2),\n ((S, S, S), ord_vector, -1),\n ((S, S, S), ord_vector, -2),\n ]\n L = 1_000_000\n if dtype == torch.double:\n test_cases.append(((L, ), ord_vector, None))\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)" }, { "id": 7062, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n self.assertEqual(result, result_numpy, msg=msg)\n\n result_out = torch.empty_like(result)\n torch.linalg.norm(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro', None]\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, S), ord_matrix, None),\n ((S, S), ord_matrix, (0, 1)),\n ((S, S), ord_matrix, (1, 0)),\n ((S, S, S, S), ord_matrix, (2, 0)),\n ((S, S, S, S), ord_matrix, (-1, -2)),\n ((S, S, S, S), ord_matrix, (-1, -3)),\n ((S, S, S, S), ord_matrix, (-3, 2)),\n ]\n L = 1_000\n if dtype == torch.double:\n test_cases.append(((L, L), ord_matrix, None))\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)", "probing input": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n", "probing input new": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,dim,keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,dim,keepdim)", "y_neg": " result = torch.norm(input, p=p, dim=dim, keepdim=keepdim)", "retain": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, p, dim, keepdim):\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n self.assertEqual(result, result_numpy, msg=msg)\n\n result_out = torch.empty_like(result)\n torch.linalg.norm(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro', None]\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, S), ord_matrix, None),\n ((S, S), ord_matrix, (0, 1)),\n ((S, S), ord_matrix, (1, 0)),\n ((S, S, S, S), ord_matrix, (2, 0)),\n ((S, S, S, S), ord_matrix, (-1, -2)),\n ((S, S, S, S), ord_matrix, (-1, -3)),\n ((S, S, S, S), ord_matrix, (-3, 2)),\n ]\n L = 1_000\n if dtype == torch.double:\n test_cases.append(((L, L), ord_matrix, None))\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)" }, { "id": 7063, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_errors(self, device, dtype):\n def run_error_test_case(input, ord, dim, keepdim, error_type, error_regex):\n test_case_info = (\n f'test case input.size()={input.size()}, ord={ord}, dim={dim}, '\n f'keepdim={keepdim}, dtype={dtype}')\n\n with self.assertRaisesRegex(error_type, error_regex, msg=test_case_info):\n torch.linalg.norm(input, ord, dim, keepdim)\n\n input_numpy = input.cpu().numpy()\n\n msg = f'numpy does not raise error but pytorch does, for case \"{test_case_info}\"'\n with self.assertRaises(Exception, msg=test_case_info):\n np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n S = 10\n error_test_cases = [\n # input size, p settings, dim, error type, error regex\n ((S, ), ['fro'], None, RuntimeError, r'order \"fro\" can only be used if either len\\(dim\\) == 2'),\n ((S, ), ['nuc'], None, RuntimeError, r'order \"nuc\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), [3.5], None, RuntimeError, r'Order 3.5 not supported for matrix norm'),\n ((S, S), [0], None, RuntimeError, r'Order 0 not supported for matrix norm'),\n ((S, S), ['nuc'], 0, RuntimeError, r'order \"nuc\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), ['fro'], 0, RuntimeError, r'order \"fro\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), ['nuc'], (0, 0), RuntimeError, r'duplicate or invalid dimensions'),\n ((S, S), ['fro', 0], (0, 0), RuntimeError, r'Expected dims to be different'),\n ((S, S), ['fro', 'nuc', 0], (0, 4), IndexError, r'Dimension out of range'),\n ((S, ), [0], (4, ), IndexError, r'Dimension out of range'),\n ((S, ), [None], (0, 0), RuntimeError, r'Expected dims to be different, got this instead'),\n ((S, S, S), [1], (0, 1, 2), RuntimeError, r\"'dim' must specify 1 or 2 dimensions\"),\n ((S, S, S), [1], None, RuntimeError, r\"'dim' must specify 1 or 2 dimensions\"),\n ((S, S), ['garbage'], (0, 1), RuntimeError, r'Invalid norm order: garbage'),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings, dim, error_type, error_regex in error_test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_error_test_case(input, ord, dim, keepdim, error_type, error_regex)", "probing input": " def test_norm_errors(self, device, dtype):\n def run_error_test_case(input, ord, dim, keepdim, error_type, error_regex):\n test_case_info = (\n f'test case input.size()={input.size()}, ord={ord}, dim={dim}, '\n f'keepdim={keepdim}, dtype={dtype}')\n\n with self.assertRaisesRegex(error_type, error_regex, msg=test_case_info):\n", "probing input new": " def test_norm_errors(self, device, dtype):\n def run_error_test_case(input, ord, dim, keepdim, error_type, error_regex):\n test_case_info = (\n f'test case input.size()={input.size()}, ord={ord}, dim={dim}, '\n f'keepdim={keepdim}, dtype={dtype}')\n\n with self.assertRaisesRegex(error_type, error_regex, msg=test_case_info):\n torch.", "reference": "torch.linalg.norm(input,ord,dim,keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "torch.linalg.norm(input,ord,dim,keepdim)", "y_neg": " torch.norm(input, ord=ord, dim=dim, keepdim=keepdim, dtype=dtype)", "retain": " def test_norm_errors(self, device, dtype):\n def run_error_test_case(input, ord, dim, keepdim, error_type, error_regex):\n test_case_info = (\n f'test case input.size()={input.size()}, ord={ord}, dim={dim}, '\n f'keepdim={keepdim}, dtype={dtype}')\n\n with self.assertRaisesRegex(error_type, error_regex, msg=test_case_info):\n torch.linalg.norm(input, ord, dim, keepdim)\n\n input_numpy = input.cpu().numpy()\n\n msg = f'numpy does not raise error but pytorch does, for case \"{test_case_info}\"'\n with self.assertRaises(Exception, msg=test_case_info):\n np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n S = 10\n error_test_cases = [\n # input size, p settings, dim, error type, error regex\n ((S, ), ['fro'], None, RuntimeError, r'order \"fro\" can only be used if either len\\(dim\\) == 2'),\n ((S, ), ['nuc'], None, RuntimeError, r'order \"nuc\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), [3.5], None, RuntimeError, r'Order 3.5 not supported for matrix norm'),\n ((S, S), [0], None, RuntimeError, r'Order 0 not supported for matrix norm'),\n ((S, S), ['nuc'], 0, RuntimeError, r'order \"nuc\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), ['fro'], 0, RuntimeError, r'order \"fro\" can only be used if either len\\(dim\\) == 2'),\n ((S, S), ['nuc'], (0, 0), RuntimeError, r'duplicate or invalid dimensions'),\n ((S, S), ['fro', 0], (0, 0), RuntimeError, r'Expected dims to be different'),\n ((S, S), ['fro', 'nuc', 0], (0, 4), IndexError, r'Dimension out of range'),\n ((S, ), [0], (4, ), IndexError, r'Dimension out of range'),\n ((S, ), [None], (0, 0), RuntimeError, r'Expected dims to be different, got this instead'),\n ((S, S, S), [1], (0, 1, 2), RuntimeError, r\"'dim' must specify 1 or 2 dimensions\"),\n ((S, S, S), [1], None, RuntimeError, r\"'dim' must specify 1 or 2 dimensions\"),\n ((S, S), ['garbage'], (0, 1), RuntimeError, r'Invalid norm order: garbage'),\n ]\n for keepdim in [True, False]:\n for input_size, ord_settings, dim, error_type, error_regex in error_test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_error_test_case(input, ord, dim, keepdim, error_type, error_regex)" }, { "id": 7064, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = ['fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n self.assertEqual(result, result_n, msg=msg)\n\n # TODO: Remove this function once the broken cases are fixed\n def is_broken_matrix_norm_case(ord, x):\n if self.device_type == 'cuda':\n if x.size() == torch.Size([1, 2]):\n if ord in ['nuc', 2, -2] and isnan(x[0][0]) and x[0][1] == 1:\n # These cases are broken because of an issue with svd\n # https://github.com/pytorch/pytorch/issues/43567\n return True\n return False\n\n for matrix in matrices:\n x = torch.tensor(matrix).to(device)\n x_n = x.cpu().numpy()\n for ord in matrix_ords:\n msg = f'ord={ord}, matrix={matrix}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n\n if is_broken_matrix_norm_case(ord, x):\n continue\n else:\n self.assertEqual(result, result_n, msg=msg)", "probing input": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = ['fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n", "probing input new": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = ['fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.", "reference": "result=torch.linalg.norm(x,ord=ord)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(x,ord=ord)", "y_neg": " result = torch.norm(x, ord=ord, dim=0)", "retain": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = ['fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n self.assertEqual(result, result_n, msg=msg)\n\n # TODO: Remove this function once the broken cases are fixed\n def is_broken_matrix_norm_case(ord, x):\n if self.device_type == 'cuda':\n if x.size() == torch.Size([1, 2]):\n if ord in ['nuc', 2, -2] and isnan(x[0][0]) and x[0][1] == 1:\n # These cases are broken because of an issue with svd\n # https://github.com/pytorch/pytorch/issues/43567\n return True\n return False\n\n for matrix in matrices:\n x = torch.tensor(matrix).to(device)\n x_n = x.cpu().numpy()\n for ord in matrix_ords:\n msg = f'ord={ord}, matrix={matrix}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n\n if is_broken_matrix_norm_case(ord, x):\n continue\n else:\n self.assertEqual(result, result_n, msg=msg)" }, { "id": 7067, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_fastpaths(self, device):\n x = torch.randn(3, 5, device=device)\n\n # slow path\n result = torch.linalg.norm(x, 4.5, 1)\n expected = torch.pow(x.abs().pow(4.5).sum(1), 1.0 / 4.5)\n self.assertEqual(result, expected)\n\n # fast 0-norm\n result = torch.linalg.norm(x, 0, 1)\n expected = (x != 0).type_as(x).sum(1)\n self.assertEqual(result, expected)\n\n # fast 1-norm\n result = torch.linalg.norm(x, 1, 1)\n expected = x.abs().sum(1)\n self.assertEqual(result, expected)\n\n # fast 2-norm\n result = torch.linalg.norm(x, 2, 1)\n expected = torch.sqrt(x.pow(2).sum(1))\n self.assertEqual(result, expected)\n\n # fast 3-norm\n result = torch.linalg.norm(x, 3, 1)\n expected = torch.pow(x.pow(3).abs().sum(1), 1.0 / 3.0)\n self.assertEqual(result, expected)", "probing input": " def test_norm_fastpaths(self, device):\n x = torch.randn(3, 5, device=device)\n\n # slow path\n", "probing input new": " def test_norm_fastpaths(self, device):\n x = torch.randn(3, 5, device=device)\n\n # slow path\n result = torch.", "reference": "result=torch.linalg.norm(x,4.5,1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(x,4.5,1)", "y_neg": " result = torch.norm(x, p=1, dim=0, keepdim=True)", "retain": " def test_norm_fastpaths(self, device):\n x = torch.randn(3, 5, device=device)\n\n # slow path\n result = torch.linalg.norm(x, 4.5, 1)\n expected = torch.pow(x.abs().pow(4.5).sum(1), 1.0 / 4.5)\n self.assertEqual(result, expected)\n\n # fast 0-norm\n result = torch.linalg.norm(x, 0, 1)\n expected = (x != 0).type_as(x).sum(1)\n self.assertEqual(result, expected)\n\n # fast 1-norm\n result = torch.linalg.norm(x, 1, 1)\n expected = x.abs().sum(1)\n self.assertEqual(result, expected)\n\n # fast 2-norm\n result = torch.linalg.norm(x, 2, 1)\n expected = torch.sqrt(x.pow(2).sum(1))\n self.assertEqual(result, expected)\n\n # fast 3-norm\n result = torch.linalg.norm(x, 3, 1)\n expected = torch.pow(x.pow(3).abs().sum(1), 1.0 / 3.0)\n self.assertEqual(result, expected)" }, { "id": 7068, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def subspace_relative_distance(P1, P2):\n # slow when the ambient dimension is large\n proj1 = P1@P1.T\n proj2 = P2@P2.T\n if type(P1) == type(P2) == torch.Tensor:\n return torch.linalg.norm(proj1-proj2)/torch.linalg.norm(proj1)\n if type(P1) == type(P2) == np.ndarray:\n return np.linalg.norm(proj1-proj2)/np.linalg.norm(proj1)\n return TypeError('Error: should be np.ndarray or torch.Tensor...')", "probing input": "def subspace_relative_distance(P1, P2):\n # slow when the ambient dimension is large\n proj1 = P1@P1.T\n proj2 = P2@P2.T\n if type(P1) == type(P2) == torch.Tensor:\n", "probing input new": "def subspace_relative_distance(P1, P2):\n # slow when the ambient dimension is large\n proj1 = P1@P1.T\n proj2 = P2@P2.T\n if type(P1) == type(P2) == torch.Tensor:\n return torch.", "reference": "returntorch.linalg.norm(proj1-proj2)/torch.linalg.norm(proj1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(proj1-proj2)/torch.linalg.norm(proj1)", "y_neg": " return torch.norm(proj1 - proj2, p='fro', dim=1)", "retain": "def subspace_relative_distance(P1, P2):\n # slow when the ambient dimension is large\n proj1 = P1@P1.T\n proj2 = P2@P2.T\n if type(P1) == type(P2) == torch.Tensor:\n return torch.linalg.norm(proj1-proj2)/torch.linalg.norm(proj1)\n if type(P1) == type(P2) == np.ndarray:\n return np.linalg.norm(proj1-proj2)/np.linalg.norm(proj1)\n return TypeError('Error: should be np.ndarray or torch.Tensor...')" }, { "id": 7074, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def dist_point_to_line_torch(points, line_start, line_direction):\n \"\"\"Get the distance from multiple points to a single line using torch\"\"\"\n # Get the vectors from each point cloud point to the line\n vectors = point_to_line_torch(points, line_start, line_direction)\n dist = torch.linalg.norm(vectors, dim=-1)\n return dist", "probing input": "def dist_point_to_line_torch(points, line_start, line_direction):\n \"\"\"Get the distance from multiple points to a single line using torch\"\"\"\n # Get the vectors from each point cloud point to the line\n vectors = point_to_line_torch(points, line_start, line_direction)\n", "probing input new": "def dist_point_to_line_torch(points, line_start, line_direction):\n \"\"\"Get the distance from multiple points to a single line using torch\"\"\"\n # Get the vectors from each point cloud point to the line\n vectors = point_to_line_torch(points, line_start, line_direction)\n dist = torch.", "reference": "dist=torch.linalg.norm(vectors,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(vectors,dim=-1)", "y_neg": " dist = torch.norm(vectors, p=2, dim=1)", "retain": "def dist_point_to_line_torch(points, line_start, line_direction):\n \"\"\"Get the distance from multiple points to a single line using torch\"\"\"\n # Get the vectors from each point cloud point to the line\n vectors = point_to_line_torch(points, line_start, line_direction)\n dist = torch.linalg.norm(vectors, dim=-1)\n return dist" }, { "id": 7075, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def axis_line_to_torch(axis_line):\n \"\"\"\n Convert an axis line dict into a\n torch origin point and direction vector\n \"\"\"\n origin = util.vector_to_torch(axis_line[\"origin\"])[:3]\n direction = util.vector_to_torch(axis_line[\"direction\"])[:3]\n length = torch.linalg.norm(direction)\n if length == 0:\n print(\"Warning: Joint axis direction of length 0\")\n else:\n direction = direction / length\n return origin, direction", "probing input": "def axis_line_to_torch(axis_line):\n \"\"\"\n Convert an axis line dict into a\n torch origin point and direction vector\n \"\"\"\n origin = util.vector_to_torch(axis_line[\"origin\"])[:3]\n direction = util.vector_to_torch(axis_line[\"direction\"])[:3]\n", "probing input new": "def axis_line_to_torch(axis_line):\n \"\"\"\n Convert an axis line dict into a\n torch origin point and direction vector\n \"\"\"\n origin = util.vector_to_torch(axis_line[\"origin\"])[:3]\n direction = util.vector_to_torch(axis_line[\"direction\"])[:3]\n length = torch.", "reference": "length=torch.linalg.norm(direction)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "length=torch.linalg.norm(direction)", "y_neg": " length = torch.norm(direction, p=2, dim=1, keepdim=True)", "retain": "def axis_line_to_torch(axis_line):\n \"\"\"\n Convert an axis line dict into a\n torch origin point and direction vector\n \"\"\"\n origin = util.vector_to_torch(axis_line[\"origin\"])[:3]\n direction = util.vector_to_torch(axis_line[\"direction\"])[:3]\n length = torch.linalg.norm(direction)\n if length == 0:\n print(\"Warning: Joint axis direction of length 0\")\n else:\n direction = direction / length\n return origin, direction" }, { "id": 7077, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def assign_pred_to_gt_vip3d(\n self,\n bbox_result,\n gt_bbox,\n gt_label,\n match_dis_thresh=2.0\n ):\n \"\"\"Assign pred boxs to gt boxs according to object center preds in lcf.\n Args:\n bbox_result (dict): Predictions.\n 'boxes_3d': (LiDARInstance3DBoxes)\n 'scores_3d': (Tensor), [num_pred_bbox]\n 'labels_3d': (Tensor), [num_pred_bbox]\n 'trajs_3d': (Tensor), [fut_ts*2]\n gt_bboxs (LiDARInstance3DBoxes): GT Bboxs.\n gt_label (Tensor): GT labels for gt_bbox, [num_gt_bbox].\n match_dis_thresh (float): dis thresh for determine a positive sample for a gt bbox.\n\n Returns:\n matched_bbox_result (np.array): assigned pred index for each gt box [num_gt_bbox].\n \"\"\" \n dynamic_list = [0,1,3,4,6,7,8]\n matched_bbox_result = torch.ones(\n (len(gt_bbox)), dtype=torch.long) * -1 # -1: not assigned\n gt_centers = gt_bbox.center[:, :2]\n pred_centers = bbox_result['boxes_3d'].center[:, :2]\n dist = torch.linalg.norm(pred_centers[:, None, :] - gt_centers[None, :, :], dim=-1)\n pred_not_dyn = [label not in dynamic_list for label in bbox_result['labels_3d']]\n gt_not_dyn = [label not in dynamic_list for label in gt_label]\n dist[pred_not_dyn] = 1e6\n dist[:, gt_not_dyn] = 1e6\n dist[dist > match_dis_thresh] = 1e6\n\n r_list, c_list = linear_sum_assignment(dist)\n\n for i in range(len(r_list)):\n if dist[r_list[i], c_list[i]] <= match_dis_thresh:\n matched_bbox_result[c_list[i]] = r_list[i]\n\n return matched_bbox_result", "probing input": " def assign_pred_to_gt_vip3d(\n self,\n bbox_result,\n gt_bbox,\n gt_label,\n match_dis_thresh=2.0\n ):\n \"\"\"Assign pred boxs to gt boxs according to object center preds in lcf.\n Args:\n bbox_result (dict): Predictions.\n 'boxes_3d': (LiDARInstance3DBoxes)\n 'scores_3d': (Tensor), [num_pred_bbox]\n 'labels_3d': (Tensor), [num_pred_bbox]\n 'trajs_3d': (Tensor), [fut_ts*2]\n gt_bboxs (LiDARInstance3DBoxes): GT Bboxs.\n gt_label (Tensor): GT labels for gt_bbox, [num_gt_bbox].\n match_dis_thresh (float): dis thresh for determine a positive sample for a gt bbox.\n\n Returns:\n matched_bbox_result (np.array): assigned pred index for each gt box [num_gt_bbox].\n \"\"\" \n dynamic_list = [0,1,3,4,6,7,8]\n matched_bbox_result = torch.ones(\n (len(gt_bbox)), dtype=torch.long) * -1 # -1: not assigned\n gt_centers = gt_bbox.center[:, :2]\n pred_centers = bbox_result['boxes_3d'].center[:, :2]\n", "probing input new": " def assign_pred_to_gt_vip3d(\n self,\n bbox_result,\n gt_bbox,\n gt_label,\n match_dis_thresh=2.0\n ):\n \"\"\"Assign pred boxs to gt boxs according to object center preds in lcf.\n Args:\n bbox_result (dict): Predictions.\n 'boxes_3d': (LiDARInstance3DBoxes)\n 'scores_3d': (Tensor), [num_pred_bbox]\n 'labels_3d': (Tensor), [num_pred_bbox]\n 'trajs_3d': (Tensor), [fut_ts*2]\n gt_bboxs (LiDARInstance3DBoxes): GT Bboxs.\n gt_label (Tensor): GT labels for gt_bbox, [num_gt_bbox].\n match_dis_thresh (float): dis thresh for determine a positive sample for a gt bbox.\n\n Returns:\n matched_bbox_result (np.array): assigned pred index for each gt box [num_gt_bbox].\n \"\"\" \n dynamic_list = [0,1,3,4,6,7,8]\n matched_bbox_result = torch.ones(\n (len(gt_bbox)), dtype=torch.long) * -1 # -1: not assigned\n gt_centers = gt_bbox.center[:, :2]\n pred_centers = bbox_result['boxes_3d'].center[:, :2]\n dist = torch.", "reference": "dist=torch.linalg.norm(pred_centers[:,None,:]-gt_centers[None,:,:],dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(pred_centers[:,None,:]-gt_centers[None,:,:],dim=-1)", "y_neg": " dist = torch.norm(gt_centers - pred_centers, dim=-1)", "retain": " def assign_pred_to_gt_vip3d(\n self,\n bbox_result,\n gt_bbox,\n gt_label,\n match_dis_thresh=2.0\n ):\n \"\"\"Assign pred boxs to gt boxs according to object center preds in lcf.\n Args:\n bbox_result (dict): Predictions.\n 'boxes_3d': (LiDARInstance3DBoxes)\n 'scores_3d': (Tensor), [num_pred_bbox]\n 'labels_3d': (Tensor), [num_pred_bbox]\n 'trajs_3d': (Tensor), [fut_ts*2]\n gt_bboxs (LiDARInstance3DBoxes): GT Bboxs.\n gt_label (Tensor): GT labels for gt_bbox, [num_gt_bbox].\n match_dis_thresh (float): dis thresh for determine a positive sample for a gt bbox.\n\n Returns:\n matched_bbox_result (np.array): assigned pred index for each gt box [num_gt_bbox].\n \"\"\" \n dynamic_list = [0,1,3,4,6,7,8]\n matched_bbox_result = torch.ones(\n (len(gt_bbox)), dtype=torch.long) * -1 # -1: not assigned\n gt_centers = gt_bbox.center[:, :2]\n pred_centers = bbox_result['boxes_3d'].center[:, :2]\n dist = torch.linalg.norm(pred_centers[:, None, :] - gt_centers[None, :, :], dim=-1)\n pred_not_dyn = [label not in dynamic_list for label in bbox_result['labels_3d']]\n gt_not_dyn = [label not in dynamic_list for label in gt_label]\n dist[pred_not_dyn] = 1e6\n dist[:, gt_not_dyn] = 1e6\n dist[dist > match_dis_thresh] = 1e6\n\n r_list, c_list = linear_sum_assignment(dist)\n\n for i in range(len(r_list)):\n if dist[r_list[i], c_list[i]] <= match_dis_thresh:\n matched_bbox_result[c_list[i]] = r_list[i]\n\n return matched_bbox_result" }, { "id": 7078, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, batch):\n # Node embedding\n h = self.emb_in(batch.atoms) # (n,) -> (n, d)\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n\n edge_sh = self.spherical_harmonics(vectors)\n edge_feats = self.radial_embedding(lengths)\n \n for conv in self.convs:\n # Message passing layer\n h_update = conv(h, batch.edge_index, edge_sh, edge_feats)\n\n # Update node features\n h = h_update + F.pad(h, (0, h_update.shape[-1] - h.shape[-1])) if self.residual else h_update\n\n out = self.pool(h, batch.batch) # (n, d) -> (batch_size, d)\n \n if not self.equivariant_pred:\n # Select only scalars for invariant prediction\n out = out[:,:self.emb_dim]\n \n return self.pred(out)", "probing input": " def forward(self, batch):\n # Node embedding\n h = self.emb_in(batch.atoms) # (n,) -> (n, d)\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n", "probing input new": " def forward(self, batch):\n # Node embedding\n h = self.emb_in(batch.atoms) # (n,) -> (n, d)\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.", "reference": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "y_neg": " lengths = torch.norm(vectors, dim=1) # [n_edges]", "retain": " def forward(self, batch):\n # Node embedding\n h = self.emb_in(batch.atoms) # (n,) -> (n, d)\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n\n edge_sh = self.spherical_harmonics(vectors)\n edge_feats = self.radial_embedding(lengths)\n \n for conv in self.convs:\n # Message passing layer\n h_update = conv(h, batch.edge_index, edge_sh, edge_feats)\n\n # Update node features\n h = h_update + F.pad(h, (0, h_update.shape[-1] - h.shape[-1])) if self.residual else h_update\n\n out = self.pool(h, batch.batch) # (n, d) -> (batch_size, d)\n \n if not self.equivariant_pred:\n # Select only scalars for invariant prediction\n out = out[:,:self.emb_dim]\n \n return self.pred(out)" }, { "id": 7079, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, rho, alpha, temperature) -> tuple:\n\n w_prime = self._preprocess_graph(self.w, tau=temperature,\n seed=self.seed)\n w_prime = self.pns_mask * w_prime\n mse_loss = self._get_mse_loss(x, w_prime)\n h = (torch.trace(torch.matrix_exp(w_prime * w_prime)) - self.n_nodes)\n loss = (0.5 / self.n_samples * mse_loss\n + self.l1_graph_penalty * torch.linalg.norm(w_prime, ord=1)\n + alpha * h\n + 0.5 * rho * h * h)\n\n return loss, h, self.w", "probing input": " def forward(self, x, rho, alpha, temperature) -> tuple:\n\n w_prime = self._preprocess_graph(self.w, tau=temperature,\n seed=self.seed)\n w_prime = self.pns_mask * w_prime\n mse_loss = self._get_mse_loss(x, w_prime)\n h = (torch.trace(torch.matrix_exp(w_prime * w_prime)) - self.n_nodes)\n loss = (0.5 / self.n_samples * mse_loss\n", "probing input new": " def forward(self, x, rho, alpha, temperature) -> tuple:\n\n w_prime = self._preprocess_graph(self.w, tau=temperature,\n seed=self.seed)\n w_prime = self.pns_mask * w_prime\n mse_loss = self._get_mse_loss(x, w_prime)\n h = (torch.trace(torch.matrix_exp(w_prime * w_prime)) - self.n_nodes)\n loss = (0.5 / self.n_samples * mse_loss\n + self.l1_graph_penalty * torch.", "reference": "+self.l1_graph_penalty*torch.linalg.norm(w_prime,ord=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "+self.l1_graph_penalty*torch.linalg.norm(w_prime,ord=1)", "y_neg": " + self.l1_graph_penalty * torch.norm(h, p='fro', dim=0)", "retain": " def forward(self, x, rho, alpha, temperature) -> tuple:\n\n w_prime = self._preprocess_graph(self.w, tau=temperature,\n seed=self.seed)\n w_prime = self.pns_mask * w_prime\n mse_loss = self._get_mse_loss(x, w_prime)\n h = (torch.trace(torch.matrix_exp(w_prime * w_prime)) - self.n_nodes)\n loss = (0.5 / self.n_samples * mse_loss\n + self.l1_graph_penalty * torch.linalg.norm(w_prime, ord=1)\n + alpha * h\n + 0.5 * rho * h * h)\n\n return loss, h, self.w" }, { "id": 7083, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def arap_deformation_loss(trajectory, node_radius=None, trajectory_rot=None, K=50, with_rot=True):\n init_pcl = trajectory[:, 0]\n radius = torch.linalg.norm(init_pcl.max(dim=0).values - init_pcl.min(dim=0).values) / 8\n fid = torch.randint(1, trajectory.shape[1], [])\n tar_pcl = trajectory[:, fid]\n\n N = init_pcl.shape[0]\n with torch.no_grad():\n radius = torch.linalg.norm(init_pcl.max(dim=0).values - init_pcl.min(dim=0).values) / 8\n device = init_pcl.device\n ii, jj, nn, weight = cal_connectivity_from_points(init_pcl, radius, K, trajectory=trajectory.detach(), node_radius=node_radius, mode='nn')\n L_opt = torch.eye(N).cuda()\n L_opt[ii, jj] = - weight[ii, nn]\n \n P = produce_edge_matrix_nfmt(init_pcl, (N, K, 3), ii, jj, nn, device=device)\n P_prime = produce_edge_matrix_nfmt(tar_pcl, (N, K, 3), ii, jj, nn, device=device)\n \n with torch.no_grad():\n D = torch.diag_embed(weight, dim1=1, dim2=2)\n S = torch.bmm(P.permute(0, 2, 1), torch.bmm(D, P_prime))\n U, sig, W = torch.svd(S)\n R = torch.bmm(W, U.permute(0, 2, 1))\n with torch.no_grad():\n # Need to flip the column of U corresponding to smallest singular value\n # for any det(Ri) <= 0\n entries_to_flip = torch.nonzero(torch.det(R) <= 0, as_tuple=False).flatten() # idxs where det(R) <= 0\n if len(entries_to_flip) > 0:\n Umod = U.clone()\n cols_to_flip = torch.argmin(sig[entries_to_flip], dim=1) # Get minimum singular value for each entry\n Umod[entries_to_flip, :, cols_to_flip] *= -1 # flip cols\n R[entries_to_flip] = torch.bmm(W[entries_to_flip], Umod[entries_to_flip].permute(0, 2, 1))\n arap_error = (weight[..., None] * (P_prime - torch.einsum('bxy,bky->bkx', R, P))).square().mean(dim=0).sum()\n\n if with_rot:\n init_rot = quaternion_to_matrix(trajectory_rot[:, 0])\n tar_rot = quaternion_to_matrix(trajectory_rot[:, fid])\n R_rot = torch.bmm(R, init_rot)\n rot_error = (R_rot - tar_rot).square().mean(dim=0).sum()\n else:\n rot_error = 0.\n\n return arap_error, rot_error * 1e2", "probing input": "def arap_deformation_loss(trajectory, node_radius=None, trajectory_rot=None, K=50, with_rot=True):\n init_pcl = trajectory[:, 0]\n", "probing input new": "def arap_deformation_loss(trajectory, node_radius=None, trajectory_rot=None, K=50, with_rot=True):\n init_pcl = trajectory[:, 0]\n radius = torch.", "reference": "radius=torch.linalg.norm(init_pcl.max(dim=0).values-init_pcl.min(dim=0).values)/8", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(init_pcl.max(dim=0).values-init_pcl.min(dim=0).values)/8", "y_neg": " radius = torch.norm(trajectory - init_pcl, p=2, dim=1)", "retain": "def arap_deformation_loss(trajectory, node_radius=None, trajectory_rot=None, K=50, with_rot=True):\n init_pcl = trajectory[:, 0]\n radius = torch.linalg.norm(init_pcl.max(dim=0).values - init_pcl.min(dim=0).values) / 8\n fid = torch.randint(1, trajectory.shape[1], [])\n tar_pcl = trajectory[:, fid]\n\n N = init_pcl.shape[0]\n with torch.no_grad():\n radius = torch.linalg.norm(init_pcl.max(dim=0).values - init_pcl.min(dim=0).values) / 8\n device = init_pcl.device\n ii, jj, nn, weight = cal_connectivity_from_points(init_pcl, radius, K, trajectory=trajectory.detach(), node_radius=node_radius, mode='nn')\n L_opt = torch.eye(N).cuda()\n L_opt[ii, jj] = - weight[ii, nn]\n \n P = produce_edge_matrix_nfmt(init_pcl, (N, K, 3), ii, jj, nn, device=device)\n P_prime = produce_edge_matrix_nfmt(tar_pcl, (N, K, 3), ii, jj, nn, device=device)\n \n with torch.no_grad():\n D = torch.diag_embed(weight, dim1=1, dim2=2)\n S = torch.bmm(P.permute(0, 2, 1), torch.bmm(D, P_prime))\n U, sig, W = torch.svd(S)\n R = torch.bmm(W, U.permute(0, 2, 1))\n with torch.no_grad():\n # Need to flip the column of U corresponding to smallest singular value\n # for any det(Ri) <= 0\n entries_to_flip = torch.nonzero(torch.det(R) <= 0, as_tuple=False).flatten() # idxs where det(R) <= 0\n if len(entries_to_flip) > 0:\n Umod = U.clone()\n cols_to_flip = torch.argmin(sig[entries_to_flip], dim=1) # Get minimum singular value for each entry\n Umod[entries_to_flip, :, cols_to_flip] *= -1 # flip cols\n R[entries_to_flip] = torch.bmm(W[entries_to_flip], Umod[entries_to_flip].permute(0, 2, 1))\n arap_error = (weight[..., None] * (P_prime - torch.einsum('bxy,bky->bkx', R, P))).square().mean(dim=0).sum()\n\n if with_rot:\n init_rot = quaternion_to_matrix(trajectory_rot[:, 0])\n tar_rot = quaternion_to_matrix(trajectory_rot[:, fid])\n R_rot = torch.bmm(R, init_rot)\n rot_error = (R_rot - tar_rot).square().mean(dim=0).sum()\n else:\n rot_error = 0.\n\n return arap_error, rot_error * 1e2" }, { "id": 7088, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _calc_real_energy_matrix(self):\n \"\"\"\n Calculate real-space-part energy in atomic unit\n \"\"\"\n # calculate length between atoms `i` and `j` with `shift`\n shifts = get_shifts_within_cutoff(self.cell, self.cutoff_real) # (num_shifts, 3)\n # disps_ij[i, j, :] is displacement vector r_{ij}\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n disps = disps_ij[None, :, :, :] + torch.matmul(shifts, self.cell)[:, None, None, :]\n distances_all = torch.linalg.norm(disps, dim=-1) # (num_shifts, num_atoms, num_atoms)\n\n # retrieve pairs whose length are shorter than cutoff\n within_cutoff = (distances_all > self.eps) & (distances_all < self.cutoff_real)\n distances = distances_all[within_cutoff]\n\n e_real_matrix_aug = torch.zeros_like(distances_all)\n e_real_matrix_aug[within_cutoff] = torch.erfc(distances / (math.sqrt(2) * self.eta))\n if not self.point_charge:\n gammas_all = torch.sqrt(\n torch.square(self.sigmas[:, None]) + torch.square(self.sigmas[None, :])\n )\n gammas = torch.broadcast_to(gammas_all, distances_all.shape)[within_cutoff]\n e_real_matrix_aug[within_cutoff] -= torch.erfc(distances / (math.sqrt(2) * gammas))\n e_real_matrix_aug[within_cutoff] /= distances\n e_real_matrix = self.COULOMB_FACTOR * torch.sum(\n e_real_matrix_aug, dim=0\n ) # sum over shifts\n return e_real_matrix", "probing input": " def _calc_real_energy_matrix(self):\n \"\"\"\n Calculate real-space-part energy in atomic unit\n \"\"\"\n # calculate length between atoms `i` and `j` with `shift`\n shifts = get_shifts_within_cutoff(self.cell, self.cutoff_real) # (num_shifts, 3)\n # disps_ij[i, j, :] is displacement vector r_{ij}\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n disps = disps_ij[None, :, :, :] + torch.matmul(shifts, self.cell)[:, None, None, :]\n", "probing input new": " def _calc_real_energy_matrix(self):\n \"\"\"\n Calculate real-space-part energy in atomic unit\n \"\"\"\n # calculate length between atoms `i` and `j` with `shift`\n shifts = get_shifts_within_cutoff(self.cell, self.cutoff_real) # (num_shifts, 3)\n # disps_ij[i, j, :] is displacement vector r_{ij}\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n disps = disps_ij[None, :, :, :] + torch.matmul(shifts, self.cell)[:, None, None, :]\n distances_all = torch.", "reference": "distances_all=torch.linalg.norm(disps,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distances_all=torch.linalg.norm(disps,dim=-1)", "y_neg": " distances_all = torch.norm(disps, dim=-1)", "retain": " def _calc_real_energy_matrix(self):\n \"\"\"\n Calculate real-space-part energy in atomic unit\n \"\"\"\n # calculate length between atoms `i` and `j` with `shift`\n shifts = get_shifts_within_cutoff(self.cell, self.cutoff_real) # (num_shifts, 3)\n # disps_ij[i, j, :] is displacement vector r_{ij}\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n disps = disps_ij[None, :, :, :] + torch.matmul(shifts, self.cell)[:, None, None, :]\n distances_all = torch.linalg.norm(disps, dim=-1) # (num_shifts, num_atoms, num_atoms)\n\n # retrieve pairs whose length are shorter than cutoff\n within_cutoff = (distances_all > self.eps) & (distances_all < self.cutoff_real)\n distances = distances_all[within_cutoff]\n\n e_real_matrix_aug = torch.zeros_like(distances_all)\n e_real_matrix_aug[within_cutoff] = torch.erfc(distances / (math.sqrt(2) * self.eta))\n if not self.point_charge:\n gammas_all = torch.sqrt(\n torch.square(self.sigmas[:, None]) + torch.square(self.sigmas[None, :])\n )\n gammas = torch.broadcast_to(gammas_all, distances_all.shape)[within_cutoff]\n e_real_matrix_aug[within_cutoff] -= torch.erfc(distances / (math.sqrt(2) * gammas))\n e_real_matrix_aug[within_cutoff] /= distances\n e_real_matrix = self.COULOMB_FACTOR * torch.sum(\n e_real_matrix_aug, dim=0\n ) # sum over shifts\n return e_real_matrix" }, { "id": 7089, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _calc_reciprocal_energy_matrix(self):\n # calculate reciprocal points\n recip = get_reciprocal_vectors(self.cell)\n shifts = get_shifts_within_cutoff(recip, self.cutoff_recip) # (num_shifts, 3)\n ks_all = torch.matmul(shifts, recip)\n length_all = torch.linalg.norm(ks_all, dim=-1) # (num_shifts, )\n\n # retrieve reciprocal points whose length are shorter than cutoff\n within_cutoff = (length_all > self.eps) & (length_all < self.cutoff_recip)\n ks = ks_all[within_cutoff]\n length = length_all[within_cutoff]\n # disps_ij[i, j, :] is displacement vector r_{ij}, (num_atoms, num_atoms, 3)\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n phases = torch.sum(ks[:, None, None, :] * disps_ij[None, :, :, :], dim=-1)\n\n e_recip_matrix_aug = (\n torch.cos(phases)\n * torch.exp(-0.5 * torch.square(self.eta * length[:, None, None]))\n / torch.square(length[:, None, None])\n )\n e_recip_matrix = (\n self.COULOMB_FACTOR\n * 4.0\n * math.pi\n / self.volume\n * torch.sum(e_recip_matrix_aug, dim=0)\n )\n return e_recip_matrix", "probing input": " def _calc_reciprocal_energy_matrix(self):\n # calculate reciprocal points\n recip = get_reciprocal_vectors(self.cell)\n shifts = get_shifts_within_cutoff(recip, self.cutoff_recip) # (num_shifts, 3)\n ks_all = torch.matmul(shifts, recip)\n", "probing input new": " def _calc_reciprocal_energy_matrix(self):\n # calculate reciprocal points\n recip = get_reciprocal_vectors(self.cell)\n shifts = get_shifts_within_cutoff(recip, self.cutoff_recip) # (num_shifts, 3)\n ks_all = torch.matmul(shifts, recip)\n length_all = torch.", "reference": "length_all=torch.linalg.norm(ks_all,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "length_all=torch.linalg.norm(ks_all,dim=-1)", "y_neg": " length_all = torch.norm(ks_all, dim=1)", "retain": " def _calc_reciprocal_energy_matrix(self):\n # calculate reciprocal points\n recip = get_reciprocal_vectors(self.cell)\n shifts = get_shifts_within_cutoff(recip, self.cutoff_recip) # (num_shifts, 3)\n ks_all = torch.matmul(shifts, recip)\n length_all = torch.linalg.norm(ks_all, dim=-1) # (num_shifts, )\n\n # retrieve reciprocal points whose length are shorter than cutoff\n within_cutoff = (length_all > self.eps) & (length_all < self.cutoff_recip)\n ks = ks_all[within_cutoff]\n length = length_all[within_cutoff]\n # disps_ij[i, j, :] is displacement vector r_{ij}, (num_atoms, num_atoms, 3)\n disps_ij = self.pos[None, :, :] - self.pos[:, None, :]\n phases = torch.sum(ks[:, None, None, :] * disps_ij[None, :, :, :], dim=-1)\n\n e_recip_matrix_aug = (\n torch.cos(phases)\n * torch.exp(-0.5 * torch.square(self.eta * length[:, None, None]))\n / torch.square(length[:, None, None])\n )\n e_recip_matrix = (\n self.COULOMB_FACTOR\n * 4.0\n * math.pi\n / self.volume\n * torch.sum(e_recip_matrix_aug, dim=0)\n )\n return e_recip_matrix" }, { "id": 7090, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_shifts_within_cutoff(cell, cutoff):\n \"\"\"\n Return all shifts required to search for atoms within cutoff\n \"\"\"\n device = cell.device\n\n # projected length for three planes\n proj = torch.zeros(3, device=device)\n nx = torch.cross(cell[1], cell[2])\n ny = torch.cross(cell[2], cell[0])\n nz = torch.cross(cell[0], cell[1])\n proj[0] = torch.dot(cell[0], nx / torch.linalg.norm(nx))\n proj[1] = torch.dot(cell[1], ny / torch.linalg.norm(ny))\n proj[2] = torch.dot(cell[2], nz / torch.linalg.norm(nz))\n\n shift = torch.ceil(cutoff / torch.abs(proj))\n\n grid = torch.cartesian_prod(\n torch.arange(-shift[0], shift[0] + 1, device=device),\n torch.arange(-shift[1], shift[1] + 1, device=device),\n torch.arange(-shift[2], shift[2] + 1, device=device),\n )\n\n return grid", "probing input": "def get_shifts_within_cutoff(cell, cutoff):\n \"\"\"\n Return all shifts required to search for atoms within cutoff\n \"\"\"\n device = cell.device\n\n # projected length for three planes\n proj = torch.zeros(3, device=device)\n nx = torch.cross(cell[1], cell[2])\n ny = torch.cross(cell[2], cell[0])\n nz = torch.cross(cell[0], cell[1])\n", "probing input new": "def get_shifts_within_cutoff(cell, cutoff):\n \"\"\"\n Return all shifts required to search for atoms within cutoff\n \"\"\"\n device = cell.device\n\n # projected length for three planes\n proj = torch.zeros(3, device=device)\n nx = torch.cross(cell[1], cell[2])\n ny = torch.cross(cell[2], cell[0])\n nz = torch.cross(cell[0], cell[1])\n proj[0] = torch.dot(cell[0], nx / torch.", "reference": "proj[0]=torch.dot(cell[0],nx/torch.linalg.norm(nx))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "proj[0]=torch.dot(cell[0],nx/torch.linalg.norm(nx))", "y_neg": " proj[0] = torch.dot(cell[0], nx / torch.norm(nx))", "retain": "def get_shifts_within_cutoff(cell, cutoff):\n \"\"\"\n Return all shifts required to search for atoms within cutoff\n \"\"\"\n device = cell.device\n\n # projected length for three planes\n proj = torch.zeros(3, device=device)\n nx = torch.cross(cell[1], cell[2])\n ny = torch.cross(cell[2], cell[0])\n nz = torch.cross(cell[0], cell[1])\n proj[0] = torch.dot(cell[0], nx / torch.linalg.norm(nx))\n proj[1] = torch.dot(cell[1], ny / torch.linalg.norm(ny))\n proj[2] = torch.dot(cell[2], nz / torch.linalg.norm(nz))\n\n shift = torch.ceil(cutoff / torch.abs(proj))\n\n grid = torch.cartesian_prod(\n torch.arange(-shift[0], shift[0] + 1, device=device),\n torch.arange(-shift[1], shift[1] + 1, device=device),\n torch.arange(-shift[2], shift[2] + 1, device=device),\n )\n\n return grid" }, { "id": 7093, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, positions):\n def contract(x):\n x = x * self.scale_factor\n \n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n\n return x_new\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n\n if self.scale_factor != 1.0:\n raise NotImplementedError('Scaling of gaussian covariances is not implemented.')\n \n # FIXME: covariances are not handled for now!\n contract = lambda x: (2 - (1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True))) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n jc_means = vmap(jacrev(contract))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)", "probing input": " def forward(self, positions):\n def contract(x):\n x = x * self.scale_factor\n \n", "probing input new": " def forward(self, positions):\n def contract(x):\n x = x * self.scale_factor\n \n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)", "y_neg": " mag = torch.norm(x, p=2, dim=1, keepdim=True)", "retain": " def forward(self, positions):\n def contract(x):\n x = x * self.scale_factor\n \n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n\n return x_new\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n\n if self.scale_factor != 1.0:\n raise NotImplementedError('Scaling of gaussian covariances is not implemented.')\n \n # FIXME: covariances are not handled for now!\n contract = lambda x: (2 - (1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True))) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n jc_means = vmap(jacrev(contract))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)" }, { "id": 7094, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, positions):\n def _contract(x):\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n\n return x_new\n\n def contract(x):\n x = x * self.scale_factor\n if self.aabb is None:\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n else:\n in_aabb_mask = ((x >= self.aabb[0]) & (x <= self.aabb[1])).all(-1) # whether including = ?\n mask = ~in_aabb_mask\n x_new = x.clone()\n x_new[mask] = x[mask] / self.alpha\n return _contract(x_new)\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n # FIXME: covariances are not handled for now!\n if self.scale_factor != 1.0:\n raise NotImplementedError('Scaling of gaussian covariances is not implemented.')\n contract = lambda x: (2 - (1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True))) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n jc_means = vmap(jacrev(contract))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)", "probing input": " def forward(self, positions):\n def _contract(x):\n", "probing input new": " def forward(self, positions):\n def _contract(x):\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)", "y_neg": " mag = torch.norm(x, p=2, dim=1, keepdim=True)", "retain": " def forward(self, positions):\n def _contract(x):\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n\n return x_new\n\n def contract(x):\n x = x * self.scale_factor\n if self.aabb is None:\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)\n mask = mag >= 1\n else:\n in_aabb_mask = ((x >= self.aabb[0]) & (x <= self.aabb[1])).all(-1) # whether including = ?\n mask = ~in_aabb_mask\n x_new = x.clone()\n x_new[mask] = x[mask] / self.alpha\n return _contract(x_new)\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n # FIXME: covariances are not handled for now!\n if self.scale_factor != 1.0:\n raise NotImplementedError('Scaling of gaussian covariances is not implemented.')\n contract = lambda x: (2 - (1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True))) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n jc_means = vmap(jacrev(contract))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)" }, { "id": 7098, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_norm(self, grad: Tensor) -> Tensor:\n return torch.linalg.norm(self.precondition(grad))", "probing input": " def compute_norm(self, grad: Tensor) -> Tensor:\n", "probing input new": " def compute_norm(self, grad: Tensor) -> Tensor:\n return torch.", "reference": "returntorch.linalg.norm(self.precondition(grad))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(self.precondition(grad))", "y_neg": " return torch.norm(grad, p=2, dim=1)", "retain": " def compute_norm(self, grad: Tensor) -> Tensor:\n return torch.linalg.norm(self.precondition(grad))" }, { "id": 7102, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_accel_norm(joints):\n \"\"\"\n :param joints (T, J, 3)\n \"\"\"\n vel = joints[1:] - joints[:-1] # (T-1, J, 3)\n acc = vel[1:] - vel[:-1] # (T-2, J, 3)\n return torch.linalg.norm(acc, dim=-1)", "probing input": "def compute_accel_norm(joints):\n \"\"\"\n :param joints (T, J, 3)\n \"\"\"\n vel = joints[1:] - joints[:-1] # (T-1, J, 3)\n acc = vel[1:] - vel[:-1] # (T-2, J, 3)\n", "probing input new": "def compute_accel_norm(joints):\n \"\"\"\n :param joints (T, J, 3)\n \"\"\"\n vel = joints[1:] - joints[:-1] # (T-1, J, 3)\n acc = vel[1:] - vel[:-1] # (T-2, J, 3)\n return torch.", "reference": "returntorch.linalg.norm(acc,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(acc,dim=-1)", "y_neg": " return torch.norm(acc, p=2, dim=-1) # (T-2, J)", "retain": "def compute_accel_norm(joints):\n \"\"\"\n :param joints (T, J, 3)\n \"\"\"\n vel = joints[1:] - joints[:-1] # (T-1, J, 3)\n acc = vel[1:] - vel[:-1] # (T-2, J, 3)\n return torch.linalg.norm(acc, dim=-1)" }, { "id": 7103, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lookAt(eye, at, up):\n a = eye - at\n w = a / torch.linalg.norm(a)\n u = torch.cross(up, w)\n u = u / torch.linalg.norm(u)\n v = torch.cross(w, u)\n translate = torch.tensor([[1, 0, 0, -eye[0]], \n [0, 1, 0, -eye[1]], \n [0, 0, 1, -eye[2]], \n [0, 0, 0, 1]], dtype=eye.dtype, device=eye.device)\n rotate = torch.tensor([[u[0], u[1], u[2], 0], \n [v[0], v[1], v[2], 0], \n [w[0], w[1], w[2], 0], \n [0, 0, 0, 1]], dtype=eye.dtype, device=eye.device)\n return rotate @ translate", "probing input": "def lookAt(eye, at, up):\n a = eye - at\n", "probing input new": "def lookAt(eye, at, up):\n a = eye - at\n w = a / torch.", "reference": "w=a/torch.linalg.norm(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "w=a/torch.linalg.norm(a)", "y_neg": " w = a / torch.norm(a)", "retain": "def lookAt(eye, at, up):\n a = eye - at\n w = a / torch.linalg.norm(a)\n u = torch.cross(up, w)\n u = u / torch.linalg.norm(u)\n v = torch.cross(w, u)\n translate = torch.tensor([[1, 0, 0, -eye[0]], \n [0, 1, 0, -eye[1]], \n [0, 0, 1, -eye[2]], \n [0, 0, 0, 1]], dtype=eye.dtype, device=eye.device)\n rotate = torch.tensor([[u[0], u[1], u[2], 0], \n [v[0], v[1], v[2], 0], \n [w[0], w[1], w[2], 0], \n [0, 0, 0, 1]], dtype=eye.dtype, device=eye.device)\n return rotate @ translate" }, { "id": 7107, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n \n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1], device=sdf.device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1], device=alpha.device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n \n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1], device=sdf.device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1], device=alpha.device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n return z_samples" }, { "id": 7109, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n q = torch.stack([(pixels_x/self.W-0.5)*2, (pixels_y/self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1) # W, H, 3\n\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n\n # orthogonal projection\n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3].cuda(), rays_v[:, :, :, None].cuda()).squeeze() # W, H, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, None, :3, :3].cuda(), q[:, :, :, None].cuda()).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape).cuda() + rays_o # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n q = torch.stack([(pixels_x/self.W-0.5)*2, (pixels_y/self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1) # W, H, 3\n\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n\n # orthogonal projection\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n q = torch.stack([(pixels_x/self.W-0.5)*2, (pixels_y/self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1) # W, H, 3\n\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n\n # orthogonal projection\n rays_v = v / torch.", "reference": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = v / torch.norm(v, dim=-1, keepdim=True)", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n q = torch.stack([(pixels_x/self.W-0.5)*2, (pixels_y/self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1) # W, H, 3\n\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n\n # orthogonal projection\n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3].cuda(), rays_v[:, :, :, None].cuda()).squeeze() # W, H, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, None, :3, :3].cuda(), q[:, :, :, None].cuda()).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape).cuda() + rays_o # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7110, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu() \n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu() \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n\n # q = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # bsz, 3\n # q = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], q[:, :, None]).squeeze() # bsz, 3\n # q[:, 2] = 0\n \n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, :3, :3], q[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) + rays_o # batch_size, 3\n \n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, None], normal], dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu() \n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu() \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n\n # q = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # bsz, 3\n # q = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], q[:, :, None]).squeeze() # bsz, 3\n # q[:, 2] = 0\n \n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu() \n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu() \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n\n # q = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # bsz, 3\n # q = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], q[:, :, None]).squeeze() # bsz, 3\n # q[:, 2] = 0\n \n rays_v = v / torch.", "reference": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = v / torch.norm(v, dim=-1, keepdim=True) # bsz, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu() \n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu() \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n\n # q = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # bsz, 3\n # q = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], q[:, :, None]).squeeze() # bsz, 3\n # q[:, 2] = 0\n \n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, :3, :3], q[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) + rays_o # batch_size, 3\n \n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, None], normal], dim=-1).cuda()" }, { "id": 7111, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def prepare_rays_a_view(self, img_idx):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n pixels_x = pixels_x.reshape(-1).long()\n pixels_y = pixels_y.reshape(-1).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n \n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, :3, :3], q[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) + rays_o # batch_size, 3\n\n cosines = self.cos(rays_v, normal)\n\n # pdb.set_trace()\n \n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, None], normal, cosines[:, None]], dim=-1)", "probing input": " def prepare_rays_a_view(self, img_idx):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n pixels_x = pixels_x.reshape(-1).long()\n pixels_y = pixels_y.reshape(-1).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n \n", "probing input new": " def prepare_rays_a_view(self, img_idx):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n pixels_x = pixels_x.reshape(-1).long()\n pixels_y = pixels_y.reshape(-1).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n \n rays_v = v / torch.", "reference": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=v/torch.linalg.norm(v,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = v / torch.norm(v, dim=-1, keepdim=True)", "retain": " def prepare_rays_a_view(self, img_idx):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n pixels_x = pixels_x.reshape(-1).long()\n pixels_y = pixels_y.reshape(-1).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n normal = self.normals_world[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n \n q = torch.stack([(pixels_x / self.W-0.5)*2, (pixels_y / self.H-0.5)*2, torch.zeros_like(pixels_y)], dim=-1).float() # batch_size, 3\n v = torch.stack([torch.zeros_like(pixels_y), torch.zeros_like(pixels_y), torch.ones_like(pixels_y)], dim=-1).float()\n \n rays_v = v / torch.linalg.norm(v, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n \n rays_o = torch.matmul(self.pose_all[img_idx, None, :3, :3], q[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) + rays_o # batch_size, 3\n\n cosines = self.cos(rays_v, normal)\n\n # pdb.set_trace()\n \n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, None], normal, cosines[:, None]], dim=-1)" }, { "id": 7112, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7113, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _encode_prompt(self, prompt):\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > self.tokenizer.model_max_length:\n removed_text = self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : self.tokenizer.model_max_length]\n prompt_embeds = self.clip.get_text_features(text_input_ids.to(self.device))\n prompt_embeds = prompt_embeds / torch.linalg.norm(prompt_embeds, dim=-1, keepdim=True)\n prompt_embeds = prompt_embeds[:, None, :]\n return prompt_embeds", "probing input": " def _encode_prompt(self, prompt):\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > self.tokenizer.model_max_length:\n removed_text = self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : self.tokenizer.model_max_length]\n prompt_embeds = self.clip.get_text_features(text_input_ids.to(self.device))\n", "probing input new": " def _encode_prompt(self, prompt):\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > self.tokenizer.model_max_length:\n removed_text = self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : self.tokenizer.model_max_length]\n prompt_embeds = self.clip.get_text_features(text_input_ids.to(self.device))\n prompt_embeds = prompt_embeds / torch.", "reference": "prompt_embeds=prompt_embeds/torch.linalg.norm(prompt_embeds,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "prompt_embeds=prompt_embeds/torch.linalg.norm(prompt_embeds,dim=-1,keepdim=True)", "y_neg": " prompt_embeds = prompt_embeds / torch.norm(prompt_embeds, dim=-1, keepdim=True)", "retain": " def _encode_prompt(self, prompt):\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > self.tokenizer.model_max_length:\n removed_text = self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : self.tokenizer.model_max_length]\n prompt_embeds = self.clip.get_text_features(text_input_ids.to(self.device))\n prompt_embeds = prompt_embeds / torch.linalg.norm(prompt_embeds, dim=-1, keepdim=True)\n prompt_embeds = prompt_embeds[:, None, :]\n return prompt_embeds" }, { "id": 7114, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _encode_image(self, retrieved_images, batch_size):\n if len(retrieved_images[0]) == 0:\n return None\n for i in range(len(retrieved_images)):\n retrieved_images[i] = normalize_images(retrieved_images[i])\n retrieved_images[i] = preprocess_images(retrieved_images[i], self.feature_extractor).to(\n self.clip.device, dtype=self.clip.dtype\n )\n _, c, h, w = retrieved_images[0].shape\n\n retrieved_images = torch.reshape(torch.cat(retrieved_images, dim=0), (-1, c, h, w))\n image_embeddings = self.clip.get_image_features(retrieved_images)\n image_embeddings = image_embeddings / torch.linalg.norm(image_embeddings, dim=-1, keepdim=True)\n _, d = image_embeddings.shape\n image_embeddings = torch.reshape(image_embeddings, (batch_size, -1, d))\n return image_embeddings", "probing input": " def _encode_image(self, retrieved_images, batch_size):\n if len(retrieved_images[0]) == 0:\n return None\n for i in range(len(retrieved_images)):\n retrieved_images[i] = normalize_images(retrieved_images[i])\n retrieved_images[i] = preprocess_images(retrieved_images[i], self.feature_extractor).to(\n self.clip.device, dtype=self.clip.dtype\n )\n _, c, h, w = retrieved_images[0].shape\n\n retrieved_images = torch.reshape(torch.cat(retrieved_images, dim=0), (-1, c, h, w))\n image_embeddings = self.clip.get_image_features(retrieved_images)\n", "probing input new": " def _encode_image(self, retrieved_images, batch_size):\n if len(retrieved_images[0]) == 0:\n return None\n for i in range(len(retrieved_images)):\n retrieved_images[i] = normalize_images(retrieved_images[i])\n retrieved_images[i] = preprocess_images(retrieved_images[i], self.feature_extractor).to(\n self.clip.device, dtype=self.clip.dtype\n )\n _, c, h, w = retrieved_images[0].shape\n\n retrieved_images = torch.reshape(torch.cat(retrieved_images, dim=0), (-1, c, h, w))\n image_embeddings = self.clip.get_image_features(retrieved_images)\n image_embeddings = image_embeddings / torch.", "reference": "image_embeddings=image_embeddings/torch.linalg.norm(image_embeddings,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "image_embeddings=image_embeddings/torch.linalg.norm(image_embeddings,dim=-1,keepdim=True)", "y_neg": " image_embeddings = image_embeddings / torch.norm(image_embeddings, dim=1, keepdim=True)", "retain": " def _encode_image(self, retrieved_images, batch_size):\n if len(retrieved_images[0]) == 0:\n return None\n for i in range(len(retrieved_images)):\n retrieved_images[i] = normalize_images(retrieved_images[i])\n retrieved_images[i] = preprocess_images(retrieved_images[i], self.feature_extractor).to(\n self.clip.device, dtype=self.clip.dtype\n )\n _, c, h, w = retrieved_images[0].shape\n\n retrieved_images = torch.reshape(torch.cat(retrieved_images, dim=0), (-1, c, h, w))\n image_embeddings = self.clip.get_image_features(retrieved_images)\n image_embeddings = image_embeddings / torch.linalg.norm(image_embeddings, dim=-1, keepdim=True)\n _, d = image_embeddings.shape\n image_embeddings = torch.reshape(image_embeddings, (batch_size, -1, d))\n return image_embeddings" }, { "id": 7115, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_param_norms(model, optimizer, param_id_to_buffer):\n weight_norms = {}\n other_norms = {}\n for name, param in model.named_parameters():\n buf = param_id_to_buffer[id(param)]\n param_norm = torch.linalg.norm(buf) ** 2\n other_norm = torch.linalg.norm(param.ds_tensor.data) ** 2\n torch.distributed.all_reduce(param_norm, group=optimizer.ds_param_shard_group)\n torch.distributed.all_reduce(other_norm, group=optimizer.ds_param_shard_group)\n weight_norms[name] = torch.sqrt(param_norm).item()\n other_norms[name] = torch.sqrt(other_norm).item()\n if smp.rank() == 0:\n print(f\"{name}: {weight_norms[name]} {other_norms[name]}\")", "probing input": "def log_param_norms(model, optimizer, param_id_to_buffer):\n weight_norms = {}\n other_norms = {}\n for name, param in model.named_parameters():\n buf = param_id_to_buffer[id(param)]\n", "probing input new": "def log_param_norms(model, optimizer, param_id_to_buffer):\n weight_norms = {}\n other_norms = {}\n for name, param in model.named_parameters():\n buf = param_id_to_buffer[id(param)]\n param_", "reference": "param_norm=torch.linalg.norm(buf)**2", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "param_norm=torch.linalg.norm(buf)**2", "y_neg": " param_norm = torch.norm(param)", "retain": "def log_param_norms(model, optimizer, param_id_to_buffer):\n weight_norms = {}\n other_norms = {}\n for name, param in model.named_parameters():\n buf = param_id_to_buffer[id(param)]\n param_norm = torch.linalg.norm(buf) ** 2\n other_norm = torch.linalg.norm(param.ds_tensor.data) ** 2\n torch.distributed.all_reduce(param_norm, group=optimizer.ds_param_shard_group)\n torch.distributed.all_reduce(other_norm, group=optimizer.ds_param_shard_group)\n weight_norms[name] = torch.sqrt(param_norm).item()\n other_norms[name] = torch.sqrt(other_norm).item()\n if smp.rank() == 0:\n print(f\"{name}: {weight_norms[name]} {other_norms[name]}\")" }, { "id": 7116, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[Tensor] = None,\n quats: Optional[Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[Tensor] = None,\n quats: Optional[Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[Tensor] = None,\n quats: Optional[Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[Tensor] = None,\n quats: Optional[Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (rot_mats is not None and quats is not None):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7117, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def render_views_from_rays(\n render_rays: Callable[[AttrDict, AttrDict, AttrDict], AttrDict],\n batch: AttrDict,\n params: Optional[Dict] = None,\n options: Optional[Dict] = None,\n device: torch.device = torch.device(\"cuda\"),\n) -> AttrDict:\n camera, batch_size, inner_shape = get_camera_from_batch(batch)\n inner_batch_size = int(np.prod(inner_shape))\n\n coords = get_image_coords(camera.width, camera.height).to(device)\n coords = torch.broadcast_to(coords.unsqueeze(0), [batch_size * inner_batch_size, *coords.shape])\n rays = camera.camera_rays(coords)\n\n # mip-NeRF radii calculation from: https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L193-L200\n directions = rays.view(batch_size, inner_batch_size, camera.height, camera.width, 2, 3)[\n ..., 1, :\n ]\n neighbor_dists = torch.linalg.norm(directions[:, :, :, 1:] - directions[:, :, :, :-1], dim=-1)\n neighbor_dists = torch.cat([neighbor_dists, neighbor_dists[:, :, :, -2:-1]], dim=3)\n radii = (neighbor_dists * 2 / np.sqrt(12)).view(batch_size, -1, 1)\n\n rays = rays.view(batch_size, inner_batch_size * camera.height * camera.width, 2, 3)\n\n if isinstance(camera, DifferentiableProjectiveCamera):\n # Compute the camera z direction corresponding to every ray's pixel.\n # Used for depth computations below.\n z_directions = (\n (camera.z / torch.linalg.norm(camera.z, dim=-1, keepdim=True))\n .reshape([batch_size, inner_batch_size, 1, 3])\n .repeat(1, 1, camera.width * camera.height, 1)\n .reshape(1, inner_batch_size * camera.height * camera.width, 3)\n )\n\n ray_batch_size = batch.get(\"ray_batch_size\", batch.get(\"inner_batch_size\", 4096))\n assert rays.shape[1] % ray_batch_size == 0\n n_batches = rays.shape[1] // ray_batch_size\n\n output_list = AttrDict(aux_losses=dict())\n\n for idx in range(n_batches):\n rays_batch = AttrDict(\n rays=rays[:, idx * ray_batch_size : (idx + 1) * ray_batch_size],\n radii=radii[:, idx * ray_batch_size : (idx + 1) * ray_batch_size],\n )\n output = render_rays(rays_batch, params=params, options=options)\n\n if isinstance(camera, DifferentiableProjectiveCamera):\n z_batch = z_directions[:, idx * ray_batch_size : (idx + 1) * ray_batch_size]\n ray_directions = rays_batch.rays[:, :, 1]\n z_dots = (ray_directions * z_batch).sum(-1, keepdim=True)\n output.depth = output.distances * z_dots\n\n output_list = output_list.combine(output, append_tensor)\n\n def _resize(val_list: List[torch.Tensor]):\n val = torch.cat(val_list, dim=1)\n assert val.shape[1] == inner_batch_size * camera.height * camera.width\n return val.view(batch_size, *inner_shape, camera.height, camera.width, -1)\n\n def _avg(_key: str, loss_list: List[torch.Tensor]):\n return sum(loss_list) / n_batches\n\n output = AttrDict(\n {name: _resize(val_list) for name, val_list in output_list.items() if name != \"aux_losses\"}\n )\n output.aux_losses = output_list.aux_losses.map(_avg)\n\n #Tiange modified\n #alpha = imgs[..., -1:]\n #mask = (alpha < 0.000001).expand_as(imgs) \n #imgs[mask] = 222.0/255.0 #\n output['channels'] += (output['transmittance']==1).expand_as(output['channels'])*207\n\n return output", "probing input": "def render_views_from_rays(\n render_rays: Callable[[AttrDict, AttrDict, AttrDict], AttrDict],\n batch: AttrDict,\n params: Optional[Dict] = None,\n options: Optional[Dict] = None,\n device: torch.device = torch.device(\"cuda\"),\n) -> AttrDict:\n camera, batch_size, inner_shape = get_camera_from_batch(batch)\n inner_batch_size = int(np.prod(inner_shape))\n\n coords = get_image_coords(camera.width, camera.height).to(device)\n coords = torch.broadcast_to(coords.unsqueeze(0), [batch_size * inner_batch_size, *coords.shape])\n rays = camera.camera_rays(coords)\n\n # mip-NeRF radii calculation from: https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L193-L200\n directions = rays.view(batch_size, inner_batch_size, camera.height, camera.width, 2, 3)[\n ..., 1, :\n ]\n", "probing input new": "def render_views_from_rays(\n render_rays: Callable[[AttrDict, AttrDict, AttrDict], AttrDict],\n batch: AttrDict,\n params: Optional[Dict] = None,\n options: Optional[Dict] = None,\n device: torch.device = torch.device(\"cuda\"),\n) -> AttrDict:\n camera, batch_size, inner_shape = get_camera_from_batch(batch)\n inner_batch_size = int(np.prod(inner_shape))\n\n coords = get_image_coords(camera.width, camera.height).to(device)\n coords = torch.broadcast_to(coords.unsqueeze(0), [batch_size * inner_batch_size, *coords.shape])\n rays = camera.camera_rays(coords)\n\n # mip-NeRF radii calculation from: https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L193-L200\n directions = rays.view(batch_size, inner_batch_size, camera.height, camera.width, 2, 3)[\n ..., 1, :\n ]\n neighbor_dists = torch.", "reference": "neighbor_dists=torch.linalg.norm(directions[:,:,:,1:]-directions[:,:,:,:-1],dim=-1)", "reference dict": { "output_list": "AttrDict", "output": "AttrDict", "rays_batch": "AttrDict" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "neighbor_dists=torch.linalg.norm(directions[:,:,:,1:]-directions[:,:,:,:-1],dim=-1)", "y_neg": " neighbor_dists = torch.norm(directions, dim=-1)", "retain": "def render_views_from_rays(\n render_rays: Callable[[AttrDict, AttrDict, AttrDict], AttrDict],\n batch: AttrDict,\n params: Optional[Dict] = None,\n options: Optional[Dict] = None,\n device: torch.device = torch.device(\"cuda\"),\n) -> AttrDict:\n camera, batch_size, inner_shape = get_camera_from_batch(batch)\n inner_batch_size = int(np.prod(inner_shape))\n\n coords = get_image_coords(camera.width, camera.height).to(device)\n coords = torch.broadcast_to(coords.unsqueeze(0), [batch_size * inner_batch_size, *coords.shape])\n rays = camera.camera_rays(coords)\n\n # mip-NeRF radii calculation from: https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L193-L200\n directions = rays.view(batch_size, inner_batch_size, camera.height, camera.width, 2, 3)[\n ..., 1, :\n ]\n neighbor_dists = torch.linalg.norm(directions[:, :, :, 1:] - directions[:, :, :, :-1], dim=-1)\n neighbor_dists = torch.cat([neighbor_dists, neighbor_dists[:, :, :, -2:-1]], dim=3)\n radii = (neighbor_dists * 2 / np.sqrt(12)).view(batch_size, -1, 1)\n\n rays = rays.view(batch_size, inner_batch_size * camera.height * camera.width, 2, 3)\n\n if isinstance(camera, DifferentiableProjectiveCamera):\n # Compute the camera z direction corresponding to every ray's pixel.\n # Used for depth computations below.\n z_directions = (\n (camera.z / torch.linalg.norm(camera.z, dim=-1, keepdim=True))\n .reshape([batch_size, inner_batch_size, 1, 3])\n .repeat(1, 1, camera.width * camera.height, 1)\n .reshape(1, inner_batch_size * camera.height * camera.width, 3)\n )\n\n ray_batch_size = batch.get(\"ray_batch_size\", batch.get(\"inner_batch_size\", 4096))\n assert rays.shape[1] % ray_batch_size == 0\n n_batches = rays.shape[1] // ray_batch_size\n\n output_list = AttrDict(aux_losses=dict())\n\n for idx in range(n_batches):\n rays_batch = AttrDict(\n rays=rays[:, idx * ray_batch_size : (idx + 1) * ray_batch_size],\n radii=radii[:, idx * ray_batch_size : (idx + 1) * ray_batch_size],\n )\n output = render_rays(rays_batch, params=params, options=options)\n\n if isinstance(camera, DifferentiableProjectiveCamera):\n z_batch = z_directions[:, idx * ray_batch_size : (idx + 1) * ray_batch_size]\n ray_directions = rays_batch.rays[:, :, 1]\n z_dots = (ray_directions * z_batch).sum(-1, keepdim=True)\n output.depth = output.distances * z_dots\n\n output_list = output_list.combine(output, append_tensor)\n\n def _resize(val_list: List[torch.Tensor]):\n val = torch.cat(val_list, dim=1)\n assert val.shape[1] == inner_batch_size * camera.height * camera.width\n return val.view(batch_size, *inner_shape, camera.height, camera.width, -1)\n\n def _avg(_key: str, loss_list: List[torch.Tensor]):\n return sum(loss_list) / n_batches\n\n output = AttrDict(\n {name: _resize(val_list) for name, val_list in output_list.items() if name != \"aux_losses\"}\n )\n output.aux_losses = output_list.aux_losses.map(_avg)\n\n #Tiange modified\n #alpha = imgs[..., -1:]\n #mask = (alpha < 0.000001).expand_as(imgs) \n #imgs[mask] = 222.0/255.0 #\n output['channels'] += (output['transmittance']==1).expand_as(output['channels'])*207\n\n return output" }, { "id": 7118, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, text):\n tokens = self.tokenize(self.tokenizer, text, context_length=self.max_length).to(self.device)\n z = self.model(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z", "probing input": " def forward(self, text):\n tokens = self.tokenize(self.tokenizer, text, context_length=self.max_length).to(self.device)\n z = self.model(tokens)\n if self.normalize:\n", "probing input new": " def forward(self, text):\n tokens = self.tokenize(self.tokenizer, text, context_length=self.max_length).to(self.device)\n z = self.model(tokens)\n if self.normalize:\n z = z / torch.", "reference": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "y_neg": " z = z / torch.norm(z, dim=-1, keepdim=True)", "retain": " def forward(self, text):\n tokens = self.tokenize(self.tokenizer, text, context_length=self.max_length).to(self.device)\n z = self.model(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z" }, { "id": 7129, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x0, x1, y):\n #方向,点乘小丸子\n #欧式,最后的分类的\n self.idx+=1\n x0_soft = F.softmax(x0,1)\n x1_soft = F.softmax(x1,1)\n # cosdis = torch.sum(x0_soft*x0_soft) + torch.sum(x1_soft*x1_soft) - 2* torch.mm(x0_soft, torch.transpose(x1_soft,0,1))\n cosdis = torch.matmul(x0_soft, x1_soft.T)\n coslabel = torch.diag(cosdis)\n coslabel = torch.div(coslabel, torch.linalg.norm(x0_soft, 1) * torch.linalg.norm(x1_soft, 1))\n\n if self.idx==60:\n coslabel = torch.div(coslabel, torch.linalg.norm(x0_soft, 1) * torch.linalg.norm(x1_soft, 1))\n e_diff = x0 - x1\n e_dist_sq = torch.sum(torch.pow(e_diff, 2), 1)\n e_dist = torch.sqrt(e_dist_sq)\n e_mdist = self.margin - e_dist\n e_dist = torch.clamp(e_mdist, min=0.0)\n # e_loss = y*coslabel*e_dist_sq + (1-y)*coslabel* torch.pow(e_dist, 2)\n e_loss = 2*y*abs(y-0.5)*e_dist_sq + 2*(1 - y)* abs(y-0.5) * torch.pow(e_dist, 2) + 400*y*(1-y)*e_dist_sq* coslabel\n # e_loss = y*e_dist_sq + (1 - y)*torch.pow(e_dist, 2)\n\n loss_1 = torch.sum(e_loss) / 2.0 / x0.size()[0]\n\n return loss_1", "probing input": " def forward(self, x0, x1, y):\n #方向,点乘小丸子\n #欧式,最后的分类的\n self.idx+=1\n x0_soft = F.softmax(x0,1)\n x1_soft = F.softmax(x1,1)\n # cosdis = torch.sum(x0_soft*x0_soft) + torch.sum(x1_soft*x1_soft) - 2* torch.mm(x0_soft, torch.transpose(x1_soft,0,1))\n cosdis = torch.matmul(x0_soft, x1_soft.T)\n coslabel = torch.diag(cosdis)\n", "probing input new": " def forward(self, x0, x1, y):\n #方向,点乘小丸子\n #欧式,最后的分类的\n self.idx+=1\n x0_soft = F.softmax(x0,1)\n x1_soft = F.softmax(x1,1)\n # cosdis = torch.sum(x0_soft*x0_soft) + torch.sum(x1_soft*x1_soft) - 2* torch.mm(x0_soft, torch.transpose(x1_soft,0,1))\n cosdis = torch.matmul(x0_soft, x1_soft.T)\n coslabel = torch.diag(cosdis)\n coslabel = torch.div(coslabel, torch.", "reference": "coslabel=torch.div(coslabel,torch.linalg.norm(x0_soft,1)*torch.linalg.norm(x1_soft,1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "coslabel=torch.div(coslabel,torch.linalg.norm(x0_soft,1)*torch.linalg.norm(x1_soft,1))", "y_neg": " coslabel = torch.div(coslabel, torch.norm(cosdis, 2, 1, True))", "retain": " def forward(self, x0, x1, y):\n #方向,点乘小丸子\n #欧式,最后的分类的\n self.idx+=1\n x0_soft = F.softmax(x0,1)\n x1_soft = F.softmax(x1,1)\n # cosdis = torch.sum(x0_soft*x0_soft) + torch.sum(x1_soft*x1_soft) - 2* torch.mm(x0_soft, torch.transpose(x1_soft,0,1))\n cosdis = torch.matmul(x0_soft, x1_soft.T)\n coslabel = torch.diag(cosdis)\n coslabel = torch.div(coslabel, torch.linalg.norm(x0_soft, 1) * torch.linalg.norm(x1_soft, 1))\n\n if self.idx==60:\n coslabel = torch.div(coslabel, torch.linalg.norm(x0_soft, 1) * torch.linalg.norm(x1_soft, 1))\n e_diff = x0 - x1\n e_dist_sq = torch.sum(torch.pow(e_diff, 2), 1)\n e_dist = torch.sqrt(e_dist_sq)\n e_mdist = self.margin - e_dist\n e_dist = torch.clamp(e_mdist, min=0.0)\n # e_loss = y*coslabel*e_dist_sq + (1-y)*coslabel* torch.pow(e_dist, 2)\n e_loss = 2*y*abs(y-0.5)*e_dist_sq + 2*(1 - y)* abs(y-0.5) * torch.pow(e_dist, 2) + 400*y*(1-y)*e_dist_sq* coslabel\n # e_loss = y*e_dist_sq + (1 - y)*torch.pow(e_dist, 2)\n\n loss_1 = torch.sum(e_loss) / 2.0 / x0.size()[0]\n\n return loss_1" }, { "id": 7131, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def distance_to_depth(K, dist, uv=None):\n if uv is None and len(dist.shape) >= 2:\n # create mesh grid according to d\n uv = np.stack(np.meshgrid(np.arange(dist.shape[1]), np.arange(dist.shape[0])), -1)\n uv = uv.reshape(-1, 2)\n dist = dist.reshape(-1)\n if not isinstance(dist, np.ndarray):\n uv = torch.from_numpy(uv).to(dist)\n if isinstance(dist, np.ndarray):\n # z * np.sqrt(x_temp**2+y_temp**2+z_temp**2) = dist\n uvh = np.concatenate([uv, np.ones((len(uv), 1))], -1)\n temp_point = dot(np.linalg.inv(K), uvh)\n z = dist / np.linalg.norm(temp_point, axis=1)\n\n else:\n uvh = torch.cat([uv, torch.ones(len(uv), 1).to(uv)], -1)\n temp_point = dot(torch.inverse(K), uvh)\n z = dist / torch.linalg.norm(temp_point, dim=1)\n return z", "probing input": "def distance_to_depth(K, dist, uv=None):\n if uv is None and len(dist.shape) >= 2:\n # create mesh grid according to d\n uv = np.stack(np.meshgrid(np.arange(dist.shape[1]), np.arange(dist.shape[0])), -1)\n uv = uv.reshape(-1, 2)\n dist = dist.reshape(-1)\n if not isinstance(dist, np.ndarray):\n uv = torch.from_numpy(uv).to(dist)\n if isinstance(dist, np.ndarray):\n # z * np.sqrt(x_temp**2+y_temp**2+z_temp**2) = dist\n uvh = np.concatenate([uv, np.ones((len(uv), 1))], -1)\n temp_point = dot(np.linalg.inv(K), uvh)\n z = dist / np.linalg.norm(temp_point, axis=1)\n\n else:\n uvh = torch.cat([uv, torch.ones(len(uv), 1).to(uv)], -1)\n temp_point = dot(torch.inverse(K), uvh)\n", "probing input new": "def distance_to_depth(K, dist, uv=None):\n if uv is None and len(dist.shape) >= 2:\n # create mesh grid according to d\n uv = np.stack(np.meshgrid(np.arange(dist.shape[1]), np.arange(dist.shape[0])), -1)\n uv = uv.reshape(-1, 2)\n dist = dist.reshape(-1)\n if not isinstance(dist, np.ndarray):\n uv = torch.from_numpy(uv).to(dist)\n if isinstance(dist, np.ndarray):\n # z * np.sqrt(x_temp**2+y_temp**2+z_temp**2) = dist\n uvh = np.concatenate([uv, np.ones((len(uv), 1))], -1)\n temp_point = dot(np.linalg.inv(K), uvh)\n z = dist / np.linalg.norm(temp_point, axis=1)\n\n else:\n uvh = torch.cat([uv, torch.ones(len(uv), 1).to(uv)], -1)\n temp_point = dot(torch.inverse(K), uvh)\n z = dist / torch.", "reference": "z=dist/torch.linalg.norm(temp_point,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "z=dist/torch.linalg.norm(temp_point,dim=1)", "y_neg": " z = dist / torch.norm(temp_point, dim=1)", "retain": "def distance_to_depth(K, dist, uv=None):\n if uv is None and len(dist.shape) >= 2:\n # create mesh grid according to d\n uv = np.stack(np.meshgrid(np.arange(dist.shape[1]), np.arange(dist.shape[0])), -1)\n uv = uv.reshape(-1, 2)\n dist = dist.reshape(-1)\n if not isinstance(dist, np.ndarray):\n uv = torch.from_numpy(uv).to(dist)\n if isinstance(dist, np.ndarray):\n # z * np.sqrt(x_temp**2+y_temp**2+z_temp**2) = dist\n uvh = np.concatenate([uv, np.ones((len(uv), 1))], -1)\n temp_point = dot(np.linalg.inv(K), uvh)\n z = dist / np.linalg.norm(temp_point, axis=1)\n\n else:\n uvh = torch.cat([uv, torch.ones(len(uv), 1).to(uv)], -1)\n temp_point = dot(torch.inverse(K), uvh)\n z = dist / torch.linalg.norm(temp_point, dim=1)\n return z" }, { "id": 7133, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def unit(v: Tensor, dim: int = -1) -> Tensor:\n '''\n Unit vectors\n '''\n return v / torch.linalg.norm(v, dim=dim, keepdims=True)", "probing input": "def unit(v: Tensor, dim: int = -1) -> Tensor:\n '''\n Unit vectors\n '''\n", "probing input new": "def unit(v: Tensor, dim: int = -1) -> Tensor:\n '''\n Unit vectors\n '''\n return v / torch.", "reference": "returnv/torch.linalg.norm(v,dim=dim,keepdims=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnv/torch.linalg.norm(v,dim=dim,keepdims=True)", "y_neg": " return v / torch.norm(v, dim=dim, keepdim=True)", "retain": "def unit(v: Tensor, dim: int = -1) -> Tensor:\n '''\n Unit vectors\n '''\n return v / torch.linalg.norm(v, dim=dim, keepdims=True)" }, { "id": 7134, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def check_structure_test(pretrain_file, args1, args2):\n \"\"\"\n Test that the \"copy\" method copies the parameters from one model to another\n\n Also check that the copied models produce the same results\n \"\"\"\n set_random_seed(1000)\n other = build_model(pretrain_file, *args1)\n other.eval()\n\n set_random_seed(1001)\n model = build_model(pretrain_file, *args2)\n model.eval()\n\n assert not torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert not torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n\n model.copy_with_new_structure(other)\n\n assert torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.linalg.norm(model.word_lstm.weight_ih_l0), torch.linalg.norm(other.word_lstm.weight_ih_l0))\n\n # now, check that applying one transition to an initial state\n # results in the same values in the output states for both models\n # as the pattn layer inputs are 0, the output values should be equal\n shift = [parse_transitions.Shift()]\n model_states = test_parse_transitions.build_initial_state(model, 1)\n model_states = model.bulk_apply(model_states, shift)\n\n other_states = test_parse_transitions.build_initial_state(other, 1)\n other_states = other.bulk_apply(other_states, shift)\n\n for i, j in zip(other_states[0].word_queue, model_states[0].word_queue):\n assert torch.allclose(i.hx, j.hx, atol=1e-07)\n for i, j in zip(other_states[0].transitions, model_states[0].transitions):\n assert torch.allclose(i.lstm_hx, j.lstm_hx)\n assert torch.allclose(i.lstm_cx, j.lstm_cx)\n for i, j in zip(other_states[0].constituents, model_states[0].constituents):\n assert (i.value is None) == (j.value is None)\n if i.value is not None:\n assert torch.allclose(i.value.tree_hx, j.value.tree_hx, atol=1e-07)\n assert torch.allclose(i.lstm_hx, j.lstm_hx)\n assert torch.allclose(i.lstm_cx, j.lstm_cx)", "probing input": "def check_structure_test(pretrain_file, args1, args2):\n \"\"\"\n Test that the \"copy\" method copies the parameters from one model to another\n\n Also check that the copied models produce the same results\n \"\"\"\n set_random_seed(1000)\n other = build_model(pretrain_file, *args1)\n other.eval()\n\n set_random_seed(1001)\n model = build_model(pretrain_file, *args2)\n model.eval()\n\n assert not torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert not torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n\n model.copy_with_new_structure(other)\n\n assert torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n", "probing input new": "def check_structure_test(pretrain_file, args1, args2):\n \"\"\"\n Test that the \"copy\" method copies the parameters from one model to another\n\n Also check that the copied models produce the same results\n \"\"\"\n set_random_seed(1000)\n other = build_model(pretrain_file, *args1)\n other.eval()\n\n set_random_seed(1001)\n model = build_model(pretrain_file, *args2)\n model.eval()\n\n assert not torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert not torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n\n model.copy_with_new_structure(other)\n\n assert torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.", "reference": "asserttorch.allclose(torch.linalg.norm(model.word_lstm.weight_ih_l0),torch.linalg.norm(other.word_lstm.weight_ih_l0))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "asserttorch.allclose(torch.linalg.norm(model.word_lstm.weight_ih_l0),torch.linalg.norm(other.word_lstm.weight_ih_l0))", "y_neg": " assert torch.allclose(torch.norm(model.delta_embedding.weight, p='fro'), torch.norm(other.delta_embedding.weight, p='fro'))", "retain": "def check_structure_test(pretrain_file, args1, args2):\n \"\"\"\n Test that the \"copy\" method copies the parameters from one model to another\n\n Also check that the copied models produce the same results\n \"\"\"\n set_random_seed(1000)\n other = build_model(pretrain_file, *args1)\n other.eval()\n\n set_random_seed(1001)\n model = build_model(pretrain_file, *args2)\n model.eval()\n\n assert not torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert not torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n\n model.copy_with_new_structure(other)\n\n assert torch.allclose(model.delta_embedding.weight, other.delta_embedding.weight)\n assert torch.allclose(model.output_layers[0].weight, other.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.linalg.norm(model.word_lstm.weight_ih_l0), torch.linalg.norm(other.word_lstm.weight_ih_l0))\n\n # now, check that applying one transition to an initial state\n # results in the same values in the output states for both models\n # as the pattn layer inputs are 0, the output values should be equal\n shift = [parse_transitions.Shift()]\n model_states = test_parse_transitions.build_initial_state(model, 1)\n model_states = model.bulk_apply(model_states, shift)\n\n other_states = test_parse_transitions.build_initial_state(other, 1)\n other_states = other.bulk_apply(other_states, shift)\n\n for i, j in zip(other_states[0].word_queue, model_states[0].word_queue):\n assert torch.allclose(i.hx, j.hx, atol=1e-07)\n for i, j in zip(other_states[0].transitions, model_states[0].transitions):\n assert torch.allclose(i.lstm_hx, j.lstm_hx)\n assert torch.allclose(i.lstm_cx, j.lstm_cx)\n for i, j in zip(other_states[0].constituents, model_states[0].constituents):\n assert (i.value is None) == (j.value is None)\n if i.value is not None:\n assert torch.allclose(i.value.tree_hx, j.value.tree_hx, atol=1e-07)\n assert torch.allclose(i.lstm_hx, j.lstm_hx)\n assert torch.allclose(i.lstm_cx, j.lstm_cx)" }, { "id": 7136, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ) -> None:\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats.\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats.\n If normalize_quats is not True, must be a unit quaternion.\n normalize_quats:\n If quats is specified, whether to normalize quats.\n \"\"\"\n if rot_mats is None and quats is None:\n raise ValueError(\"Exactly one input argument must be specified\")\n elif rot_mats is not None and quats is not None:\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if rot_mats is not None and rot_mats.shape[-2:] != (3, 3):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n elif quats is not None and quats.shape[-1] != 4:\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ) -> None:\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats.\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats.\n If normalize_quats is not True, must be a unit quaternion.\n normalize_quats:\n If quats is specified, whether to normalize quats.\n \"\"\"\n if rot_mats is None and quats is None:\n raise ValueError(\"Exactly one input argument must be specified\")\n elif rot_mats is not None and quats is not None:\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if rot_mats is not None and rot_mats.shape[-2:] != (3, 3):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n elif quats is not None and quats.shape[-1] != 4:\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ) -> None:\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats.\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats.\n If normalize_quats is not True, must be a unit quaternion.\n normalize_quats:\n If quats is specified, whether to normalize quats.\n \"\"\"\n if rot_mats is None and quats is None:\n raise ValueError(\"Exactly one input argument must be specified\")\n elif rot_mats is not None and quats is not None:\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if rot_mats is not None and rot_mats.shape[-2:] != (3, 3):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n elif quats is not None and quats.shape[-1] != 4:\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ) -> None:\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats.\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats.\n If normalize_quats is not True, must be a unit quaternion.\n normalize_quats:\n If quats is specified, whether to normalize quats.\n \"\"\"\n if rot_mats is None and quats is None:\n raise ValueError(\"Exactly one input argument must be specified\")\n elif rot_mats is not None and quats is not None:\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if rot_mats is not None and rot_mats.shape[-2:] != (3, 3):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n elif quats is not None and quats.shape[-1] != 4:\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7137, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(x: torch.Tensor) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)", "probing input": "def normalize(x: torch.Tensor) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n", "probing input new": "def normalize(x: torch.Tensor) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.", "reference": "returnx/torch.linalg.norm(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnx/torch.linalg.norm(x)", "y_neg": " return x / torch.norm(x)", "retain": "def normalize(x: torch.Tensor) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)" }, { "id": 7142, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x:torch.Tensor, y:torch.Tensor)-> torch.Tensor:\n norm = get_outnorm(x, self.out_norm)\n\n if self.kind == 'mat':\n loss = torch.linalg.matrix_norm(\n x - y, ord=self.order).mean()\n else:\n # norm = torch.norm(x - y, p=self.order)\n loss = torch.linalg.norm(\n x.view(-1, 1) - y.view(-1, 1), ord=self.order)\n\n return loss*norm", "probing input": " def forward(self, x:torch.Tensor, y:torch.Tensor)-> torch.Tensor:\n norm = get_outnorm(x, self.out_norm)\n\n if self.kind == 'mat':\n loss = torch.linalg.matrix_norm(\n x - y, ord=self.order).mean()\n else:\n # norm = torch.norm(x - y, p=self.order)\n", "probing input new": " def forward(self, x:torch.Tensor, y:torch.Tensor)-> torch.Tensor:\n norm = get_outnorm(x, self.out_norm)\n\n if self.kind == 'mat':\n loss = torch.linalg.matrix_norm(\n x - y, ord=self.order).mean()\n else:\n # norm = torch.norm(x - y, p=self.order)\n loss = torch.", "reference": "loss=torch.linalg.norm(x.view(-1,1)-y.view(-1,1),ord=self.order)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "loss=torch.linalg.norm(x.view(-1,1)-y.view(-1,1),ord=self.order)", "y_neg": " loss = torch.norm(x - y, p=self.order, dim=1).mean()", "retain": " def forward(self, x:torch.Tensor, y:torch.Tensor)-> torch.Tensor:\n norm = get_outnorm(x, self.out_norm)\n\n if self.kind == 'mat':\n loss = torch.linalg.matrix_norm(\n x - y, ord=self.order).mean()\n else:\n # norm = torch.norm(x - y, p=self.order)\n loss = torch.linalg.norm(\n x.view(-1, 1) - y.view(-1, 1), ord=self.order)\n\n return loss*norm" }, { "id": 7143, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def text_embeddings(self, prompts: List[str]) -> torch.Tensor:\n tokens, lens = self.encode_prompts(prompts)\n z_t = self.text_encoder(tokens, lens)\n return z_t / (torch.linalg.norm(z_t, dim=-1, keepdim=True) + 1e-12)", "probing input": " def text_embeddings(self, prompts: List[str]) -> torch.Tensor:\n tokens, lens = self.encode_prompts(prompts)\n z_t = self.text_encoder(tokens, lens)\n", "probing input new": " def text_embeddings(self, prompts: List[str]) -> torch.Tensor:\n tokens, lens = self.encode_prompts(prompts)\n z_t = self.text_encoder(tokens, lens)\n return z_t / (torch.", "reference": "returnz_t/(torch.linalg.norm(z_t,dim=-1,keepdim=True)+1e-12)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnz_t/(torch.linalg.norm(z_t,dim=-1,keepdim=True)+1e-12)", "y_neg": " return z_t / (torch.norm(z_t, dim=-1, keepdim=True) + 1e-10)", "retain": " def text_embeddings(self, prompts: List[str]) -> torch.Tensor:\n tokens, lens = self.encode_prompts(prompts)\n z_t = self.text_encoder(tokens, lens)\n return z_t / (torch.linalg.norm(z_t, dim=-1, keepdim=True) + 1e-12)" }, { "id": 7144, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def image_embeddings(self, images: torch.Tensor, t: torch.Tensor) -> torch.Tensor:\n z_i = self.image_encoder((images + 1) * 127.5, t)\n return z_i / (torch.linalg.norm(z_i, dim=-1, keepdim=True) + 1e-12)", "probing input": " def image_embeddings(self, images: torch.Tensor, t: torch.Tensor) -> torch.Tensor:\n z_i = self.image_encoder((images + 1) * 127.5, t)\n", "probing input new": " def image_embeddings(self, images: torch.Tensor, t: torch.Tensor) -> torch.Tensor:\n z_i = self.image_encoder((images + 1) * 127.5, t)\n return z_i / (torch.", "reference": "returnz_i/(torch.linalg.norm(z_i,dim=-1,keepdim=True)+1e-12)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnz_i/(torch.linalg.norm(z_i,dim=-1,keepdim=True)+1e-12)", "y_neg": " return z_i / (torch.norm(z_i, dim=1, keepdim=True) + 1e-10)", "retain": " def image_embeddings(self, images: torch.Tensor, t: torch.Tensor) -> torch.Tensor:\n z_i = self.image_encoder((images + 1) * 127.5, t)\n return z_i / (torch.linalg.norm(z_i, dim=-1, keepdim=True) + 1e-12)" }, { "id": 7145, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def pt_render_poses(datadir: str, n_frames: int, frame_h: int = 800, frame_w: int = 800):\n scene = PhototourismScenes.get_scene_from_datadir(datadir)\n idx, _ = get_ids_for_split(datadir, split='train')\n train_poses, kinvs, bounds, res = load_camera_metadata(datadir, idx)\n train_poses, kinvs, bounds = scale_cam_metadata(train_poses, kinvs, bounds, scale=0.05)\n\n # build camera intrinsic from appropriate focal distance and cx, cy. Good for trevi\n k = np.array([[780.0, 0, -frame_w / 2], [0, -780, -frame_h / 2], [0, 0, -1]])\n kinv = torch.from_numpy(np.linalg.inv(k)).to(torch.float32)\n\n bounds = torch.from_numpy(bounds).float()\n train_poses = torch.from_numpy(train_poses).float()\n\n r_poses = pt_spiral_path(scene, train_poses, n_frames=n_frames, zrate=1, n_rots=1)\n\n all_rays_o, all_rays_d, camera_ids, near_fars = [], [], [], []\n for pose_id, pose in enumerate(r_poses):\n pose = pose.float()\n rays_o, rays_d = get_rays_tourism(frame_h, frame_w, kinv, pose)\n rays_o = rays_o.view(-1, 3)\n rays_d = rays_d.view(-1, 3)\n all_rays_o.append(rays_o)\n all_rays_d.append(rays_d)\n\n # Find the closest cam\n closest_cam_idx = torch.linalg.norm(\n train_poses[:, :3, :].view(train_poses.shape[0], -1) - pose.view(-1), dim=1\n ).argmin()\n\n # For brandenburg and trevi\n if scene == PhototourismScenes.BRANDENBURG or scene == PhototourismScenes.TREVI:\n near_fars.append((\n bounds[closest_cam_idx] + torch.tensor([0.01, 0.0])\n ))\n elif scene == PhototourismScenes.SACRE:\n near_fars.append((\n bounds[closest_cam_idx] + torch.tensor([0.05, 0.0])\n ))\n # camera-IDs. They are floats interpolating between 2 appearance embeddings.\n x = torch.linspace(-1, 1, len(r_poses))\n s = 0.3\n camera_ids = 1/(s * math.sqrt(2 * torch.pi)) * torch.exp(- (x)**2 / (2 * s**2))\n camera_ids = (camera_ids - camera_ids.min()) / camera_ids.max()\n all_rays_o = torch.stack(all_rays_o, dim=0)\n all_rays_d = torch.stack(all_rays_d, dim=0)\n near_fars = torch.stack(near_fars, dim=0)\n return all_rays_o, all_rays_d, camera_ids, near_fars", "probing input": "def pt_render_poses(datadir: str, n_frames: int, frame_h: int = 800, frame_w: int = 800):\n scene = PhototourismScenes.get_scene_from_datadir(datadir)\n idx, _ = get_ids_for_split(datadir, split='train')\n train_poses, kinvs, bounds, res = load_camera_metadata(datadir, idx)\n train_poses, kinvs, bounds = scale_cam_metadata(train_poses, kinvs, bounds, scale=0.05)\n\n # build camera intrinsic from appropriate focal distance and cx, cy. Good for trevi\n k = np.array([[780.0, 0, -frame_w / 2], [0, -780, -frame_h / 2], [0, 0, -1]])\n kinv = torch.from_numpy(np.linalg.inv(k)).to(torch.float32)\n\n bounds = torch.from_numpy(bounds).float()\n train_poses = torch.from_numpy(train_poses).float()\n\n r_poses = pt_spiral_path(scene, train_poses, n_frames=n_frames, zrate=1, n_rots=1)\n\n all_rays_o, all_rays_d, camera_ids, near_fars = [], [], [], []\n for pose_id, pose in enumerate(r_poses):\n pose = pose.float()\n rays_o, rays_d = get_rays_tourism(frame_h, frame_w, kinv, pose)\n rays_o = rays_o.view(-1, 3)\n rays_d = rays_d.view(-1, 3)\n all_rays_o.append(rays_o)\n all_rays_d.append(rays_d)\n\n # Find the closest cam\n", "probing input new": "def pt_render_poses(datadir: str, n_frames: int, frame_h: int = 800, frame_w: int = 800):\n scene = PhototourismScenes.get_scene_from_datadir(datadir)\n idx, _ = get_ids_for_split(datadir, split='train')\n train_poses, kinvs, bounds, res = load_camera_metadata(datadir, idx)\n train_poses, kinvs, bounds = scale_cam_metadata(train_poses, kinvs, bounds, scale=0.05)\n\n # build camera intrinsic from appropriate focal distance and cx, cy. Good for trevi\n k = np.array([[780.0, 0, -frame_w / 2], [0, -780, -frame_h / 2], [0, 0, -1]])\n kinv = torch.from_numpy(np.linalg.inv(k)).to(torch.float32)\n\n bounds = torch.from_numpy(bounds).float()\n train_poses = torch.from_numpy(train_poses).float()\n\n r_poses = pt_spiral_path(scene, train_poses, n_frames=n_frames, zrate=1, n_rots=1)\n\n all_rays_o, all_rays_d, camera_ids, near_fars = [], [], [], []\n for pose_id, pose in enumerate(r_poses):\n pose = pose.float()\n rays_o, rays_d = get_rays_tourism(frame_h, frame_w, kinv, pose)\n rays_o = rays_o.view(-1, 3)\n rays_d = rays_d.view(-1, 3)\n all_rays_o.append(rays_o)\n all_rays_d.append(rays_d)\n\n # Find the closest cam\n closest_cam_idx = torch.", "reference": "closest_cam_idx=torch.linalg.norm(train_poses[:,:3,:].view(train_poses.shape[0],-1)-pose.view(-1),dim=1).argmin()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "closest_cam_idx=torch.linalg.norm(train_poses[:,:3,:].view(train_poses.shape[0],-1)-pose.view(-1),dim=1).argmin()", "y_neg": " closest_cam_idx = torch.argmin(torch.norm(rays_o[:, :3] - rays_d[:, :3], dim=-1))", "retain": "def pt_render_poses(datadir: str, n_frames: int, frame_h: int = 800, frame_w: int = 800):\n scene = PhototourismScenes.get_scene_from_datadir(datadir)\n idx, _ = get_ids_for_split(datadir, split='train')\n train_poses, kinvs, bounds, res = load_camera_metadata(datadir, idx)\n train_poses, kinvs, bounds = scale_cam_metadata(train_poses, kinvs, bounds, scale=0.05)\n\n # build camera intrinsic from appropriate focal distance and cx, cy. Good for trevi\n k = np.array([[780.0, 0, -frame_w / 2], [0, -780, -frame_h / 2], [0, 0, -1]])\n kinv = torch.from_numpy(np.linalg.inv(k)).to(torch.float32)\n\n bounds = torch.from_numpy(bounds).float()\n train_poses = torch.from_numpy(train_poses).float()\n\n r_poses = pt_spiral_path(scene, train_poses, n_frames=n_frames, zrate=1, n_rots=1)\n\n all_rays_o, all_rays_d, camera_ids, near_fars = [], [], [], []\n for pose_id, pose in enumerate(r_poses):\n pose = pose.float()\n rays_o, rays_d = get_rays_tourism(frame_h, frame_w, kinv, pose)\n rays_o = rays_o.view(-1, 3)\n rays_d = rays_d.view(-1, 3)\n all_rays_o.append(rays_o)\n all_rays_d.append(rays_d)\n\n # Find the closest cam\n closest_cam_idx = torch.linalg.norm(\n train_poses[:, :3, :].view(train_poses.shape[0], -1) - pose.view(-1), dim=1\n ).argmin()\n\n # For brandenburg and trevi\n if scene == PhototourismScenes.BRANDENBURG or scene == PhototourismScenes.TREVI:\n near_fars.append((\n bounds[closest_cam_idx] + torch.tensor([0.01, 0.0])\n ))\n elif scene == PhototourismScenes.SACRE:\n near_fars.append((\n bounds[closest_cam_idx] + torch.tensor([0.05, 0.0])\n ))\n # camera-IDs. They are floats interpolating between 2 appearance embeddings.\n x = torch.linspace(-1, 1, len(r_poses))\n s = 0.3\n camera_ids = 1/(s * math.sqrt(2 * torch.pi)) * torch.exp(- (x)**2 / (2 * s**2))\n camera_ids = (camera_ids - camera_ids.min()) / camera_ids.max()\n all_rays_o = torch.stack(all_rays_o, dim=0)\n all_rays_d = torch.stack(all_rays_d, dim=0)\n near_fars = torch.stack(near_fars, dim=0)\n return all_rays_o, all_rays_d, camera_ids, near_fars" }, { "id": 7146, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6\n query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)", "probing input": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n", "probing input new": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.", "reference": "image_class_embeds/=torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "image_class_embeds/=torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6", "y_neg": " image_class_embeds /= torch.norm(image_class_embeds, dim=1, keepdim=True)", "retain": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6\n query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)" }, { "id": 7147, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n", "probing input new": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7149, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n x,\n global_pe: Optional[torch.Tensor] = None,\n ):\n B, Din, H, W = x.shape\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n q = q / (np.sqrt(q.shape[-1]) + 1e-6)\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n\n qk_score = self._compute_QK_scores(q, x)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out", "probing input": " def forward(\n self,\n x,\n global_pe: Optional[torch.Tensor] = None,\n ):\n B, Din, H, W = x.shape\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n q = q / (np.sqrt(q.shape[-1]) + 1e-6)\n if self.normalize_q:\n", "probing input new": " def forward(\n self,\n x,\n global_pe: Optional[torch.Tensor] = None,\n ):\n B, Din, H, W = x.shape\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n q = q / (np.sqrt(q.shape[-1]) + 1e-6)\n if self.normalize_q:\n q = q / (torch.", "reference": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "y_neg": " q = q / (torch.norm(q, 2, 1, keepdim=True) + 1e-6)", "retain": " def forward(\n self,\n x,\n global_pe: Optional[torch.Tensor] = None,\n ):\n B, Din, H, W = x.shape\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n q = q / (np.sqrt(q.shape[-1]) + 1e-6)\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n\n qk_score = self._compute_QK_scores(q, x)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out" }, { "id": 7150, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(B, self.heads, self.hidden_features // self.heads)\n else:\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n\n q = q / np.sqrt(q.shape[-1])\n\n x_with_pos = x if global_pe is None else x + global_pe\n qk_score = self._compute_QK_scores(q, x_with_pos)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out", "probing input": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(B, self.heads, self.hidden_features // self.heads)\n else:\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n if self.normalize_q:\n", "probing input new": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(B, self.heads, self.hidden_features // self.heads)\n else:\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n if self.normalize_q:\n q = q / (torch.", "reference": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "y_neg": " q = q / (torch.norm(q, dim=-1, keepdim=True) + 1e-9)", "retain": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(B, self.heads, self.hidden_features // self.heads)\n else:\n # Prepare query\n q = torch.broadcast_to(self.query, [x.shape[0], self.hidden_features]).view(B, self.heads,\n self.hidden_features // self.heads)\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n\n q = q / np.sqrt(q.shape[-1])\n\n x_with_pos = x if global_pe is None else x + global_pe\n qk_score = self._compute_QK_scores(q, x_with_pos)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out" }, { "id": 7151, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n else:\n # Prepare query\n # assert False, \"Don't unset timesteps unless explicitly done for testing\"\n q = torch.broadcast_to(\n self.query, [x.shape[0], self.scale_factor * self.hidden_features]\n ).view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n q = q / np.sqrt(q.shape[-1])\n\n qk_score = self._compute_QK_scores(q, x)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out", "probing input": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n else:\n # Prepare query\n # assert False, \"Don't unset timesteps unless explicitly done for testing\"\n q = torch.broadcast_to(\n self.query, [x.shape[0], self.scale_factor * self.hidden_features]\n ).view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n if self.normalize_q:\n", "probing input new": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n else:\n # Prepare query\n # assert False, \"Don't unset timesteps unless explicitly done for testing\"\n q = torch.broadcast_to(\n self.query, [x.shape[0], self.scale_factor * self.hidden_features]\n ).view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n if self.normalize_q:\n q = q / (torch.", "reference": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "q=q/(torch.linalg.norm(q,dim=-1,keepdim=True)+1e-6)", "y_neg": " q = q / (torch.norm(q, dim=-1, keepdim=True) + 1e-9)", "retain": " def forward(\n self,\n x,\n timesteps: Optional[torch.Tensor] = None,\n global_pe: Optional[torch.Tensor] = None,\n ):\n assert x.shape[2] == self.axial_dim\n B, Din, H, W = x.shape\n if self.timesteps_embed is not None and timesteps is not None:\n q = self.timesteps_embed(timesteps)\n q = q.view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n else:\n # Prepare query\n # assert False, \"Don't unset timesteps unless explicitly done for testing\"\n q = torch.broadcast_to(\n self.query, [x.shape[0], self.scale_factor * self.hidden_features]\n ).view(\n B, self.scale_factor, self.heads, self.hidden_features // self.heads\n )\n if self.normalize_q:\n q = q / (torch.linalg.norm(q, dim=-1, keepdim=True) + 1e-6)\n q = q / np.sqrt(q.shape[-1])\n\n qk_score = self._compute_QK_scores(q, x)\n\n v = self.to_v(x)\n\n out_per_head_concat = self._compute_attention(qk_score, v, self.rpe)\n out = self.to_out(out_per_head_concat)\n return out" }, { "id": 7153, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7158, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, :1] *= -1\n return torch.divide(normal, torch.linalg.norm(normal, dim=1).reshape(-1, 1))", "probing input": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, :1] *= -1\n", "probing input new": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, :1] *= -1\n return torch.divide(", "reference": "returntorch.divide(normal,torch.linalg.norm(normal,dim=1).reshape(-1,1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.divide(normal,torch.linalg.norm(normal,dim=1).reshape(-1,1))", "y_neg": " return torch.divide(normal, torch.norm(normal, p=2, dim=1, keepdim=True),", "retain": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, :1] *= -1\n return torch.divide(normal, torch.linalg.norm(normal, dim=1).reshape(-1, 1))" }, { "id": 7160, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def render_lidar_eval(model, lidar_depends,testsavedir, ndc, render_kwargs):\n lidar_dists, lidar_origins,lidar_rays_directions,lidar_labels = lidar_depends\n segs = []\n depths = []\n import os\n for i in tqdm(range(len(lidar_origins))):\n rays_d= torch.tensor(lidar_rays_directions[i]).float()\n rays_o = torch.broadcast_to(torch.tensor(lidar_origins[i]).reshape(1,3),\n rays_d.shape).float() \n viewdirs = rays_d/torch.linalg.norm(rays_d,dim=-1,keepdim=True)\n # directions= lidar_rays_directions[i]\n # origin,directions = lidar2globals[i]\n keys = ['rgb_marched', 'depth', 'alphainv_last', 'segmentation']\n \n render_result_chunks = [\n {k: v for k, v in model(ro, rd, vd, **render_kwargs).items() if k in keys}\n for ro, rd, vd in zip(rays_o.split(1024, 0), rays_d.split(1024, 0), viewdirs.split(1024, 0))\n ]\n render_result = {\n k: torch.cat([ret[k] for ret in render_result_chunks]).reshape(rays_d.shape[0],-1)\n for k in render_result_chunks[0].keys()\n }\n depth = render_result['depth'].cpu().numpy()\n # if 'segmentation' in render_result.keys():\n seg = render_result['segmentation']\n logits_2_label = lambda x: torch.argmax(x, dim=-1)\n seg_ = logits_2_label(seg).cpu().numpy()\n segs.append(seg_)\n\n depths.append(depth)\n def get_points_corrds(rays,depth):\n origins =rays[0]\n directions =rays[1]\n points = origins + torch.tensor(depth)*directions#/directions[:,-2:-1]\n return points\n\n points = get_points_corrds((rays_o,rays_d),depth)\n\n # np.save(os.path.join(testsavedir, 'points_{:03d}.npy'.format(i)),points.detach().cpu().numpy())\n if i = len(lidar_origins) - len(lidar_labels):\n np.save(os.path.join(testsavedir, 'points_semantic_{:03d}.npy'.format(i)),seg_)\n np.save(os.path.join(testsavedir, 'gt_points_semantic_{:03d}.npy'.format(i)),lidar_labels[i-len(lidar_origins) + len(lidar_labels)])\n\n \n import os\n import yaml\n with open('/SSD_DISK/users/zhangjunge/Scenes/6cam_scene1_revision/NeRFlidar_label_v7.yaml', 'r') as stream:\n # to 8 classes \n semkittiyaml = yaml.safe_load(stream)\n learning_map = semkittiyaml['learning_map']\n points_labels = []\n for idx, label in enumerate(lidar_labels):\n points_label = np.vectorize(learning_map.__getitem__)(segs[idx+len(lidar_origins) - len(lidar_labels)])\n points_labels.append(points_label)\n\n # points_labels = np.concatenate(points_labels)\n # lidar_labels = np.concatenate(lidar_labels)\n from miou_cal import eval_miou\n per_class_iou = eval_miou(points_labels,lidar_labels)\n with open(os.path.join(testsavedir,'iou.txt'),'w') as f:\n for idx in range(len(per_class_iou)):\n f.write(f'{per_class_iou[idx]}\\n')\n f.write(f'miou is {per_class_iou.mean()}')\n\n return None", "probing input": "def render_lidar_eval(model, lidar_depends,testsavedir, ndc, render_kwargs):\n lidar_dists, lidar_origins,lidar_rays_directions,lidar_labels = lidar_depends\n segs = []\n depths = []\n import os\n for i in tqdm(range(len(lidar_origins))):\n rays_d= torch.tensor(lidar_rays_directions[i]).float()\n rays_o = torch.broadcast_to(torch.tensor(lidar_origins[i]).reshape(1,3),\n rays_d.shape).float() \n", "probing input new": "def render_lidar_eval(model, lidar_depends,testsavedir, ndc, render_kwargs):\n lidar_dists, lidar_origins,lidar_rays_directions,lidar_labels = lidar_depends\n segs = []\n depths = []\n import os\n for i in tqdm(range(len(lidar_origins))):\n rays_d= torch.tensor(lidar_rays_directions[i]).float()\n rays_o = torch.broadcast_to(torch.tensor(lidar_origins[i]).reshape(1,3),\n rays_d.shape).float() \n viewdirs = rays_d/torch.", "reference": "viewdirs=rays_d/torch.linalg.norm(rays_d,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "viewdirs=rays_d/torch.linalg.norm(rays_d,dim=-1,keepdim=True)", "y_neg": " viewdirs = rays_d/torch.norm(rays_d, dim=-1, keepdim=True)", "retain": "def render_lidar_eval(model, lidar_depends,testsavedir, ndc, render_kwargs):\n lidar_dists, lidar_origins,lidar_rays_directions,lidar_labels = lidar_depends\n segs = []\n depths = []\n import os\n for i in tqdm(range(len(lidar_origins))):\n rays_d= torch.tensor(lidar_rays_directions[i]).float()\n rays_o = torch.broadcast_to(torch.tensor(lidar_origins[i]).reshape(1,3),\n rays_d.shape).float() \n viewdirs = rays_d/torch.linalg.norm(rays_d,dim=-1,keepdim=True)\n # directions= lidar_rays_directions[i]\n # origin,directions = lidar2globals[i]\n keys = ['rgb_marched', 'depth', 'alphainv_last', 'segmentation']\n \n render_result_chunks = [\n {k: v for k, v in model(ro, rd, vd, **render_kwargs).items() if k in keys}\n for ro, rd, vd in zip(rays_o.split(1024, 0), rays_d.split(1024, 0), viewdirs.split(1024, 0))\n ]\n render_result = {\n k: torch.cat([ret[k] for ret in render_result_chunks]).reshape(rays_d.shape[0],-1)\n for k in render_result_chunks[0].keys()\n }\n depth = render_result['depth'].cpu().numpy()\n # if 'segmentation' in render_result.keys():\n seg = render_result['segmentation']\n logits_2_label = lambda x: torch.argmax(x, dim=-1)\n seg_ = logits_2_label(seg).cpu().numpy()\n segs.append(seg_)\n\n depths.append(depth)\n def get_points_corrds(rays,depth):\n origins =rays[0]\n directions =rays[1]\n points = origins + torch.tensor(depth)*directions#/directions[:,-2:-1]\n return points\n\n points = get_points_corrds((rays_o,rays_d),depth)\n\n # np.save(os.path.join(testsavedir, 'points_{:03d}.npy'.format(i)),points.detach().cpu().numpy())\n if i = len(lidar_origins) - len(lidar_labels):\n np.save(os.path.join(testsavedir, 'points_semantic_{:03d}.npy'.format(i)),seg_)\n np.save(os.path.join(testsavedir, 'gt_points_semantic_{:03d}.npy'.format(i)),lidar_labels[i-len(lidar_origins) + len(lidar_labels)])\n\n \n import os\n import yaml\n with open('/SSD_DISK/users/zhangjunge/Scenes/6cam_scene1_revision/NeRFlidar_label_v7.yaml', 'r') as stream:\n # to 8 classes \n semkittiyaml = yaml.safe_load(stream)\n learning_map = semkittiyaml['learning_map']\n points_labels = []\n for idx, label in enumerate(lidar_labels):\n points_label = np.vectorize(learning_map.__getitem__)(segs[idx+len(lidar_origins) - len(lidar_labels)])\n points_labels.append(points_label)\n\n # points_labels = np.concatenate(points_labels)\n # lidar_labels = np.concatenate(lidar_labels)\n from miou_cal import eval_miou\n per_class_iou = eval_miou(points_labels,lidar_labels)\n with open(os.path.join(testsavedir,'iou.txt'),'w') as f:\n for idx in range(len(per_class_iou)):\n f.write(f'{per_class_iou[idx]}\\n')\n f.write(f'miou is {per_class_iou.mean()}')\n\n return None" }, { "id": 7161, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exp_map_SE3(tangent_vector: Float[Tensor, \"b 6\"]) -> Float[Tensor, \"b 3 4\"]:\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret", "probing input": "def exp_map_SE3(tangent_vector: Float[Tensor, \"b 6\"]) -> Float[Tensor, \"b 3 4\"]:\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n", "probing input new": "def exp_map_SE3(tangent_vector: Float[Tensor, \"b 6\"]) -> Float[Tensor, \"b 3 4\"]:\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.", "reference": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "y_neg": " theta = torch.norm(tangent_vector_ang, p=2, dim=1, keepdim=True)", "retain": "def exp_map_SE3(tangent_vector: Float[Tensor, \"b 6\"]) -> Float[Tensor, \"b 3 4\"]:\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret" }, { "id": 7162, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def pre_compute(self):\n # This method is auxiliary of the `get_solution` method (below)\n # It extracts some computation irrelevant to `area` to reduce computational time\n # You'll need to first understand the theories to solve truss problems and read this method together with the `get_solution` method to understand\n dis_vec = self.coords[self.con[:, 1], :] - self.coords[self.con[:, 0], :]\n self.length = torch.linalg.norm(dis_vec, dim=-1) # length of bars\n self.T = dis_vec / self.length.view(-1, 1) # distance unit vector or transformation vector\n self.matrix = torch.kron(torch.tensor([[1, -1], [-1, 1]], device=self.device), torch.einsum('ij,ik->ijk', self.T, self.T))\n self.idx = torch.cat((torch.arange(0, self.n_dim, device=self.device) + (self.con[:, 0] * self.n_dim).view(-1, 1),\n torch.arange(0, self.n_dim, device=self.device) + (self.con[:, 1] * self.n_dim).view(-1, 1)), dim=1)\n self.free_list = self.free_mask.flatten()", "probing input": " def pre_compute(self):\n # This method is auxiliary of the `get_solution` method (below)\n # It extracts some computation irrelevant to `area` to reduce computational time\n # You'll need to first understand the theories to solve truss problems and read this method together with the `get_solution` method to understand\n dis_vec = self.coords[self.con[:, 1], :] - self.coords[self.con[:, 0], :]\n", "probing input new": " def pre_compute(self):\n # This method is auxiliary of the `get_solution` method (below)\n # It extracts some computation irrelevant to `area` to reduce computational time\n # You'll need to first understand the theories to solve truss problems and read this method together with the `get_solution` method to understand\n dis_vec = self.coords[self.con[:, 1], :] - self.coords[self.con[:, 0], :]\n self.length = torch.", "reference": "self.length=torch.linalg.norm(dis_vec,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.length=torch.linalg.norm(dis_vec,dim=-1)", "y_neg": " self.length = torch.norm(dis_vec, p=2, dim=1)", "retain": " def pre_compute(self):\n # This method is auxiliary of the `get_solution` method (below)\n # It extracts some computation irrelevant to `area` to reduce computational time\n # You'll need to first understand the theories to solve truss problems and read this method together with the `get_solution` method to understand\n dis_vec = self.coords[self.con[:, 1], :] - self.coords[self.con[:, 0], :]\n self.length = torch.linalg.norm(dis_vec, dim=-1) # length of bars\n self.T = dis_vec / self.length.view(-1, 1) # distance unit vector or transformation vector\n self.matrix = torch.kron(torch.tensor([[1, -1], [-1, 1]], device=self.device), torch.einsum('ij,ik->ijk', self.T, self.T))\n self.idx = torch.cat((torch.arange(0, self.n_dim, device=self.device) + (self.con[:, 0] * self.n_dim).view(-1, 1),\n torch.arange(0, self.n_dim, device=self.device) + (self.con[:, 1] * self.n_dim).view(-1, 1)), dim=1)\n self.free_list = self.free_mask.flatten()" }, { "id": 7168, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_l1_penalty(self):\n for dtype in (torch.float, torch.double):\n init_point = torch.tensor([1.0, 1.0, 1.0], device=self.device, dtype=dtype)\n l1_module = L1Penalty(init_point=init_point)\n\n # testing a batch of two points\n sample_point = torch.tensor(\n [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], device=self.device, dtype=dtype\n )\n\n diff_l1_norm = torch.linalg.norm((sample_point - init_point), ord=1, dim=-1)\n real_value = diff_l1_norm.max(dim=-1).values\n computed_value = l1_module(sample_point)\n self.assertEqual(computed_value.item(), real_value.item())", "probing input": " def test_l1_penalty(self):\n for dtype in (torch.float, torch.double):\n init_point = torch.tensor([1.0, 1.0, 1.0], device=self.device, dtype=dtype)\n l1_module = L1Penalty(init_point=init_point)\n\n # testing a batch of two points\n sample_point = torch.tensor(\n [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], device=self.device, dtype=dtype\n )\n\n", "probing input new": " def test_l1_penalty(self):\n for dtype in (torch.float, torch.double):\n init_point = torch.tensor([1.0, 1.0, 1.0], device=self.device, dtype=dtype)\n l1_module = L1Penalty(init_point=init_point)\n\n # testing a batch of two points\n sample_point = torch.tensor(\n [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], device=self.device, dtype=dtype\n )\n\n diff_l1_", "reference": "diff_l1_norm=torch.linalg.norm((sample_point-init_point),ord=1,dim=-1)", "reference dict": { "l1_module": "L1Penalty" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "diff_l1_norm=torch.linalg.norm((sample_point-init_point),ord=1,dim=-1)", "y_neg": " diff_l1_norm = torch.norm(sample_point - init_point, p=1, dim=1)", "retain": " def test_l1_penalty(self):\n for dtype in (torch.float, torch.double):\n init_point = torch.tensor([1.0, 1.0, 1.0], device=self.device, dtype=dtype)\n l1_module = L1Penalty(init_point=init_point)\n\n # testing a batch of two points\n sample_point = torch.tensor(\n [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]], device=self.device, dtype=dtype\n )\n\n diff_l1_norm = torch.linalg.norm((sample_point - init_point), ord=1, dim=-1)\n real_value = diff_l1_norm.max(dim=-1).values\n computed_value = l1_module(sample_point)\n self.assertEqual(computed_value.item(), real_value.item())" }, { "id": 7172, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample_unbias(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, debug=False):\n \"\"\"\n up sampling strategy similar with NeuS;\n only sample more points at the first possible surface intersection\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n\n udf = udf.reshape(batch_size, n_samples)\n\n dists_raw = z_vals[..., 1:] - z_vals[..., :-1]\n dists_raw = torch.cat([dists_raw, torch.Tensor([sample_dist]).to(device).expand(dists_raw[..., :1].shape)], -1)\n\n dirs = rays_d[:, None, :].expand(pts.shape)\n\n prev_udf, next_udf = udf[:, :-1], udf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_udf = (prev_udf + next_udf) * 0.5\n mid_z_vals = (prev_z_vals + next_z_vals) * 0.5\n\n dists = (next_z_vals - prev_z_vals)\n\n # ! directly use udf to approximate cos_val, otherwise, sampling will be biased\n fake_sdf = udf\n ## near the 0levelset, the cos_val approximation should be inaccurate\n prev_sdf, next_sdf = fake_sdf[:, :-1], fake_sdf[:, 1:]\n\n true_cos = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5) # ! the cos_val will be larger than 1\n cos_val = -1 * torch.abs(true_cos)\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]).to(device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n # ! leverage the direction of gradients to alleviate the early zero of vis_prob\n vis_mask = torch.ones_like(true_cos).to(true_cos.device).to(true_cos.dtype) * (\n true_cos < 0.05).float()\n vis_mask = vis_mask.reshape(batch_size, n_samples - 1)\n vis_mask = torch.cat([torch.ones([batch_size, 1]).to(device), vis_mask], dim=-1)\n\n # * the probability of occlusion\n raw_occ = self.udf2logistic(udf, beta, 1.0, 1.0).reshape(batch_size, n_samples)\n # near 0levelset alpha_acc -> 1 others -> 0\n alpha_occ = 1.0 - torch.exp(-F.relu(raw_occ) * gamma * dists_raw)\n\n # - use the vis_mask, make upsampling more uniform and centered\n vis_prob = torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), (1. - alpha_occ + vis_mask).clip(0, 1) + 1e-7], -1), -1)[\n :, :-1] # before udf=0 -> 1; after udf=0 -> 0\n\n signs_prob = vis_prob[:, :-1]\n sdf_plus = mid_udf\n sdf_minus = mid_udf * -1\n alpha_plus = self.sdf2alpha(sdf_plus, cos_val, dists, inv_s) # batch_size, n_samples\n alpha_minus = self.sdf2alpha(sdf_minus, cos_val, dists, inv_s)\n alpha = alpha_plus * signs_prob + alpha_minus * (1 - signs_prob)\n alpha = alpha.reshape(batch_size, n_samples - 1)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n flag = torch.any(torch.isnan(z_samples)).cpu().numpy().item()\n if flag:\n print(\"z_vals\", z_samples[torch.isnan(z_samples)])\n print('z_vals have nan values')\n pdb.set_trace()\n # raise Exception(\"gradients have nan values\")\n\n return z_samples", "probing input": " def up_sample_unbias(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, debug=False):\n \"\"\"\n up sampling strategy similar with NeuS;\n only sample more points at the first possible surface intersection\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample_unbias(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, debug=False):\n \"\"\"\n up sampling strategy similar with NeuS;\n only sample more points at the first possible surface intersection\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts - rays_o[:, None, :], dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample_unbias(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, debug=False):\n \"\"\"\n up sampling strategy similar with NeuS;\n only sample more points at the first possible surface intersection\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n\n udf = udf.reshape(batch_size, n_samples)\n\n dists_raw = z_vals[..., 1:] - z_vals[..., :-1]\n dists_raw = torch.cat([dists_raw, torch.Tensor([sample_dist]).to(device).expand(dists_raw[..., :1].shape)], -1)\n\n dirs = rays_d[:, None, :].expand(pts.shape)\n\n prev_udf, next_udf = udf[:, :-1], udf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_udf = (prev_udf + next_udf) * 0.5\n mid_z_vals = (prev_z_vals + next_z_vals) * 0.5\n\n dists = (next_z_vals - prev_z_vals)\n\n # ! directly use udf to approximate cos_val, otherwise, sampling will be biased\n fake_sdf = udf\n ## near the 0levelset, the cos_val approximation should be inaccurate\n prev_sdf, next_sdf = fake_sdf[:, :-1], fake_sdf[:, 1:]\n\n true_cos = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5) # ! the cos_val will be larger than 1\n cos_val = -1 * torch.abs(true_cos)\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]).to(device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n # ! leverage the direction of gradients to alleviate the early zero of vis_prob\n vis_mask = torch.ones_like(true_cos).to(true_cos.device).to(true_cos.dtype) * (\n true_cos < 0.05).float()\n vis_mask = vis_mask.reshape(batch_size, n_samples - 1)\n vis_mask = torch.cat([torch.ones([batch_size, 1]).to(device), vis_mask], dim=-1)\n\n # * the probability of occlusion\n raw_occ = self.udf2logistic(udf, beta, 1.0, 1.0).reshape(batch_size, n_samples)\n # near 0levelset alpha_acc -> 1 others -> 0\n alpha_occ = 1.0 - torch.exp(-F.relu(raw_occ) * gamma * dists_raw)\n\n # - use the vis_mask, make upsampling more uniform and centered\n vis_prob = torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), (1. - alpha_occ + vis_mask).clip(0, 1) + 1e-7], -1), -1)[\n :, :-1] # before udf=0 -> 1; after udf=0 -> 0\n\n signs_prob = vis_prob[:, :-1]\n sdf_plus = mid_udf\n sdf_minus = mid_udf * -1\n alpha_plus = self.sdf2alpha(sdf_plus, cos_val, dists, inv_s) # batch_size, n_samples\n alpha_minus = self.sdf2alpha(sdf_minus, cos_val, dists, inv_s)\n alpha = alpha_plus * signs_prob + alpha_minus * (1 - signs_prob)\n alpha = alpha.reshape(batch_size, n_samples - 1)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n flag = torch.any(torch.isnan(z_samples)).cpu().numpy().item()\n if flag:\n print(\"z_vals\", z_samples[torch.isnan(z_samples)])\n print('z_vals have nan values')\n pdb.set_trace()\n # raise Exception(\"gradients have nan values\")\n\n return z_samples" }, { "id": 7173, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample_no_occ_aware(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, ):\n \"\"\"\n Different with NeuS, here we sample more points at all possible surfaces where udf is close to 0;\n Since unlike that SDF has clear sign changes, UDF sampling may miss the true surfaces\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n\n udf = udf.reshape(batch_size, n_samples)\n\n dists = z_vals[..., 1:] - z_vals[..., :-1]\n dists = torch.cat([dists, torch.Tensor([sample_dist]).to(device).expand(dists[..., :1].shape)], -1)\n\n dirs = rays_d[:, None, :].expand(pts.shape)\n\n # * the probability of occlusion\n raw_occ = self.udf2logistic(udf, beta, gamma, 1.0)\n # near 0levelset alpha_acc -> 1 others -> 0\n alpha_occ = 1.0 - torch.exp(-F.relu(raw_occ.reshape(batch_size, n_samples)) * dists)\n\n z_samples = sample_pdf(z_vals, alpha_occ[:, :-1], n_importance, det=True).detach()\n\n flag = torch.any(torch.isnan(z_samples)).cpu().numpy().item()\n if flag:\n print(\"z_vals\", z_samples[torch.isnan(z_samples)])\n print('z_vals have nan values')\n pdb.set_trace()\n\n return z_samples", "probing input": " def up_sample_no_occ_aware(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, ):\n \"\"\"\n Different with NeuS, here we sample more points at all possible surfaces where udf is close to 0;\n Since unlike that SDF has clear sign changes, UDF sampling may miss the true surfaces\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample_no_occ_aware(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, ):\n \"\"\"\n Different with NeuS, here we sample more points at all possible surfaces where udf is close to 0;\n Since unlike that SDF has clear sign changes, UDF sampling may miss the true surfaces\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts - rays_o[:, None, :], dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample_no_occ_aware(self, rays_o, rays_d, z_vals, udf, sample_dist,\n n_importance, inv_s, beta, gamma, ):\n \"\"\"\n Different with NeuS, here we sample more points at all possible surfaces where udf is close to 0;\n Since unlike that SDF has clear sign changes, UDF sampling may miss the true surfaces\n \"\"\"\n device = z_vals.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n\n udf = udf.reshape(batch_size, n_samples)\n\n dists = z_vals[..., 1:] - z_vals[..., :-1]\n dists = torch.cat([dists, torch.Tensor([sample_dist]).to(device).expand(dists[..., :1].shape)], -1)\n\n dirs = rays_d[:, None, :].expand(pts.shape)\n\n # * the probability of occlusion\n raw_occ = self.udf2logistic(udf, beta, gamma, 1.0)\n # near 0levelset alpha_acc -> 1 others -> 0\n alpha_occ = 1.0 - torch.exp(-F.relu(raw_occ.reshape(batch_size, n_samples)) * dists)\n\n z_samples = sample_pdf(z_vals, alpha_occ[:, :-1], n_importance, det=True).detach()\n\n flag = torch.any(torch.isnan(z_samples)).cpu().numpy().item()\n if flag:\n print(\"z_vals\", z_samples[torch.isnan(z_samples)])\n print('z_vals have nan values')\n pdb.set_trace()\n\n return z_samples" }, { "id": 7174, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def verify_speakers(self, path2audio_file1, path2audio_file2, threshold=0.7):\n \"\"\"\n Verify if two audio files are from the same speaker or not.\n\n Args:\n path2audio_file1: path to audio wav file of speaker 1\n path2audio_file2: path to audio wav file of speaker 2\n threshold: cosine similarity score used as a threshold to distinguish two embeddings (default = 0.7)\n\n Returns:\n True if both audio files are from same speaker, False otherwise\n \"\"\"\n embs1 = self.get_embedding(path2audio_file1).squeeze()\n embs2 = self.get_embedding(path2audio_file2).squeeze()\n # Length Normalize\n X = embs1 / torch.linalg.norm(embs1)\n Y = embs2 / torch.linalg.norm(embs2)\n # Score\n similarity_score = torch.dot(X, Y) / ((torch.dot(X, X) * torch.dot(Y, Y)) ** 0.5)\n similarity_score = (similarity_score + 1) / 2\n # Decision\n if similarity_score >= threshold:\n logging.info(\" two audio files are from same speaker\")\n return True\n else:\n logging.info(\" two audio files are from different speakers\")\n return False", "probing input": " def verify_speakers(self, path2audio_file1, path2audio_file2, threshold=0.7):\n \"\"\"\n Verify if two audio files are from the same speaker or not.\n\n Args:\n path2audio_file1: path to audio wav file of speaker 1\n path2audio_file2: path to audio wav file of speaker 2\n threshold: cosine similarity score used as a threshold to distinguish two embeddings (default = 0.7)\n\n Returns:\n True if both audio files are from same speaker, False otherwise\n \"\"\"\n embs1 = self.get_embedding(path2audio_file1).squeeze()\n embs2 = self.get_embedding(path2audio_file2).squeeze()\n # Length Normalize\n", "probing input new": " def verify_speakers(self, path2audio_file1, path2audio_file2, threshold=0.7):\n \"\"\"\n Verify if two audio files are from the same speaker or not.\n\n Args:\n path2audio_file1: path to audio wav file of speaker 1\n path2audio_file2: path to audio wav file of speaker 2\n threshold: cosine similarity score used as a threshold to distinguish two embeddings (default = 0.7)\n\n Returns:\n True if both audio files are from same speaker, False otherwise\n \"\"\"\n embs1 = self.get_embedding(path2audio_file1).squeeze()\n embs2 = self.get_embedding(path2audio_file2).squeeze()\n # Length Normalize\n X = embs1 / torch.", "reference": "X=embs1/torch.linalg.norm(embs1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "X=embs1/torch.linalg.norm(embs1)", "y_neg": " X = embs1 / torch.norm(embs1)", "retain": " def verify_speakers(self, path2audio_file1, path2audio_file2, threshold=0.7):\n \"\"\"\n Verify if two audio files are from the same speaker or not.\n\n Args:\n path2audio_file1: path to audio wav file of speaker 1\n path2audio_file2: path to audio wav file of speaker 2\n threshold: cosine similarity score used as a threshold to distinguish two embeddings (default = 0.7)\n\n Returns:\n True if both audio files are from same speaker, False otherwise\n \"\"\"\n embs1 = self.get_embedding(path2audio_file1).squeeze()\n embs2 = self.get_embedding(path2audio_file2).squeeze()\n # Length Normalize\n X = embs1 / torch.linalg.norm(embs1)\n Y = embs2 / torch.linalg.norm(embs2)\n # Score\n similarity_score = torch.dot(X, Y) / ((torch.dot(X, X) * torch.dot(Y, Y)) ** 0.5)\n similarity_score = (similarity_score + 1) / 2\n # Decision\n if similarity_score >= threshold:\n logging.info(\" two audio files are from same speaker\")\n return True\n else:\n logging.info(\" two audio files are from different speakers\")\n return False" }, { "id": 7175, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, batch, out: dict):\n input_xyz = batch[DS.INPUT_PC][0]\n assert input_xyz.ndim == 2, \"Can only forward single batch.\"\n\n if self.hparams.feature == 'normal':\n assert DS.TARGET_NORMAL in batch.keys(), \"normal must be provided in this config!\"\n feat = batch[DS.TARGET_NORMAL][0]\n elif self.hparams.feature == 'sensor':\n assert DS.INPUT_SENSOR_POS in batch.keys(), \"sensor must be provided in this config!\"\n view_dir = batch[DS.INPUT_SENSOR_POS][0] - input_xyz\n view_dir = view_dir / (torch.linalg.norm(view_dir, dim=-1, keepdim=True) + 1e-6)\n feat = view_dir\n else:\n feat = None\n out['feat'] = feat\n\n enc_svh = SparseFeatureHierarchy(\n voxel_size=self.hparams.voxel_size,\n depth=self.hparams.tree_depth,\n device=self.device\n )\n enc_svh.build_point_splatting(input_xyz)\n\n # Compute density by computing points per voxel.\n if self.hparams.runtime_density:\n q_xyz = torch.unique(torch.div(input_xyz, self.hparams.voxel_size).floor().int(), dim=0)\n density = input_xyz.size(0) / q_xyz.size(0)\n exp.logger.info(f\"Density {density}, # pts = {input_xyz.size(0)}\")\n\n if self.hparams.runtime_visualize:\n vis.show_3d([vis.pointcloud(input_xyz, normal=feat)], enc_svh.get_visualization())\n\n feat = self.network.encoder(input_xyz, feat, enc_svh, 0)\n feat, dec_svh, udf_svh = self.network.unet(\n feat, enc_svh,\n adaptive_depth=self.hparams.adaptive_depth,\n gt_decoder_svh=out.get('gt_svh', None)\n )\n\n if all([dec_svh.grids[d] is None for d in range(self.hparams.adaptive_depth)]):\n if self.trainer.training or self.trainer.validating:\n # In case training data is corrupted (pd & gt not aligned)...\n exp.logger.warning(\"Empty grid detected during training/validation.\")\n return None\n\n out.update({'enc_svh': enc_svh, 'dec_svh': dec_svh, 'dec_tmp_svh': udf_svh})\n if self.trainer.training:\n SVH_CACHE.append([enc_svh, dec_svh, udf_svh])\n\n if self.hparams.geometry == 'kernel':\n output_field = KernelField(\n svh=dec_svh,\n interpolator=self.network.interpolators,\n features=feat.basis_features,\n approx_kernel_grad=False\n )\n if self.hparams.solver_verbose:\n output_field.solver_config['verbose'] = True\n\n normal_xyz = torch.cat([dec_svh.get_voxel_centers(d) for d in range(self.hparams.adaptive_depth)])\n normal_value = torch.cat([feat.normal_features[d] for d in range(self.hparams.adaptive_depth)])\n\n normal_weight = self.hparams.solver.normal_weight / normal_xyz.size(0) * \\\n (self.hparams.voxel_size ** 2)\n output_field.solve_non_fused(\n pos_xyz=input_xyz,\n normal_xyz=normal_xyz,\n normal_value=-normal_value,\n pos_weight=self.hparams.solver.pos_weight / input_xyz.size(0),\n normal_weight=normal_weight,\n reg_weight=1.0\n )\n\n elif self.hparams.geometry == 'neural':\n output_field = NeuralField(\n svh=dec_svh,\n decoder=self.network.sdf_decoder,\n features=feat.basis_features\n )\n\n else:\n raise NotImplementedError\n\n if self.hparams.udf.enabled:\n mask_field = NeuralField(\n svh=udf_svh,\n decoder=self.network.udf_decoder,\n features=feat.udf_features\n )\n mask_field.set_level_set(2 * self.hparams.voxel_size)\n else:\n mask_field = LayerField(dec_svh, self.hparams.adaptive_depth)\n output_field.set_mask_field(mask_field)\n\n out.update({\n 'structure_features': feat.structure_features,\n 'normal_features': feat.normal_features,\n 'basis_features': feat.basis_features,\n 'field': output_field\n })\n return out", "probing input": " def forward(self, batch, out: dict):\n input_xyz = batch[DS.INPUT_PC][0]\n assert input_xyz.ndim == 2, \"Can only forward single batch.\"\n\n if self.hparams.feature == 'normal':\n assert DS.TARGET_NORMAL in batch.keys(), \"normal must be provided in this config!\"\n feat = batch[DS.TARGET_NORMAL][0]\n elif self.hparams.feature == 'sensor':\n assert DS.INPUT_SENSOR_POS in batch.keys(), \"sensor must be provided in this config!\"\n view_dir = batch[DS.INPUT_SENSOR_POS][0] - input_xyz\n", "probing input new": " def forward(self, batch, out: dict):\n input_xyz = batch[DS.INPUT_PC][0]\n assert input_xyz.ndim == 2, \"Can only forward single batch.\"\n\n if self.hparams.feature == 'normal':\n assert DS.TARGET_NORMAL in batch.keys(), \"normal must be provided in this config!\"\n feat = batch[DS.TARGET_NORMAL][0]\n elif self.hparams.feature == 'sensor':\n assert DS.INPUT_SENSOR_POS in batch.keys(), \"sensor must be provided in this config!\"\n view_dir = batch[DS.INPUT_SENSOR_POS][0] - input_xyz\n view_dir = view_dir / (torch.", "reference": "view_dir=view_dir/(torch.linalg.norm(view_dir,dim=-1,keepdim=True)+1e-6)", "reference dict": { "enc_svh": "SparseFeatureHierarchy", "output_field": "NeuralField", "mask_field": "LayerField" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "view_dir=view_dir/(torch.linalg.norm(view_dir,dim=-1,keepdim=True)+1e-6)", "y_neg": " view_dir = view_dir / (torch.norm(view_dir, dim=-1, keepdim=True) + 1e-10)", "retain": " def forward(self, batch, out: dict):\n input_xyz = batch[DS.INPUT_PC][0]\n assert input_xyz.ndim == 2, \"Can only forward single batch.\"\n\n if self.hparams.feature == 'normal':\n assert DS.TARGET_NORMAL in batch.keys(), \"normal must be provided in this config!\"\n feat = batch[DS.TARGET_NORMAL][0]\n elif self.hparams.feature == 'sensor':\n assert DS.INPUT_SENSOR_POS in batch.keys(), \"sensor must be provided in this config!\"\n view_dir = batch[DS.INPUT_SENSOR_POS][0] - input_xyz\n view_dir = view_dir / (torch.linalg.norm(view_dir, dim=-1, keepdim=True) + 1e-6)\n feat = view_dir\n else:\n feat = None\n out['feat'] = feat\n\n enc_svh = SparseFeatureHierarchy(\n voxel_size=self.hparams.voxel_size,\n depth=self.hparams.tree_depth,\n device=self.device\n )\n enc_svh.build_point_splatting(input_xyz)\n\n # Compute density by computing points per voxel.\n if self.hparams.runtime_density:\n q_xyz = torch.unique(torch.div(input_xyz, self.hparams.voxel_size).floor().int(), dim=0)\n density = input_xyz.size(0) / q_xyz.size(0)\n exp.logger.info(f\"Density {density}, # pts = {input_xyz.size(0)}\")\n\n if self.hparams.runtime_visualize:\n vis.show_3d([vis.pointcloud(input_xyz, normal=feat)], enc_svh.get_visualization())\n\n feat = self.network.encoder(input_xyz, feat, enc_svh, 0)\n feat, dec_svh, udf_svh = self.network.unet(\n feat, enc_svh,\n adaptive_depth=self.hparams.adaptive_depth,\n gt_decoder_svh=out.get('gt_svh', None)\n )\n\n if all([dec_svh.grids[d] is None for d in range(self.hparams.adaptive_depth)]):\n if self.trainer.training or self.trainer.validating:\n # In case training data is corrupted (pd & gt not aligned)...\n exp.logger.warning(\"Empty grid detected during training/validation.\")\n return None\n\n out.update({'enc_svh': enc_svh, 'dec_svh': dec_svh, 'dec_tmp_svh': udf_svh})\n if self.trainer.training:\n SVH_CACHE.append([enc_svh, dec_svh, udf_svh])\n\n if self.hparams.geometry == 'kernel':\n output_field = KernelField(\n svh=dec_svh,\n interpolator=self.network.interpolators,\n features=feat.basis_features,\n approx_kernel_grad=False\n )\n if self.hparams.solver_verbose:\n output_field.solver_config['verbose'] = True\n\n normal_xyz = torch.cat([dec_svh.get_voxel_centers(d) for d in range(self.hparams.adaptive_depth)])\n normal_value = torch.cat([feat.normal_features[d] for d in range(self.hparams.adaptive_depth)])\n\n normal_weight = self.hparams.solver.normal_weight / normal_xyz.size(0) * \\\n (self.hparams.voxel_size ** 2)\n output_field.solve_non_fused(\n pos_xyz=input_xyz,\n normal_xyz=normal_xyz,\n normal_value=-normal_value,\n pos_weight=self.hparams.solver.pos_weight / input_xyz.size(0),\n normal_weight=normal_weight,\n reg_weight=1.0\n )\n\n elif self.hparams.geometry == 'neural':\n output_field = NeuralField(\n svh=dec_svh,\n decoder=self.network.sdf_decoder,\n features=feat.basis_features\n )\n\n else:\n raise NotImplementedError\n\n if self.hparams.udf.enabled:\n mask_field = NeuralField(\n svh=udf_svh,\n decoder=self.network.udf_decoder,\n features=feat.udf_features\n )\n mask_field.set_level_set(2 * self.hparams.voxel_size)\n else:\n mask_field = LayerField(dec_svh, self.hparams.adaptive_depth)\n output_field.set_mask_field(mask_field)\n\n out.update({\n 'structure_features': feat.structure_features,\n 'normal_features': feat.normal_features,\n 'basis_features': feat.basis_features,\n 'field': output_field\n })\n return out" }, { "id": 7178, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n def check(op):\n result = op(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n result_out = torch.empty_like(result)\n op(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n check(torch.linalg.norm)\n if ord is not None and dim is not None:\n check(torch.linalg.matrix_norm)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro']\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, S), ord_matrix, None),\n ((S, S), ord_matrix, (0, 1)),\n ((S, S), ord_matrix, (1, 0)),\n ((S, S, S, S), ord_matrix, (2, 0)),\n ((S, S, S, S), ord_matrix, (-1, -2)),\n ((S, S, S, S), ord_matrix, (-1, -3)),\n ((S, S, S, S), ord_matrix, (-3, 2)),\n ]\n L = 1_000\n\n if dtype == torch.double:\n test_cases.append(((L, L), ord_matrix, None))\n\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)", "probing input": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n", "probing input new": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,dim,keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,dim,keepdim)", "y_neg": " result = torch.norm(input, ord=ord, dim=dim, keepdim=keepdim)", "retain": " def test_norm_matrix(self, device, dtype):\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n def check(op):\n result = op(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n result_out = torch.empty_like(result)\n op(input, ord, dim, keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n check(torch.linalg.norm)\n if ord is not None and dim is not None:\n check(torch.linalg.matrix_norm)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro']\n S = 10\n test_cases = [\n # input size, p settings, dim\n ((S, S), ord_matrix, None),\n ((S, S), ord_matrix, (0, 1)),\n ((S, S), ord_matrix, (1, 0)),\n ((S, S, S, S), ord_matrix, (2, 0)),\n ((S, S, S, S), ord_matrix, (-1, -2)),\n ((S, S, S, S), ord_matrix, (-1, -3)),\n ((S, S, S, S), ord_matrix, (-3, 2)),\n ]\n L = 1_000\n\n if dtype == torch.double:\n test_cases.append(((L, L), ord_matrix, None))\n\n for keepdim in [True, False]:\n for input_size, ord_settings, dim in test_cases:\n input = torch.randn(*input_size, dtype=dtype, device=device)\n for ord in ord_settings:\n run_test_case(input, ord, dim, keepdim)" }, { "id": 7179, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_complex(self, device, dtype):\n def gen_error_message(input_size, ord, keepdim, dim=None):\n return \"complex norm failed for input size %s, ord=%s, keepdim=%s, dim=%s\" % (\n input_size, ord, keepdim, dim)\n\n vector_ords = [None, 0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = [None, 'fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n\n # Test supported ords\n for keepdim in [False, True]:\n # vector norm\n x = torch.randn(25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in vector_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n torch.linalg.norm(x, ord, keepdim=keepdim, out=res_out)\n self.assertEqual(res_out.shape, expected.shape, msg=msg)\n self.assertEqual(res_out.cpu(), expected, msg=msg)\n\n # matrix norm\n x = torch.randn(25, 25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in matrix_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n torch.linalg.norm(x, ord, keepdim=keepdim, out=res_out)\n self.assertEqual(res_out.shape, expected.shape, msg=msg)\n self.assertEqual(res_out.cpu(), expected, msg=msg)", "probing input": " def test_norm_complex(self, device, dtype):\n def gen_error_message(input_size, ord, keepdim, dim=None):\n return \"complex norm failed for input size %s, ord=%s, keepdim=%s, dim=%s\" % (\n input_size, ord, keepdim, dim)\n\n vector_ords = [None, 0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = [None, 'fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n\n # Test supported ords\n for keepdim in [False, True]:\n # vector norm\n x = torch.randn(25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in vector_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n", "probing input new": " def test_norm_complex(self, device, dtype):\n def gen_error_message(input_size, ord, keepdim, dim=None):\n return \"complex norm failed for input size %s, ord=%s, keepdim=%s, dim=%s\" % (\n input_size, ord, keepdim, dim)\n\n vector_ords = [None, 0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = [None, 'fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n\n # Test supported ords\n for keepdim in [False, True]:\n # vector norm\n x = torch.randn(25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in vector_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n torch.", "reference": "torch.linalg.norm(x,ord,keepdim=keepdim,out=res_out)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "torch.linalg.norm(x,ord,keepdim=keepdim,out=res_out)", "y_neg": " torch.norm(x, ord, keepdim=keepdim, out=res_out)", "retain": " def test_norm_complex(self, device, dtype):\n def gen_error_message(input_size, ord, keepdim, dim=None):\n return \"complex norm failed for input size %s, ord=%s, keepdim=%s, dim=%s\" % (\n input_size, ord, keepdim, dim)\n\n vector_ords = [None, 0, 1, 2, 3, inf, -1, -2, -3, -inf]\n matrix_ords = [None, 'fro', 'nuc', 1, 2, inf, -1, -2, -inf]\n\n # Test supported ords\n for keepdim in [False, True]:\n # vector norm\n x = torch.randn(25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in vector_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n torch.linalg.norm(x, ord, keepdim=keepdim, out=res_out)\n self.assertEqual(res_out.shape, expected.shape, msg=msg)\n self.assertEqual(res_out.cpu(), expected, msg=msg)\n\n # matrix norm\n x = torch.randn(25, 25, device=device, dtype=dtype)\n xn = x.cpu().numpy()\n for ord in matrix_ords:\n res = torch.linalg.norm(x, ord, keepdim=keepdim).cpu()\n expected = np.linalg.norm(xn, ord, keepdims=keepdim)\n msg = gen_error_message(x.size(), ord, keepdim)\n self.assertEqual(res.shape, expected.shape, msg=msg)\n self.assertEqual(res, expected, msg=msg)\n\n res_out = torch.tensor([]).to(device)\n torch.linalg.norm(x, ord, keepdim=keepdim, out=res_out)\n self.assertEqual(res_out.shape, expected.shape, msg=msg)\n self.assertEqual(res_out.cpu(), expected, msg=msg)" }, { "id": 7183, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize_quaternion(in_quaternion: torch.Tensor) -> torch.Tensor:\n k = torch.sign(in_quaternion[..., 0:1])\n # NOTE: torch sign returns 0 as sign value when value is 0.0\n k = torch.where(k == 0, 1.0, k)\n k2 = k / torch.linalg.norm(in_quaternion, dim=-1, keepdim=True)\n # normalize quaternion\n in_q = k2 * in_quaternion\n return in_q", "probing input": "def normalize_quaternion(in_quaternion: torch.Tensor) -> torch.Tensor:\n k = torch.sign(in_quaternion[..., 0:1])\n # NOTE: torch sign returns 0 as sign value when value is 0.0\n k = torch.where(k == 0, 1.0, k)\n", "probing input new": "def normalize_quaternion(in_quaternion: torch.Tensor) -> torch.Tensor:\n k = torch.sign(in_quaternion[..., 0:1])\n # NOTE: torch sign returns 0 as sign value when value is 0.0\n k = torch.where(k == 0, 1.0, k)\n k2 = k / torch.", "reference": "k2=k/torch.linalg.norm(in_quaternion,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "k2=k/torch.linalg.norm(in_quaternion,dim=-1,keepdim=True)", "y_neg": " k2 = k / torch.norm(k, dim=-1, keepdim=True)", "retain": "def normalize_quaternion(in_quaternion: torch.Tensor) -> torch.Tensor:\n k = torch.sign(in_quaternion[..., 0:1])\n # NOTE: torch sign returns 0 as sign value when value is 0.0\n k = torch.where(k == 0, 1.0, k)\n k2 = k / torch.linalg.norm(in_quaternion, dim=-1, keepdim=True)\n # normalize quaternion\n in_q = k2 * in_quaternion\n return in_q" }, { "id": 7185, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def build_all_rays(H, W, fx, fy, cx, cy, c2w, device, nerf_coordinate=True, dir_normalize=False):\n \"\"\"\n Build rays for a whole image.\n \"\"\"\n # !!! do not normalize the dir, otherwise the scale of pose will be deteriorated\n dir_normalize = DIR_NORMALIZE\n if isinstance(c2w, np.ndarray):\n c2w = torch.from_numpy(c2w).to(device)\n\n x, y = torch.meshgrid(\n torch.linspace(0, W-1, W).to(device),\n torch.linspace(0, H-1, H).to(device),\n indexing='ij',\n )\n x, y = x.t(), y.t() # [W, H] -> [H, W]\n if nerf_coordinate:\n # https://github.com/cvg/nice-slam/issues/10#issuecomment-1128590013\n dirs = torch.stack([\n (x - cx) / fx,\n -(y - cy) / fy,\n -torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n else:\n dirs = torch.stack([\n (x - cx) / fx,\n (y - cy) / fy,\n torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n\n if dir_normalize:\n dirs = dirs / torch.linalg.norm(dirs, ord=2, dim=-1, keepdim=True) # H, W, 3\n # comment it if you are sure the pose is fine\n raise TypeError(\"Ray direction shouldn't be normalized, otherwise the scale of pose will be destroyed!\")\n\n rays_d = dirs @ c2w[:3, :3].t() # [H, W, 3]\n rays_o = c2w[:3, 3].reshape(1, 1, 3).repeat(H, W, 1) # [n_rays, 3]\n\n return rays_o, rays_d", "probing input": "def build_all_rays(H, W, fx, fy, cx, cy, c2w, device, nerf_coordinate=True, dir_normalize=False):\n \"\"\"\n Build rays for a whole image.\n \"\"\"\n # !!! do not normalize the dir, otherwise the scale of pose will be deteriorated\n dir_normalize = DIR_NORMALIZE\n if isinstance(c2w, np.ndarray):\n c2w = torch.from_numpy(c2w).to(device)\n\n x, y = torch.meshgrid(\n torch.linspace(0, W-1, W).to(device),\n torch.linspace(0, H-1, H).to(device),\n indexing='ij',\n )\n x, y = x.t(), y.t() # [W, H] -> [H, W]\n if nerf_coordinate:\n # https://github.com/cvg/nice-slam/issues/10#issuecomment-1128590013\n dirs = torch.stack([\n (x - cx) / fx,\n -(y - cy) / fy,\n -torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n else:\n dirs = torch.stack([\n (x - cx) / fx,\n (y - cy) / fy,\n torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n\n if dir_normalize:\n", "probing input new": "def build_all_rays(H, W, fx, fy, cx, cy, c2w, device, nerf_coordinate=True, dir_normalize=False):\n \"\"\"\n Build rays for a whole image.\n \"\"\"\n # !!! do not normalize the dir, otherwise the scale of pose will be deteriorated\n dir_normalize = DIR_NORMALIZE\n if isinstance(c2w, np.ndarray):\n c2w = torch.from_numpy(c2w).to(device)\n\n x, y = torch.meshgrid(\n torch.linspace(0, W-1, W).to(device),\n torch.linspace(0, H-1, H).to(device),\n indexing='ij',\n )\n x, y = x.t(), y.t() # [W, H] -> [H, W]\n if nerf_coordinate:\n # https://github.com/cvg/nice-slam/issues/10#issuecomment-1128590013\n dirs = torch.stack([\n (x - cx) / fx,\n -(y - cy) / fy,\n -torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n else:\n dirs = torch.stack([\n (x - cx) / fx,\n (y - cy) / fy,\n torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n\n if dir_normalize:\n dirs = dirs / torch.", "reference": "dirs=dirs/torch.linalg.norm(dirs,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dirs=dirs/torch.linalg.norm(dirs,ord=2,dim=-1,keepdim=True)", "y_neg": " dirs = dirs / torch.norm(dirs, dim=-1, keepdim=True)", "retain": "def build_all_rays(H, W, fx, fy, cx, cy, c2w, device, nerf_coordinate=True, dir_normalize=False):\n \"\"\"\n Build rays for a whole image.\n \"\"\"\n # !!! do not normalize the dir, otherwise the scale of pose will be deteriorated\n dir_normalize = DIR_NORMALIZE\n if isinstance(c2w, np.ndarray):\n c2w = torch.from_numpy(c2w).to(device)\n\n x, y = torch.meshgrid(\n torch.linspace(0, W-1, W).to(device),\n torch.linspace(0, H-1, H).to(device),\n indexing='ij',\n )\n x, y = x.t(), y.t() # [W, H] -> [H, W]\n if nerf_coordinate:\n # https://github.com/cvg/nice-slam/issues/10#issuecomment-1128590013\n dirs = torch.stack([\n (x - cx) / fx,\n -(y - cy) / fy,\n -torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n else:\n dirs = torch.stack([\n (x - cx) / fx,\n (y - cy) / fy,\n torch.ones_like(x),\n ], dim=-1).to(device) # (H, W, 3)\n\n if dir_normalize:\n dirs = dirs / torch.linalg.norm(dirs, ord=2, dim=-1, keepdim=True) # H, W, 3\n # comment it if you are sure the pose is fine\n raise TypeError(\"Ray direction shouldn't be normalized, otherwise the scale of pose will be destroyed!\")\n\n rays_d = dirs @ c2w[:3, :3].t() # [H, W, 3]\n rays_o = c2w[:3, 3].reshape(1, 1, 3).repeat(H, W, 1) # [n_rays, 3]\n\n return rays_o, rays_d" }, { "id": 7188, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def refine_ray_generation(campos,\n raydir,\n point_count,\n prev_ts,\n prev_weights,\n domain_size=1.,\n jitter=0,\n **kargs):\n # inputs\n # campos: N x 3\n # raydir: N x Rays x 3, must be normalized\n # point_count: int\n # prev_ts: N x Rays x PrevSamples\n # prev_weights: N x Rays x PrevSamples\n # outputs\n # raypos: N x Rays x Samples x 3\n # segment_length: N x Rays x Samples\n # valid: N x Rays x Samples\n # ts: N x Rays x Samples\n with torch.no_grad():\n end_point_ts = sample_pdf(prev_ts[..., None], prev_weights,\n point_count + 1, jitter <= 0)\n end_point_ts = end_point_ts.view(end_point_ts.shape[:-1])\n segment_length = end_point_ts[:, :, 1:] - end_point_ts[:, :, :-1]\n middle_point_ts = (end_point_ts[:, :, :-1] +\n end_point_ts[:, :, 1:]) / 2\n raypos = campos[:, None,\n None, :] + raydir[:, :,\n None, :] * middle_point_ts[:, :, :,\n None]\n valid = torch.ones_like(middle_point_ts,\n dtype=middle_point_ts.dtype,\n device=middle_point_ts.device)\n segment_length*=torch.linalg.norm(raydir[..., None, :], axis=-1)\n return raypos, segment_length, valid, middle_point_ts", "probing input": "def refine_ray_generation(campos,\n raydir,\n point_count,\n prev_ts,\n prev_weights,\n domain_size=1.,\n jitter=0,\n **kargs):\n # inputs\n # campos: N x 3\n # raydir: N x Rays x 3, must be normalized\n # point_count: int\n # prev_ts: N x Rays x PrevSamples\n # prev_weights: N x Rays x PrevSamples\n # outputs\n # raypos: N x Rays x Samples x 3\n # segment_length: N x Rays x Samples\n # valid: N x Rays x Samples\n # ts: N x Rays x Samples\n with torch.no_grad():\n end_point_ts = sample_pdf(prev_ts[..., None], prev_weights,\n point_count + 1, jitter <= 0)\n end_point_ts = end_point_ts.view(end_point_ts.shape[:-1])\n segment_length = end_point_ts[:, :, 1:] - end_point_ts[:, :, :-1]\n middle_point_ts = (end_point_ts[:, :, :-1] +\n end_point_ts[:, :, 1:]) / 2\n raypos = campos[:, None,\n None, :] + raydir[:, :,\n None, :] * middle_point_ts[:, :, :,\n None]\n valid = torch.ones_like(middle_point_ts,\n dtype=middle_point_ts.dtype,\n device=middle_point_ts.device)\n", "probing input new": "def refine_ray_generation(campos,\n raydir,\n point_count,\n prev_ts,\n prev_weights,\n domain_size=1.,\n jitter=0,\n **kargs):\n # inputs\n # campos: N x 3\n # raydir: N x Rays x 3, must be normalized\n # point_count: int\n # prev_ts: N x Rays x PrevSamples\n # prev_weights: N x Rays x PrevSamples\n # outputs\n # raypos: N x Rays x Samples x 3\n # segment_length: N x Rays x Samples\n # valid: N x Rays x Samples\n # ts: N x Rays x Samples\n with torch.no_grad():\n end_point_ts = sample_pdf(prev_ts[..., None], prev_weights,\n point_count + 1, jitter <= 0)\n end_point_ts = end_point_ts.view(end_point_ts.shape[:-1])\n segment_length = end_point_ts[:, :, 1:] - end_point_ts[:, :, :-1]\n middle_point_ts = (end_point_ts[:, :, :-1] +\n end_point_ts[:, :, 1:]) / 2\n raypos = campos[:, None,\n None, :] + raydir[:, :,\n None, :] * middle_point_ts[:, :, :,\n None]\n valid = torch.ones_like(middle_point_ts,\n dtype=middle_point_ts.dtype,\n device=middle_point_ts.device)\n segment_length*=torch.", "reference": "segment_length*=torch.linalg.norm(raydir[...,None,:],axis=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "segment_length*=torch.linalg.norm(raydir[...,None,:],axis=-1)", "y_neg": " segment_length*=torch.norm(raydir,dim=-1,keepdim=True)", "retain": "def refine_ray_generation(campos,\n raydir,\n point_count,\n prev_ts,\n prev_weights,\n domain_size=1.,\n jitter=0,\n **kargs):\n # inputs\n # campos: N x 3\n # raydir: N x Rays x 3, must be normalized\n # point_count: int\n # prev_ts: N x Rays x PrevSamples\n # prev_weights: N x Rays x PrevSamples\n # outputs\n # raypos: N x Rays x Samples x 3\n # segment_length: N x Rays x Samples\n # valid: N x Rays x Samples\n # ts: N x Rays x Samples\n with torch.no_grad():\n end_point_ts = sample_pdf(prev_ts[..., None], prev_weights,\n point_count + 1, jitter <= 0)\n end_point_ts = end_point_ts.view(end_point_ts.shape[:-1])\n segment_length = end_point_ts[:, :, 1:] - end_point_ts[:, :, :-1]\n middle_point_ts = (end_point_ts[:, :, :-1] +\n end_point_ts[:, :, 1:]) / 2\n raypos = campos[:, None,\n None, :] + raydir[:, :,\n None, :] * middle_point_ts[:, :, :,\n None]\n valid = torch.ones_like(middle_point_ts,\n dtype=middle_point_ts.dtype,\n device=middle_point_ts.device)\n segment_length*=torch.linalg.norm(raydir[..., None, :], axis=-1)\n return raypos, segment_length, valid, middle_point_ts" }, { "id": 7190, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, text):\n # tokens = clip.tokenize(text).to(self.device)\n tokens = tokenize_with_truncation(text, truncate=True).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z", "probing input": " def forward(self, text):\n # tokens = clip.tokenize(text).to(self.device)\n tokens = tokenize_with_truncation(text, truncate=True).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n", "probing input new": " def forward(self, text):\n # tokens = clip.tokenize(text).to(self.device)\n tokens = tokenize_with_truncation(text, truncate=True).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.", "reference": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "y_neg": " z = z / torch.norm(z, dim=-1, keepdim=True)", "retain": " def forward(self, text):\n # tokens = clip.tokenize(text).to(self.device)\n tokens = tokenize_with_truncation(text, truncate=True).to(self.device)\n z = self.model.encode_text(tokens)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z" }, { "id": 7191, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, text):\n tok_text = self.tokenizer(text).to(self.device)\n z = self.model.encode_text(tok_text)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z", "probing input": " def forward(self, text):\n tok_text = self.tokenizer(text).to(self.device)\n z = self.model.encode_text(tok_text)\n if self.normalize:\n", "probing input new": " def forward(self, text):\n tok_text = self.tokenizer(text).to(self.device)\n z = self.model.encode_text(tok_text)\n if self.normalize:\n z = z / torch.", "reference": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "z=z/torch.linalg.norm(z,dim=1,keepdim=True)", "y_neg": " z = z / torch.norm(z, dim=-1, keepdim=True)", "retain": " def forward(self, text):\n tok_text = self.tokenizer(text).to(self.device)\n z = self.model.encode_text(tok_text)\n if self.normalize:\n z = z / torch.linalg.norm(z, dim=1, keepdim=True)\n return z" }, { "id": 7193, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_get_tile_bin_edges():\n from gsplat import _torch_impl\n from gsplat import get_tile_bin_edges\n\n torch.manual_seed(42)\n\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.randn((num_points, 3), device=device)\n glob_scale = 0.3\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n viewmat = torch.eye(4, device=device)\n fx, fy = 3.0, 3.0\n H, W = 512, 512\n clip_thresh = 0.01\n\n BLOCK_SIZE = 16\n tile_bounds = (\n (W + BLOCK_SIZE - 1) // BLOCK_SIZE,\n (H + BLOCK_SIZE - 1) // BLOCK_SIZE,\n 1,\n )\n\n (\n _cov3d,\n _cov2d,\n _xys,\n _depths,\n _radii,\n _conics,\n _compensation,\n _num_tiles_hit,\n _masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, W / 2, H / 2),\n (H, W),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n _xys = _xys[_masks]\n _depths = _depths[_masks]\n _radii = _radii[_masks]\n _conics = _conics[_masks]\n _num_tiles_hit = _num_tiles_hit[_masks]\n\n num_points = num_points - torch.count_nonzero(~_masks).item()\n\n _cum_tiles_hit = torch.cumsum(_num_tiles_hit, dim=0, dtype=torch.int32)\n _num_intersects = _cum_tiles_hit[-1].item()\n _depths = _depths.contiguous()\n\n (\n _isect_ids_unsorted,\n _gaussian_ids_unsorted,\n ) = _torch_impl.map_gaussian_to_intersects(\n num_points, _xys, _depths, _radii, _cum_tiles_hit, tile_bounds, BLOCK_SIZE\n )\n\n # Sorting isect_ids_unsorted\n sorted_values, sorted_indices = torch.sort(_isect_ids_unsorted)\n\n _isect_ids_sorted = sorted_values\n _gaussian_ids_sorted = torch.gather(_gaussian_ids_unsorted, 0, sorted_indices)\n\n _tile_bins = _torch_impl.get_tile_bin_edges(\n _num_intersects, _isect_ids_sorted, tile_bounds\n )\n tile_bins = get_tile_bin_edges(_num_intersects, _isect_ids_sorted, tile_bounds)\n\n torch.testing.assert_close(_tile_bins, tile_bins)", "probing input": "def test_get_tile_bin_edges():\n from gsplat import _torch_impl\n from gsplat import get_tile_bin_edges\n\n torch.manual_seed(42)\n\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.randn((num_points, 3), device=device)\n glob_scale = 0.3\n quats = torch.randn((num_points, 4), device=device)\n", "probing input new": "def test_get_tile_bin_edges():\n from gsplat import _torch_impl\n from gsplat import get_tile_bin_edges\n\n torch.manual_seed(42)\n\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.randn((num_points, 3), device=device)\n glob_scale = 0.3\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.", "reference": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats /= torch.norm(quats, dim=1, keepdim=True)", "retain": "def test_get_tile_bin_edges():\n from gsplat import _torch_impl\n from gsplat import get_tile_bin_edges\n\n torch.manual_seed(42)\n\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.randn((num_points, 3), device=device)\n glob_scale = 0.3\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n viewmat = torch.eye(4, device=device)\n fx, fy = 3.0, 3.0\n H, W = 512, 512\n clip_thresh = 0.01\n\n BLOCK_SIZE = 16\n tile_bounds = (\n (W + BLOCK_SIZE - 1) // BLOCK_SIZE,\n (H + BLOCK_SIZE - 1) // BLOCK_SIZE,\n 1,\n )\n\n (\n _cov3d,\n _cov2d,\n _xys,\n _depths,\n _radii,\n _conics,\n _compensation,\n _num_tiles_hit,\n _masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, W / 2, H / 2),\n (H, W),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n _xys = _xys[_masks]\n _depths = _depths[_masks]\n _radii = _radii[_masks]\n _conics = _conics[_masks]\n _num_tiles_hit = _num_tiles_hit[_masks]\n\n num_points = num_points - torch.count_nonzero(~_masks).item()\n\n _cum_tiles_hit = torch.cumsum(_num_tiles_hit, dim=0, dtype=torch.int32)\n _num_intersects = _cum_tiles_hit[-1].item()\n _depths = _depths.contiguous()\n\n (\n _isect_ids_unsorted,\n _gaussian_ids_unsorted,\n ) = _torch_impl.map_gaussian_to_intersects(\n num_points, _xys, _depths, _radii, _cum_tiles_hit, tile_bounds, BLOCK_SIZE\n )\n\n # Sorting isect_ids_unsorted\n sorted_values, sorted_indices = torch.sort(_isect_ids_unsorted)\n\n _isect_ids_sorted = sorted_values\n _gaussian_ids_sorted = torch.gather(_gaussian_ids_unsorted, 0, sorted_indices)\n\n _tile_bins = _torch_impl.get_tile_bin_edges(\n _num_intersects, _isect_ids_sorted, tile_bounds\n )\n tile_bins = get_tile_bin_edges(_num_intersects, _isect_ids_sorted, tile_bounds)\n\n torch.testing.assert_close(_tile_bins, tile_bins)" }, { "id": 7194, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def threshold_edges(self, x, threshold):\n # get mean attention\n # i) sparsify on S_hat\n if self.opt['new_edges'] == 'k_hop_att' and self.opt['sparsify'] == 'S_hat':\n attention_weights = self.odefunc.attention_weights\n mean_att = attention_weights\n # ii) sparsify on recalculated attentions\n else:#elif self.opt['sparsify'] == 'recalc_att':\n attention_weights = self.get_attention_weights(x)\n mean_att = attention_weights.mean(dim=1, keepdim=False)\n\n if self.opt['use_flux']:\n src_features = x[self.data_edge_index[0, :], :]\n dst_features = x[self.data_edge_index[1, :], :]\n delta = torch.linalg.norm(src_features - dst_features, dim=1)\n mean_att = mean_att * delta\n\n # just for the test where threshold catches all edges\n # unique_att = torch.unique(mean_att, sorted=False, return_inverse=False, return_counts=False, dim=0)\n # print(f\"mean_att {mean_att.shape}, unqiue atts: {unique_att.shape}\")\n # threshold\n\n # threshold = torch.quantile(mean_att, 1 - self.opt['att_samp_pct'])\n mask = mean_att > threshold\n self.odefunc.edge_index = self.data_edge_index[:, mask.T]\n sampled_attention_weights = self.renormalise_attention(mean_att[mask])\n print('retaining {} of {} edges'.format(self.odefunc.edge_index.shape[1], self.data_edge_index.shape[1]))\n self.data_edge_index = self.data_edge_index[:, mask.T]\n self.odefunc.edge_weight = sampled_attention_weights #rewiring structure so need to replace any preproc ew's with new ew's\n self.odefunc.attention_weights = sampled_attention_weights", "probing input": " def threshold_edges(self, x, threshold):\n # get mean attention\n # i) sparsify on S_hat\n if self.opt['new_edges'] == 'k_hop_att' and self.opt['sparsify'] == 'S_hat':\n attention_weights = self.odefunc.attention_weights\n mean_att = attention_weights\n # ii) sparsify on recalculated attentions\n else:#elif self.opt['sparsify'] == 'recalc_att':\n attention_weights = self.get_attention_weights(x)\n mean_att = attention_weights.mean(dim=1, keepdim=False)\n\n if self.opt['use_flux']:\n src_features = x[self.data_edge_index[0, :], :]\n dst_features = x[self.data_edge_index[1, :], :]\n", "probing input new": " def threshold_edges(self, x, threshold):\n # get mean attention\n # i) sparsify on S_hat\n if self.opt['new_edges'] == 'k_hop_att' and self.opt['sparsify'] == 'S_hat':\n attention_weights = self.odefunc.attention_weights\n mean_att = attention_weights\n # ii) sparsify on recalculated attentions\n else:#elif self.opt['sparsify'] == 'recalc_att':\n attention_weights = self.get_attention_weights(x)\n mean_att = attention_weights.mean(dim=1, keepdim=False)\n\n if self.opt['use_flux']:\n src_features = x[self.data_edge_index[0, :], :]\n dst_features = x[self.data_edge_index[1, :], :]\n delta = torch.", "reference": "delta=torch.linalg.norm(src_features-dst_features,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "delta=torch.linalg.norm(src_features-dst_features,dim=1)", "y_neg": " delta = torch.norm(src_features - dst_features, p='fro', dim=1, keepdim=True)", "retain": " def threshold_edges(self, x, threshold):\n # get mean attention\n # i) sparsify on S_hat\n if self.opt['new_edges'] == 'k_hop_att' and self.opt['sparsify'] == 'S_hat':\n attention_weights = self.odefunc.attention_weights\n mean_att = attention_weights\n # ii) sparsify on recalculated attentions\n else:#elif self.opt['sparsify'] == 'recalc_att':\n attention_weights = self.get_attention_weights(x)\n mean_att = attention_weights.mean(dim=1, keepdim=False)\n\n if self.opt['use_flux']:\n src_features = x[self.data_edge_index[0, :], :]\n dst_features = x[self.data_edge_index[1, :], :]\n delta = torch.linalg.norm(src_features - dst_features, dim=1)\n mean_att = mean_att * delta\n\n # just for the test where threshold catches all edges\n # unique_att = torch.unique(mean_att, sorted=False, return_inverse=False, return_counts=False, dim=0)\n # print(f\"mean_att {mean_att.shape}, unqiue atts: {unique_att.shape}\")\n # threshold\n\n # threshold = torch.quantile(mean_att, 1 - self.opt['att_samp_pct'])\n mask = mean_att > threshold\n self.odefunc.edge_index = self.data_edge_index[:, mask.T]\n sampled_attention_weights = self.renormalise_attention(mean_att[mask])\n print('retaining {} of {} edges'.format(self.odefunc.edge_index.shape[1], self.data_edge_index.shape[1]))\n self.data_edge_index = self.data_edge_index[:, mask.T]\n self.odefunc.edge_weight = sampled_attention_weights #rewiring structure so need to replace any preproc ew's with new ew's\n self.odefunc.attention_weights = sampled_attention_weights" }, { "id": 7195, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, positions):\n def contract(x):\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)[..., None]\n return torch.where(mag < 1, x, (2 - (1 / mag)) * (x / mag))\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n\n def contract_gauss(x):\n return (2 - 1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n\n jc_means = vmap(jacrev(contract_gauss))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)", "probing input": " def forward(self, positions):\n def contract(x):\n", "probing input new": " def forward(self, positions):\n def contract(x):\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)[...,None]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=self.order,dim=-1)[...,None]", "y_neg": " mag = torch.norm(x, p=2, dim=1, keepdim=True)", "retain": " def forward(self, positions):\n def contract(x):\n mag = torch.linalg.norm(x, ord=self.order, dim=-1)[..., None]\n return torch.where(mag < 1, x, (2 - (1 / mag)) * (x / mag))\n\n if isinstance(positions, Gaussians):\n means = contract(positions.mean.clone())\n\n def contract_gauss(x):\n return (2 - 1 / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)) * (\n x / torch.linalg.norm(x, ord=self.order, dim=-1, keepdim=True)\n )\n\n jc_means = vmap(jacrev(contract_gauss))(positions.mean.view(-1, positions.mean.shape[-1]))\n jc_means = jc_means.view(list(positions.mean.shape) + [positions.mean.shape[-1]])\n\n # Only update covariances on positions outside the unit sphere\n mag = positions.mean.norm(dim=-1)\n mask = mag >= 1\n cov = positions.cov.clone()\n cov[mask] = jc_means[mask] @ positions.cov[mask] @ torch.transpose(jc_means[mask], -2, -1)\n\n return Gaussians(mean=means, cov=cov)\n\n return contract(positions)" }, { "id": 7196, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_normals_poly3D():\n vertices, faces = _create_simple_polygon()\n poly3D = TrimeshPolyhedron(R3('x'), vertices=vertices, faces=faces) \n points = poly3D.boundary.sample_grid(n=15)\n normals = poly3D.boundary.normal(points)\n assert normals.shape == (15,3)\n for i in range(15):\n assert torch.isclose(torch.linalg.norm(normals[i]), torch.tensor(1.0))", "probing input": "def test_normals_poly3D():\n vertices, faces = _create_simple_polygon()\n poly3D = TrimeshPolyhedron(R3('x'), vertices=vertices, faces=faces) \n points = poly3D.boundary.sample_grid(n=15)\n normals = poly3D.boundary.normal(points)\n assert normals.shape == (15,3)\n for i in range(15):\n", "probing input new": "def test_normals_poly3D():\n vertices, faces = _create_simple_polygon()\n poly3D = TrimeshPolyhedron(R3('x'), vertices=vertices, faces=faces) \n points = poly3D.boundary.sample_grid(n=15)\n normals = poly3D.boundary.normal(points)\n assert normals.shape == (15,3)\n for i in range(15):\n assert torch.isclose(torch.", "reference": "asserttorch.isclose(torch.linalg.norm(normals[i]),torch.tensor(1.0))", "reference dict": { "poly3D": "TrimeshPolyhedron" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "asserttorch.isclose(torch.linalg.norm(normals[i]),torch.tensor(1.0))", "y_neg": " assert torch.isclose(torch.norm(normals[i]), 1, atol=1e-5)", "retain": "def test_normals_poly3D():\n vertices, faces = _create_simple_polygon()\n poly3D = TrimeshPolyhedron(R3('x'), vertices=vertices, faces=faces) \n points = poly3D.boundary.sample_grid(n=15)\n normals = poly3D.boundary.normal(points)\n assert normals.shape == (15,3)\n for i in range(15):\n assert torch.isclose(torch.linalg.norm(normals[i]), torch.tensor(1.0))" }, { "id": 7197, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def update_symm_Rs(xyz, Lasu, symmsub, symmRs, fit=False, tscale=1.0):\n def dist_error_comp(R0,T0,xyz,tscale):\n B = xyz.shape[0]\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True)\n Tcorr = torch.einsum('ij,brj->bri', R0, xyz[:,:Lasu]-Tcom) + Tcom + tscale*T0[None,None,:]\n\n # distance map loss\n Xsymm = torch.einsum('sij,brj->bsri', symmRs[symmsub], Tcorr).reshape(B,-1,3)\n Xtrue = Ts\n\n delsx = Xsymm[:,:Lasu,None]-Xsymm[:, None, Lasu:]\n deltx = Xtrue[:,:Lasu,None]-Xtrue[:, None, Lasu:]\n dsymm = torch.linalg.norm(delsx, dim=-1)\n dtrue = torch.linalg.norm(deltx, dim=-1)\n loss1 = torch.abs(dsymm-dtrue).mean()\n\n return loss1,0.0 #loss2\n\n def dist_error(R0,T0,xyz,tscale,w_clash=0.0):\n l1,l2 = dist_error_comp(R0,T0,xyz,tscale)\n return l1+w_clash*l2\n\n def Q2R(Q):\n Qs = torch.cat((torch.ones((1),device=Q.device),Q),dim=-1)\n Qs = normQ(Qs)\n return Qs2Rs(Qs[None,:]).squeeze(0)\n \n\n B = xyz.shape[0]\n\n # symmetry correction 1: don't let COM (of entire complex) move\n #Tmean = xyz[:,:Lasu].reshape(-1,3).mean(dim=0)\n #Tmean = torch.einsum('sij,j->si', symmRs, Tmean).mean(dim=0)\n #xyz = xyz - Tmean\n\n if fit:\n # symmetry correction 2: use minimization to minimize drms\n with torch.enable_grad():\n T0 = torch.zeros(3,device=xyz.device).requires_grad_(True)\n Q0 = torch.zeros(3,device=xyz.device).requires_grad_(True)\n lbfgs = torch.optim.LBFGS([T0,Q0],\n history_size=10, \n max_iter=4,\n line_search_fn=\"strong_wolfe\")\n def closure():\n lbfgs.zero_grad()\n loss = dist_error(Q2R(Q0),T0,xyz[:,:,1], tscale)\n loss.backward() #retain_graph=True)\n return loss\n\n for e in range(4):\n loss = lbfgs.step(closure)\n\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True).detach()\n Q0 = Q0.detach()\n T0 = T0.detach()\n xyz = torch.einsum('ij,braj->brai', Q2R(Q0), xyz[:,:Lasu]-Tcom) +Tcom + tscale*T0[None,None,:]\n\n xyz = torch.einsum('sij,braj->bsrai', symmRs[symmsub], xyz[:,:Lasu])\n xyz = xyz.reshape(B,-1,3,3) # (B,S,L,3,3)\n\n return xyz", "probing input": "def update_symm_Rs(xyz, Lasu, symmsub, symmRs, fit=False, tscale=1.0):\n def dist_error_comp(R0,T0,xyz,tscale):\n B = xyz.shape[0]\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True)\n Tcorr = torch.einsum('ij,brj->bri', R0, xyz[:,:Lasu]-Tcom) + Tcom + tscale*T0[None,None,:]\n\n # distance map loss\n Xsymm = torch.einsum('sij,brj->bsri', symmRs[symmsub], Tcorr).reshape(B,-1,3)\n Xtrue = Ts\n\n delsx = Xsymm[:,:Lasu,None]-Xsymm[:, None, Lasu:]\n deltx = Xtrue[:,:Lasu,None]-Xtrue[:, None, Lasu:]\n", "probing input new": "def update_symm_Rs(xyz, Lasu, symmsub, symmRs, fit=False, tscale=1.0):\n def dist_error_comp(R0,T0,xyz,tscale):\n B = xyz.shape[0]\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True)\n Tcorr = torch.einsum('ij,brj->bri', R0, xyz[:,:Lasu]-Tcom) + Tcom + tscale*T0[None,None,:]\n\n # distance map loss\n Xsymm = torch.einsum('sij,brj->bsri', symmRs[symmsub], Tcorr).reshape(B,-1,3)\n Xtrue = Ts\n\n delsx = Xsymm[:,:Lasu,None]-Xsymm[:, None, Lasu:]\n deltx = Xtrue[:,:Lasu,None]-Xtrue[:, None, Lasu:]\n dsymm = torch.", "reference": "dsymm=torch.linalg.norm(delsx,dim=-1)", "reference dict": { "lbfgs": "torch.optim.LBFGS" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dsymm=torch.linalg.norm(delsx,dim=-1)", "y_neg": " dsymm = torch.norm(delsx, dim=-1)", "retain": "def update_symm_Rs(xyz, Lasu, symmsub, symmRs, fit=False, tscale=1.0):\n def dist_error_comp(R0,T0,xyz,tscale):\n B = xyz.shape[0]\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True)\n Tcorr = torch.einsum('ij,brj->bri', R0, xyz[:,:Lasu]-Tcom) + Tcom + tscale*T0[None,None,:]\n\n # distance map loss\n Xsymm = torch.einsum('sij,brj->bsri', symmRs[symmsub], Tcorr).reshape(B,-1,3)\n Xtrue = Ts\n\n delsx = Xsymm[:,:Lasu,None]-Xsymm[:, None, Lasu:]\n deltx = Xtrue[:,:Lasu,None]-Xtrue[:, None, Lasu:]\n dsymm = torch.linalg.norm(delsx, dim=-1)\n dtrue = torch.linalg.norm(deltx, dim=-1)\n loss1 = torch.abs(dsymm-dtrue).mean()\n\n return loss1,0.0 #loss2\n\n def dist_error(R0,T0,xyz,tscale,w_clash=0.0):\n l1,l2 = dist_error_comp(R0,T0,xyz,tscale)\n return l1+w_clash*l2\n\n def Q2R(Q):\n Qs = torch.cat((torch.ones((1),device=Q.device),Q),dim=-1)\n Qs = normQ(Qs)\n return Qs2Rs(Qs[None,:]).squeeze(0)\n \n\n B = xyz.shape[0]\n\n # symmetry correction 1: don't let COM (of entire complex) move\n #Tmean = xyz[:,:Lasu].reshape(-1,3).mean(dim=0)\n #Tmean = torch.einsum('sij,j->si', symmRs, Tmean).mean(dim=0)\n #xyz = xyz - Tmean\n\n if fit:\n # symmetry correction 2: use minimization to minimize drms\n with torch.enable_grad():\n T0 = torch.zeros(3,device=xyz.device).requires_grad_(True)\n Q0 = torch.zeros(3,device=xyz.device).requires_grad_(True)\n lbfgs = torch.optim.LBFGS([T0,Q0],\n history_size=10, \n max_iter=4,\n line_search_fn=\"strong_wolfe\")\n def closure():\n lbfgs.zero_grad()\n loss = dist_error(Q2R(Q0),T0,xyz[:,:,1], tscale)\n loss.backward() #retain_graph=True)\n return loss\n\n for e in range(4):\n loss = lbfgs.step(closure)\n\n Tcom = xyz[:,:Lasu].mean(dim=1,keepdim=True).detach()\n Q0 = Q0.detach()\n T0 = T0.detach()\n xyz = torch.einsum('ij,braj->brai', Q2R(Q0), xyz[:,:Lasu]-Tcom) +Tcom + tscale*T0[None,None,:]\n\n xyz = torch.einsum('sij,braj->bsrai', symmRs[symmsub], xyz[:,:Lasu])\n xyz = xyz.reshape(B,-1,3,3) # (B,S,L,3,3)\n\n return xyz" }, { "id": 7199, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_random_projections(dim, device, n_random_projections=256):\n projs = torch.randn((n_random_projections, dim), device=device)\n projs /= torch.linalg.norm(projs, dim=-1)[...,None]\n return projs", "probing input": "def compute_random_projections(dim, device, n_random_projections=256):\n projs = torch.randn((n_random_projections, dim), device=device)\n", "probing input new": "def compute_random_projections(dim, device, n_random_projections=256):\n projs = torch.randn((n_random_projections, dim), device=device)\n projs /= torch.", "reference": "projs/=torch.linalg.norm(projs,dim=-1)[...,None]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "projs/=torch.linalg.norm(projs,dim=-1)[...,None]", "y_neg": " projs /= torch.norm(projs, dim=1, keepdim=True)", "retain": "def compute_random_projections(dim, device, n_random_projections=256):\n projs = torch.randn((n_random_projections, dim), device=device)\n projs /= torch.linalg.norm(projs, dim=-1)[...,None]\n return projs" }, { "id": 7203, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def map_txt_to_clip_feature(clip_model, tokenizer, prompt):\n text_inputs = tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=tokenizer.model_max_length,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > tokenizer.model_max_length:\n removed_text = tokenizer.batch_decode(text_input_ids[:, tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : tokenizer.model_max_length]\n text_embeddings = clip_model.get_text_features(text_input_ids.to(clip_model.device))\n text_embeddings = text_embeddings / torch.linalg.norm(text_embeddings, dim=-1, keepdim=True)\n text_embeddings = text_embeddings[:, None, :]\n return text_embeddings[0][0].cpu().detach().numpy()", "probing input": "def map_txt_to_clip_feature(clip_model, tokenizer, prompt):\n text_inputs = tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=tokenizer.model_max_length,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > tokenizer.model_max_length:\n removed_text = tokenizer.batch_decode(text_input_ids[:, tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : tokenizer.model_max_length]\n text_embeddings = clip_model.get_text_features(text_input_ids.to(clip_model.device))\n", "probing input new": "def map_txt_to_clip_feature(clip_model, tokenizer, prompt):\n text_inputs = tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=tokenizer.model_max_length,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > tokenizer.model_max_length:\n removed_text = tokenizer.batch_decode(text_input_ids[:, tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : tokenizer.model_max_length]\n text_embeddings = clip_model.get_text_features(text_input_ids.to(clip_model.device))\n text_embeddings = text_embeddings / torch.", "reference": "text_embeddings=text_embeddings/torch.linalg.norm(text_embeddings,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "text_embeddings=text_embeddings/torch.linalg.norm(text_embeddings,dim=-1,keepdim=True)", "y_neg": " text_embeddings = text_embeddings / torch.norm(text_embeddings, dim=-1, keepdim=True)", "retain": "def map_txt_to_clip_feature(clip_model, tokenizer, prompt):\n text_inputs = tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=tokenizer.model_max_length,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n\n if text_input_ids.shape[-1] > tokenizer.model_max_length:\n removed_text = tokenizer.batch_decode(text_input_ids[:, tokenizer.model_max_length :])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {tokenizer.model_max_length} tokens: {removed_text}\"\n )\n text_input_ids = text_input_ids[:, : tokenizer.model_max_length]\n text_embeddings = clip_model.get_text_features(text_input_ids.to(clip_model.device))\n text_embeddings = text_embeddings / torch.linalg.norm(text_embeddings, dim=-1, keepdim=True)\n text_embeddings = text_embeddings[:, None, :]\n return text_embeddings[0][0].cpu().detach().numpy()" }, { "id": 7204, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def map_img_to_model_feature(model, feature_extractor, imgs, device):\n for i, image in enumerate(imgs):\n if not image.mode == \"RGB\":\n imgs[i] = image.convert(\"RGB\")\n imgs = normalize_images(imgs)\n retrieved_images = preprocess_images(imgs, feature_extractor).to(device)\n image_embeddings = model(retrieved_images)\n image_embeddings = image_embeddings / torch.linalg.norm(image_embeddings, dim=-1, keepdim=True)\n image_embeddings = image_embeddings[None, ...]\n return image_embeddings.cpu().detach().numpy()[0][0]", "probing input": "def map_img_to_model_feature(model, feature_extractor, imgs, device):\n for i, image in enumerate(imgs):\n if not image.mode == \"RGB\":\n imgs[i] = image.convert(\"RGB\")\n imgs = normalize_images(imgs)\n retrieved_images = preprocess_images(imgs, feature_extractor).to(device)\n image_embeddings = model(retrieved_images)\n", "probing input new": "def map_img_to_model_feature(model, feature_extractor, imgs, device):\n for i, image in enumerate(imgs):\n if not image.mode == \"RGB\":\n imgs[i] = image.convert(\"RGB\")\n imgs = normalize_images(imgs)\n retrieved_images = preprocess_images(imgs, feature_extractor).to(device)\n image_embeddings = model(retrieved_images)\n image_embeddings = image_embeddings / torch.", "reference": "image_embeddings=image_embeddings/torch.linalg.norm(image_embeddings,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "image_embeddings=image_embeddings/torch.linalg.norm(image_embeddings,dim=-1,keepdim=True)", "y_neg": " image_embeddings = image_embeddings / torch.norm(image_embeddings, dim=1, keepdim=True)", "retain": "def map_img_to_model_feature(model, feature_extractor, imgs, device):\n for i, image in enumerate(imgs):\n if not image.mode == \"RGB\":\n imgs[i] = image.convert(\"RGB\")\n imgs = normalize_images(imgs)\n retrieved_images = preprocess_images(imgs, feature_extractor).to(device)\n image_embeddings = model(retrieved_images)\n image_embeddings = image_embeddings / torch.linalg.norm(image_embeddings, dim=-1, keepdim=True)\n image_embeddings = image_embeddings[None, ...]\n return image_embeddings.cpu().detach().numpy()[0][0]" }, { "id": 7211, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def pose_error_torch(R, t, Tgt, reduce=None):\n \"\"\"Compute angular, scale and euclidean error of translation vector (metric). Compute angular rotation error.\"\"\"\n\n Rgt = Tgt[:, :3, :3] # [B, 3, 3]\n tgt = Tgt[:, :3, 3:].transpose(1, 2) # [B, 1, 3]\n\n scale_t = torch.linalg.norm(t, dim=-1)\n scale_tgt = torch.linalg.norm(tgt, dim=-1)\n\n cosine = (t @ tgt.transpose(1, 2)).squeeze(-1) / (scale_t * scale_tgt + 1e-9)\n cosine = torch.clip(cosine, -1.0, 1.0) # handle numerical errors\n t_ang_err = torch.rad2deg(torch.acos(cosine))\n t_ang_err = torch.minimum(t_ang_err, 180 - t_ang_err)\n\n t_scale_err = scale_t / scale_tgt\n t_scale_err_sym = torch.maximum(scale_t / scale_tgt, scale_tgt / scale_t)\n t_euclidean_err = torch.linalg.norm(t - tgt, dim=-1)\n\n residual = R.transpose(1, 2) @ Rgt\n trace = torch.diagonal(residual, dim1=-2, dim2=-1).sum(-1)\n cosine = (trace - 1) / 2\n cosine = torch.clip(cosine, -1., 1.) # handle numerical errors\n R_err = torch.rad2deg(torch.acos(cosine))\n\n if reduce is None:\n def fn(x): return x\n elif reduce == 'mean':\n fn = torch.mean\n elif reduce == 'median':\n fn = torch.median\n\n t_ang_err = fn(t_ang_err)\n t_scale_err = fn(t_scale_err)\n t_euclidean_err = fn(t_euclidean_err)\n R_err = fn(R_err)\n\n errors = {'t_err_ang': t_ang_err,\n 't_err_scale': t_scale_err,\n 't_err_scale_sym': t_scale_err_sym,\n 't_err_euc': t_euclidean_err,\n 'R_err': R_err}\n return errors", "probing input": "def pose_error_torch(R, t, Tgt, reduce=None):\n \"\"\"Compute angular, scale and euclidean error of translation vector (metric). Compute angular rotation error.\"\"\"\n\n Rgt = Tgt[:, :3, :3] # [B, 3, 3]\n tgt = Tgt[:, :3, 3:].transpose(1, 2) # [B, 1, 3]\n\n", "probing input new": "def pose_error_torch(R, t, Tgt, reduce=None):\n \"\"\"Compute angular, scale and euclidean error of translation vector (metric). Compute angular rotation error.\"\"\"\n\n Rgt = Tgt[:, :3, :3] # [B, 3, 3]\n tgt = Tgt[:, :3, 3:].transpose(1, 2) # [B, 1, 3]\n\n scale_t = torch.", "reference": "scale_t=torch.linalg.norm(t,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "scale_t=torch.linalg.norm(t,dim=-1)", "y_neg": " scale_t = torch.norm(tgt, p=2, dim=2) # [B, 1]", "retain": "def pose_error_torch(R, t, Tgt, reduce=None):\n \"\"\"Compute angular, scale and euclidean error of translation vector (metric). Compute angular rotation error.\"\"\"\n\n Rgt = Tgt[:, :3, :3] # [B, 3, 3]\n tgt = Tgt[:, :3, 3:].transpose(1, 2) # [B, 1, 3]\n\n scale_t = torch.linalg.norm(t, dim=-1)\n scale_tgt = torch.linalg.norm(tgt, dim=-1)\n\n cosine = (t @ tgt.transpose(1, 2)).squeeze(-1) / (scale_t * scale_tgt + 1e-9)\n cosine = torch.clip(cosine, -1.0, 1.0) # handle numerical errors\n t_ang_err = torch.rad2deg(torch.acos(cosine))\n t_ang_err = torch.minimum(t_ang_err, 180 - t_ang_err)\n\n t_scale_err = scale_t / scale_tgt\n t_scale_err_sym = torch.maximum(scale_t / scale_tgt, scale_tgt / scale_t)\n t_euclidean_err = torch.linalg.norm(t - tgt, dim=-1)\n\n residual = R.transpose(1, 2) @ Rgt\n trace = torch.diagonal(residual, dim1=-2, dim2=-1).sum(-1)\n cosine = (trace - 1) / 2\n cosine = torch.clip(cosine, -1., 1.) # handle numerical errors\n R_err = torch.rad2deg(torch.acos(cosine))\n\n if reduce is None:\n def fn(x): return x\n elif reduce == 'mean':\n fn = torch.mean\n elif reduce == 'median':\n fn = torch.median\n\n t_ang_err = fn(t_ang_err)\n t_scale_err = fn(t_scale_err)\n t_euclidean_err = fn(t_euclidean_err)\n R_err = fn(R_err)\n\n errors = {'t_err_ang': t_ang_err,\n 't_err_scale': t_scale_err,\n 't_err_scale_sym': t_scale_err_sym,\n 't_err_euc': t_euclidean_err,\n 'R_err': R_err}\n return errors" }, { "id": 7212, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(x) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)", "probing input": "def normalize(x) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n", "probing input new": "def normalize(x) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.", "reference": "returnx/torch.linalg.norm(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnx/torch.linalg.norm(x)", "y_neg": " return x / torch.norm(x, p=2, dim=-1, keepdim=True)", "retain": "def normalize(x) -> TensorType[...]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)" }, { "id": 7213, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def robustify_photo(r, dIt_dT, invalid_mask, photo_sigma):\n info_sqrt = 1.0 / photo_sigma\n whitened_r = r * info_sqrt\n weight = robust.huber(whitened_r)\n weight[invalid_mask[...], :] = 0.0\n\n total_err = torch.sum(weight * torch.square(whitened_r))\n num_valid = invalid_mask.shape[-1] - torch.count_nonzero(invalid_mask, dim=-1)\n mean_sq_err = total_err / num_valid\n\n J_W = weight[:, :, :, None] * dIt_dT\n grad = torch.sum(J_W * r[..., None], dim=(1, 2))\n H = torch.einsum(\"bnck,bncl->bkl\", J_W, dIt_dT)\n\n grad_norm = torch.linalg.norm(grad)\n\n return H, grad, total_err, mean_sq_err, grad_norm", "probing input": "def robustify_photo(r, dIt_dT, invalid_mask, photo_sigma):\n info_sqrt = 1.0 / photo_sigma\n whitened_r = r * info_sqrt\n weight = robust.huber(whitened_r)\n weight[invalid_mask[...], :] = 0.0\n\n total_err = torch.sum(weight * torch.square(whitened_r))\n num_valid = invalid_mask.shape[-1] - torch.count_nonzero(invalid_mask, dim=-1)\n mean_sq_err = total_err / num_valid\n\n J_W = weight[:, :, :, None] * dIt_dT\n grad = torch.sum(J_W * r[..., None], dim=(1, 2))\n H = torch.einsum(\"bnck,bncl->bkl\", J_W, dIt_dT)\n\n", "probing input new": "def robustify_photo(r, dIt_dT, invalid_mask, photo_sigma):\n info_sqrt = 1.0 / photo_sigma\n whitened_r = r * info_sqrt\n weight = robust.huber(whitened_r)\n weight[invalid_mask[...], :] = 0.0\n\n total_err = torch.sum(weight * torch.square(whitened_r))\n num_valid = invalid_mask.shape[-1] - torch.count_nonzero(invalid_mask, dim=-1)\n mean_sq_err = total_err / num_valid\n\n J_W = weight[:, :, :, None] * dIt_dT\n grad = torch.sum(J_W * r[..., None], dim=(1, 2))\n H = torch.einsum(\"bnck,bncl->bkl\", J_W, dIt_dT)\n\n grad_", "reference": "grad_norm=torch.linalg.norm(grad)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "grad_norm=torch.linalg.norm(grad)", "y_neg": " grad_norm = torch.norm(grad, p=2, dim=(1, 2), keepdim=True)", "retain": "def robustify_photo(r, dIt_dT, invalid_mask, photo_sigma):\n info_sqrt = 1.0 / photo_sigma\n whitened_r = r * info_sqrt\n weight = robust.huber(whitened_r)\n weight[invalid_mask[...], :] = 0.0\n\n total_err = torch.sum(weight * torch.square(whitened_r))\n num_valid = invalid_mask.shape[-1] - torch.count_nonzero(invalid_mask, dim=-1)\n mean_sq_err = total_err / num_valid\n\n J_W = weight[:, :, :, None] * dIt_dT\n grad = torch.sum(J_W * r[..., None], dim=(1, 2))\n H = torch.einsum(\"bnck,bncl->bkl\", J_W, dIt_dT)\n\n grad_norm = torch.linalg.norm(grad)\n\n return H, grad, total_err, mean_sq_err, grad_norm" }, { "id": 7214, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def plan_map_bound_loss(pred, target, dis_thresh=1.0):\n \"\"\"Planning map bound constraint (L1 distance).\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_bound_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n ego_traj_starts = pred[:, :-1, :]\n ego_traj_ends = pred\n B, T, _ = ego_traj_ends.size()\n padding_zeros = torch.zeros((B, 1, 2), dtype=pred.dtype, device=pred.device) # initial position\n ego_traj_starts = torch.cat((padding_zeros, ego_traj_starts), dim=1)\n _, V, P, _ = target.size()\n ego_traj_expanded = ego_traj_ends.unsqueeze(2).unsqueeze(3) # [B, T, 1, 1, 2]\n maps_expanded = target.unsqueeze(1) # [1, 1, M, P, 2]\n dist = torch.linalg.norm(ego_traj_expanded - maps_expanded, dim=-1) # [B, T, M, P]\n dist = dist.min(dim=-1, keepdim=False)[0]\n min_inst_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n bd_target = target.unsqueeze(1).repeat(1, pred.shape[1], 1, 1, 1)\n min_bd_insts = bd_target[batch_idxs, ts_idxs, min_inst_idxs] # [B, T, P, 2]\n bd_inst_starts = min_bd_insts[:, :, :-1, :].flatten(0, 2)\n bd_inst_ends = min_bd_insts[:, :, 1:, :].flatten(0, 2)\n ego_traj_starts = ego_traj_starts.unsqueeze(2).repeat(1, 1, P-1, 1).flatten(0, 2)\n ego_traj_ends = ego_traj_ends.unsqueeze(2).repeat(1, 1, P-1, 1).flatten(0, 2)\n\n intersect_mask = segments_intersect(ego_traj_starts, ego_traj_ends,\n bd_inst_starts, bd_inst_ends)\n intersect_mask = intersect_mask.reshape(B, T, P-1)\n intersect_mask = intersect_mask.any(dim=-1)\n intersect_idx = (intersect_mask == True).nonzero()\n\n target = target.view(target.shape[0], -1, target.shape[-1])\n # [B, fut_ts, num_vec*num_pts]\n dist = torch.linalg.norm(pred[:, :, None, :] - target[:, None, :, :], dim=-1)\n min_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n min_dist = dist[batch_idxs, ts_idxs, min_idxs]\n loss = min_dist\n safe_idx = loss > dis_thresh\n unsafe_idx = loss <= dis_thresh\n loss[safe_idx] = 0\n loss[unsafe_idx] = dis_thresh - loss[unsafe_idx]\n\n for i in range(len(intersect_idx)):\n loss[intersect_idx[i, 0], intersect_idx[i, 1]:] = 0\n\n return loss", "probing input": "def plan_map_bound_loss(pred, target, dis_thresh=1.0):\n \"\"\"Planning map bound constraint (L1 distance).\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_bound_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n ego_traj_starts = pred[:, :-1, :]\n ego_traj_ends = pred\n B, T, _ = ego_traj_ends.size()\n padding_zeros = torch.zeros((B, 1, 2), dtype=pred.dtype, device=pred.device) # initial position\n ego_traj_starts = torch.cat((padding_zeros, ego_traj_starts), dim=1)\n _, V, P, _ = target.size()\n ego_traj_expanded = ego_traj_ends.unsqueeze(2).unsqueeze(3) # [B, T, 1, 1, 2]\n maps_expanded = target.unsqueeze(1) # [1, 1, M, P, 2]\n", "probing input new": "def plan_map_bound_loss(pred, target, dis_thresh=1.0):\n \"\"\"Planning map bound constraint (L1 distance).\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_bound_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n ego_traj_starts = pred[:, :-1, :]\n ego_traj_ends = pred\n B, T, _ = ego_traj_ends.size()\n padding_zeros = torch.zeros((B, 1, 2), dtype=pred.dtype, device=pred.device) # initial position\n ego_traj_starts = torch.cat((padding_zeros, ego_traj_starts), dim=1)\n _, V, P, _ = target.size()\n ego_traj_expanded = ego_traj_ends.unsqueeze(2).unsqueeze(3) # [B, T, 1, 1, 2]\n maps_expanded = target.unsqueeze(1) # [1, 1, M, P, 2]\n dist = torch.", "reference": "dist=torch.linalg.norm(ego_traj_expanded-maps_expanded,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(ego_traj_expanded-maps_expanded,dim=-1)", "y_neg": " dist = torch.norm(ego_traj_expanded - maps_expanded, p=2, dim=-1) # [B, T, M, P]", "retain": "def plan_map_bound_loss(pred, target, dis_thresh=1.0):\n \"\"\"Planning map bound constraint (L1 distance).\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_bound_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n ego_traj_starts = pred[:, :-1, :]\n ego_traj_ends = pred\n B, T, _ = ego_traj_ends.size()\n padding_zeros = torch.zeros((B, 1, 2), dtype=pred.dtype, device=pred.device) # initial position\n ego_traj_starts = torch.cat((padding_zeros, ego_traj_starts), dim=1)\n _, V, P, _ = target.size()\n ego_traj_expanded = ego_traj_ends.unsqueeze(2).unsqueeze(3) # [B, T, 1, 1, 2]\n maps_expanded = target.unsqueeze(1) # [1, 1, M, P, 2]\n dist = torch.linalg.norm(ego_traj_expanded - maps_expanded, dim=-1) # [B, T, M, P]\n dist = dist.min(dim=-1, keepdim=False)[0]\n min_inst_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n bd_target = target.unsqueeze(1).repeat(1, pred.shape[1], 1, 1, 1)\n min_bd_insts = bd_target[batch_idxs, ts_idxs, min_inst_idxs] # [B, T, P, 2]\n bd_inst_starts = min_bd_insts[:, :, :-1, :].flatten(0, 2)\n bd_inst_ends = min_bd_insts[:, :, 1:, :].flatten(0, 2)\n ego_traj_starts = ego_traj_starts.unsqueeze(2).repeat(1, 1, P-1, 1).flatten(0, 2)\n ego_traj_ends = ego_traj_ends.unsqueeze(2).repeat(1, 1, P-1, 1).flatten(0, 2)\n\n intersect_mask = segments_intersect(ego_traj_starts, ego_traj_ends,\n bd_inst_starts, bd_inst_ends)\n intersect_mask = intersect_mask.reshape(B, T, P-1)\n intersect_mask = intersect_mask.any(dim=-1)\n intersect_idx = (intersect_mask == True).nonzero()\n\n target = target.view(target.shape[0], -1, target.shape[-1])\n # [B, fut_ts, num_vec*num_pts]\n dist = torch.linalg.norm(pred[:, :, None, :] - target[:, None, :, :], dim=-1)\n min_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n min_dist = dist[batch_idxs, ts_idxs, min_idxs]\n loss = min_dist\n safe_idx = loss > dis_thresh\n unsafe_idx = loss <= dis_thresh\n loss[safe_idx] = 0\n loss[unsafe_idx] = dis_thresh - loss[unsafe_idx]\n\n for i in range(len(intersect_idx)):\n loss[intersect_idx[i, 0], intersect_idx[i, 1]:] = 0\n\n return loss" }, { "id": 7215, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def plan_col_loss(\n pred,\n target,\n agent_fut_preds,\n x_dis_thresh=1.5,\n y_dis_thresh=3.0,\n dis_thresh=3.0\n):\n \"\"\"Planning ego-agent collsion constraint.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): agent_preds, [B, num_agent, 2].\n agent_fut_preds (Tensor): [B, num_agent, fut_ts, 2].\n weight (torch.Tensor): [B, fut_ts, 2].\n x_dis_thresh (float, optional): distance threshold between ego and other agents in x-axis.\n y_dis_thresh (float, optional): distance threshold between ego and other agents in y-axis.\n dis_thresh (float, optional): distance threshold to filter distant agents.\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_mode, fut_ts, 2]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n agent_fut_preds = agent_fut_preds.cumsum(dim=-2)\n target = target[:, :, None, :] + agent_fut_preds\n # filter distant agents from ego vehicle\n dist = torch.linalg.norm(pred[:, None, :, :] - target, dim=-1)\n dist_mask = dist > dis_thresh\n target[dist_mask] = 1e6\n\n # [B, num_agent, fut_ts]\n x_dist = torch.abs(pred[:, None, :, 0] - target[..., 0])\n y_dist = torch.abs(pred[:, None, :, 1] - target[..., 1])\n x_min_idxs = torch.argmin(x_dist, dim=1).tolist()\n y_min_idxs = torch.argmin(y_dist, dim=1).tolist()\n batch_idxs = [[i] for i in range(y_dist.shape[0])]\n ts_idxs = [[i for i in range(y_dist.shape[-1])] for j in range(y_dist.shape[0])]\n\n # [B, fut_ts]\n x_min_dist = x_dist[batch_idxs, x_min_idxs, ts_idxs]\n y_min_dist = y_dist[batch_idxs, y_min_idxs, ts_idxs]\n x_loss = x_min_dist\n safe_idx = x_loss > x_dis_thresh\n unsafe_idx = x_loss <= x_dis_thresh\n x_loss[safe_idx] = 0\n x_loss[unsafe_idx] = x_dis_thresh - x_loss[unsafe_idx]\n y_loss = y_min_dist\n safe_idx = y_loss > y_dis_thresh\n unsafe_idx = y_loss <= y_dis_thresh\n y_loss[safe_idx] = 0\n y_loss[unsafe_idx] = y_dis_thresh - y_loss[unsafe_idx]\n loss = torch.cat([x_loss.unsqueeze(-1), y_loss.unsqueeze(-1)], dim=-1)\n\n return loss", "probing input": "def plan_col_loss(\n pred,\n target,\n agent_fut_preds,\n x_dis_thresh=1.5,\n y_dis_thresh=3.0,\n dis_thresh=3.0\n):\n \"\"\"Planning ego-agent collsion constraint.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): agent_preds, [B, num_agent, 2].\n agent_fut_preds (Tensor): [B, num_agent, fut_ts, 2].\n weight (torch.Tensor): [B, fut_ts, 2].\n x_dis_thresh (float, optional): distance threshold between ego and other agents in x-axis.\n y_dis_thresh (float, optional): distance threshold between ego and other agents in y-axis.\n dis_thresh (float, optional): distance threshold to filter distant agents.\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_mode, fut_ts, 2]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n agent_fut_preds = agent_fut_preds.cumsum(dim=-2)\n target = target[:, :, None, :] + agent_fut_preds\n # filter distant agents from ego vehicle\n", "probing input new": "def plan_col_loss(\n pred,\n target,\n agent_fut_preds,\n x_dis_thresh=1.5,\n y_dis_thresh=3.0,\n dis_thresh=3.0\n):\n \"\"\"Planning ego-agent collsion constraint.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): agent_preds, [B, num_agent, 2].\n agent_fut_preds (Tensor): [B, num_agent, fut_ts, 2].\n weight (torch.Tensor): [B, fut_ts, 2].\n x_dis_thresh (float, optional): distance threshold between ego and other agents in x-axis.\n y_dis_thresh (float, optional): distance threshold between ego and other agents in y-axis.\n dis_thresh (float, optional): distance threshold to filter distant agents.\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_mode, fut_ts, 2]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n agent_fut_preds = agent_fut_preds.cumsum(dim=-2)\n target = target[:, :, None, :] + agent_fut_preds\n # filter distant agents from ego vehicle\n dist = torch.", "reference": "dist=torch.linalg.norm(pred[:,None,:,:]-target,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(pred[:,None,:,:]-target,dim=-1)", "y_neg": " dist = torch.norm(pred[:, :, None, :] - target, dim=-1)", "retain": "def plan_col_loss(\n pred,\n target,\n agent_fut_preds,\n x_dis_thresh=1.5,\n y_dis_thresh=3.0,\n dis_thresh=3.0\n):\n \"\"\"Planning ego-agent collsion constraint.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): agent_preds, [B, num_agent, 2].\n agent_fut_preds (Tensor): [B, num_agent, fut_ts, 2].\n weight (torch.Tensor): [B, fut_ts, 2].\n x_dis_thresh (float, optional): distance threshold between ego and other agents in x-axis.\n y_dis_thresh (float, optional): distance threshold between ego and other agents in y-axis.\n dis_thresh (float, optional): distance threshold to filter distant agents.\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_mode, fut_ts, 2]\n \"\"\"\n pred = pred.cumsum(dim=-2)\n agent_fut_preds = agent_fut_preds.cumsum(dim=-2)\n target = target[:, :, None, :] + agent_fut_preds\n # filter distant agents from ego vehicle\n dist = torch.linalg.norm(pred[:, None, :, :] - target, dim=-1)\n dist_mask = dist > dis_thresh\n target[dist_mask] = 1e6\n\n # [B, num_agent, fut_ts]\n x_dist = torch.abs(pred[:, None, :, 0] - target[..., 0])\n y_dist = torch.abs(pred[:, None, :, 1] - target[..., 1])\n x_min_idxs = torch.argmin(x_dist, dim=1).tolist()\n y_min_idxs = torch.argmin(y_dist, dim=1).tolist()\n batch_idxs = [[i] for i in range(y_dist.shape[0])]\n ts_idxs = [[i for i in range(y_dist.shape[-1])] for j in range(y_dist.shape[0])]\n\n # [B, fut_ts]\n x_min_dist = x_dist[batch_idxs, x_min_idxs, ts_idxs]\n y_min_dist = y_dist[batch_idxs, y_min_idxs, ts_idxs]\n x_loss = x_min_dist\n safe_idx = x_loss > x_dis_thresh\n unsafe_idx = x_loss <= x_dis_thresh\n x_loss[safe_idx] = 0\n x_loss[unsafe_idx] = x_dis_thresh - x_loss[unsafe_idx]\n y_loss = y_min_dist\n safe_idx = y_loss > y_dis_thresh\n unsafe_idx = y_loss <= y_dis_thresh\n y_loss[safe_idx] = 0\n y_loss[unsafe_idx] = y_dis_thresh - y_loss[unsafe_idx]\n loss = torch.cat([x_loss.unsqueeze(-1), y_loss.unsqueeze(-1)], dim=-1)\n\n return loss" }, { "id": 7216, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def plan_map_dir_loss(pred, target, dis_thresh=2.0):\n \"\"\"Planning ego-map directional loss.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_div_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n num_map_pts = target.shape[2]\n pred = pred.cumsum(dim=-2)\n traj_dis = torch.linalg.norm(pred[:, -1, :] - pred[:, 0, :], dim=-1)\n static_mask = traj_dis < 1.0\n target = target.unsqueeze(1).repeat(1, pred.shape[1], 1, 1, 1)\n\n # find the closest map instance for ego at each timestamp\n dist = torch.linalg.norm(pred[:, :, None, None, :] - target, dim=-1)\n dist = dist.min(dim=-1, keepdim=False)[0]\n min_inst_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n target_map_inst = target[batch_idxs, ts_idxs, min_inst_idxs] # [B, fut_ts, num_pts, 2]\n\n # calculate distance\n dist = torch.linalg.norm(pred[:, :, None, :] - target_map_inst, dim=-1)\n min_pts_idxs = torch.argmin(dist, dim=-1)\n min_pts_next_idxs = min_pts_idxs.clone()\n is_end_point = (min_pts_next_idxs == num_map_pts-1)\n not_end_point = (min_pts_next_idxs != num_map_pts-1)\n min_pts_next_idxs[is_end_point] = num_map_pts - 2\n min_pts_next_idxs[not_end_point] = min_pts_next_idxs[not_end_point] + 1\n min_pts_idxs = min_pts_idxs.tolist()\n min_pts_next_idxs = min_pts_next_idxs.tolist()\n traj_yaw = torch.atan2(torch.diff(pred[..., 1]), torch.diff(pred[..., 0])) # [B, fut_ts-1]\n # last ts yaw assume same as previous\n traj_yaw = torch.cat([traj_yaw, traj_yaw[:, [-1]]], dim=-1) # [B, fut_ts]\n min_pts = target_map_inst[batch_idxs, ts_idxs, min_pts_idxs]\n dist = torch.linalg.norm(min_pts - pred, dim=-1)\n dist_mask = dist > dis_thresh\n min_pts = min_pts.unsqueeze(2)\n min_pts_next = target_map_inst[batch_idxs, ts_idxs, min_pts_next_idxs].unsqueeze(2)\n map_pts = torch.cat([min_pts, min_pts_next], dim=2)\n lane_yaw = torch.atan2(torch.diff(map_pts[..., 1]).squeeze(-1), torch.diff(map_pts[..., 0]).squeeze(-1)) # [B, fut_ts]\n yaw_diff = traj_yaw - lane_yaw\n yaw_diff[yaw_diff > math.pi] = yaw_diff[yaw_diff > math.pi] - math.pi\n yaw_diff[yaw_diff > math.pi/2] = yaw_diff[yaw_diff > math.pi/2] - math.pi\n yaw_diff[yaw_diff < -math.pi] = yaw_diff[yaw_diff < -math.pi] + math.pi\n yaw_diff[yaw_diff < -math.pi/2] = yaw_diff[yaw_diff < -math.pi/2] + math.pi\n yaw_diff[dist_mask] = 0 # loss = 0 if no lane around ego\n yaw_diff[static_mask] = 0 # loss = 0 if ego is static\n\n loss = torch.abs(yaw_diff)\n\n return loss", "probing input": "def plan_map_dir_loss(pred, target, dis_thresh=2.0):\n \"\"\"Planning ego-map directional loss.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_div_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n num_map_pts = target.shape[2]\n pred = pred.cumsum(dim=-2)\n", "probing input new": "def plan_map_dir_loss(pred, target, dis_thresh=2.0):\n \"\"\"Planning ego-map directional loss.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_div_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n num_map_pts = target.shape[2]\n pred = pred.cumsum(dim=-2)\n traj_dis = torch.", "reference": "traj_dis=torch.linalg.norm(pred[:,-1,:]-pred[:,0,:],dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "traj_dis=torch.linalg.norm(pred[:,-1,:]-pred[:,0,:],dim=-1)", "y_neg": " traj_dis = torch.norm(pred[:, :, 1:] - pred[:, :, :-1], dim=-1)", "retain": "def plan_map_dir_loss(pred, target, dis_thresh=2.0):\n \"\"\"Planning ego-map directional loss.\n\n Args:\n pred (torch.Tensor): ego_fut_preds, [B, fut_ts, 2].\n target (torch.Tensor): lane_div_preds, [B, num_vec, num_pts, 2].\n weight (torch.Tensor): [B, fut_ts]\n\n Returns:\n torch.Tensor: Calculated loss [B, fut_ts]\n \"\"\"\n num_map_pts = target.shape[2]\n pred = pred.cumsum(dim=-2)\n traj_dis = torch.linalg.norm(pred[:, -1, :] - pred[:, 0, :], dim=-1)\n static_mask = traj_dis < 1.0\n target = target.unsqueeze(1).repeat(1, pred.shape[1], 1, 1, 1)\n\n # find the closest map instance for ego at each timestamp\n dist = torch.linalg.norm(pred[:, :, None, None, :] - target, dim=-1)\n dist = dist.min(dim=-1, keepdim=False)[0]\n min_inst_idxs = torch.argmin(dist, dim=-1).tolist()\n batch_idxs = [[i] for i in range(dist.shape[0])]\n ts_idxs = [[i for i in range(dist.shape[1])] for j in range(dist.shape[0])]\n target_map_inst = target[batch_idxs, ts_idxs, min_inst_idxs] # [B, fut_ts, num_pts, 2]\n\n # calculate distance\n dist = torch.linalg.norm(pred[:, :, None, :] - target_map_inst, dim=-1)\n min_pts_idxs = torch.argmin(dist, dim=-1)\n min_pts_next_idxs = min_pts_idxs.clone()\n is_end_point = (min_pts_next_idxs == num_map_pts-1)\n not_end_point = (min_pts_next_idxs != num_map_pts-1)\n min_pts_next_idxs[is_end_point] = num_map_pts - 2\n min_pts_next_idxs[not_end_point] = min_pts_next_idxs[not_end_point] + 1\n min_pts_idxs = min_pts_idxs.tolist()\n min_pts_next_idxs = min_pts_next_idxs.tolist()\n traj_yaw = torch.atan2(torch.diff(pred[..., 1]), torch.diff(pred[..., 0])) # [B, fut_ts-1]\n # last ts yaw assume same as previous\n traj_yaw = torch.cat([traj_yaw, traj_yaw[:, [-1]]], dim=-1) # [B, fut_ts]\n min_pts = target_map_inst[batch_idxs, ts_idxs, min_pts_idxs]\n dist = torch.linalg.norm(min_pts - pred, dim=-1)\n dist_mask = dist > dis_thresh\n min_pts = min_pts.unsqueeze(2)\n min_pts_next = target_map_inst[batch_idxs, ts_idxs, min_pts_next_idxs].unsqueeze(2)\n map_pts = torch.cat([min_pts, min_pts_next], dim=2)\n lane_yaw = torch.atan2(torch.diff(map_pts[..., 1]).squeeze(-1), torch.diff(map_pts[..., 0]).squeeze(-1)) # [B, fut_ts]\n yaw_diff = traj_yaw - lane_yaw\n yaw_diff[yaw_diff > math.pi] = yaw_diff[yaw_diff > math.pi] - math.pi\n yaw_diff[yaw_diff > math.pi/2] = yaw_diff[yaw_diff > math.pi/2] - math.pi\n yaw_diff[yaw_diff < -math.pi] = yaw_diff[yaw_diff < -math.pi] + math.pi\n yaw_diff[yaw_diff < -math.pi/2] = yaw_diff[yaw_diff < -math.pi/2] + math.pi\n yaw_diff[dist_mask] = 0 # loss = 0 if no lane around ego\n yaw_diff[static_mask] = 0 # loss = 0 if ego is static\n\n loss = torch.abs(yaw_diff)\n\n return loss" }, { "id": 7217, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def norm(self, arr: array_like) -> float:\n return float(torch.linalg.norm(torch.view_as_real(arr)))", "probing input": " def norm(self, arr: array_like) -> float:\n", "probing input new": " def norm(self, arr: array_like) -> float:\n return float(torch.", "reference": "returnfloat(torch.linalg.norm(torch.view_as_real(arr)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnfloat(torch.linalg.norm(torch.view_as_real(arr)))", "y_neg": " return float(torch.norm(torch.Tensor(arr)))", "retain": " def norm(self, arr: array_like) -> float:\n return float(torch.linalg.norm(torch.view_as_real(arr)))" }, { "id": 7218, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _compute_v_times_Wo_norm(\n attn_value: torch.Tensor, # thd\n W_O: torch.Tensor, # hdo\n) -> torch.Tensor:\n \"\"\"\n This function computes the norm of the product of attention values and the output weight matrix\n (W_O in the transformer-circuits convention, or c_proj in many internal settings).\n The attention values are represented by the tensor attn_value and the output weight matrix by W_O.\n The function returns a tensor representing the norm of the product.\n \"\"\"\n\n num_attended_to_sequence_tokens, nheads, d_head = attn_value.shape\n assert W_O.shape[:2] == (nheads, d_head) # third dim is d_model\n v_times_Wo = torch.einsum(\"thd,hdo->tho\", attn_value, W_O)\n return torch.linalg.norm(v_times_Wo, dim=-1)", "probing input": "def _compute_v_times_Wo_norm(\n attn_value: torch.Tensor, # thd\n W_O: torch.Tensor, # hdo\n) -> torch.Tensor:\n \"\"\"\n This function computes the norm of the product of attention values and the output weight matrix\n (W_O in the transformer-circuits convention, or c_proj in many internal settings).\n The attention values are represented by the tensor attn_value and the output weight matrix by W_O.\n The function returns a tensor representing the norm of the product.\n \"\"\"\n\n num_attended_to_sequence_tokens, nheads, d_head = attn_value.shape\n assert W_O.shape[:2] == (nheads, d_head) # third dim is d_model\n v_times_Wo = torch.einsum(\"thd,hdo->tho\", attn_value, W_O)\n", "probing input new": "def _compute_v_times_Wo_norm(\n attn_value: torch.Tensor, # thd\n W_O: torch.Tensor, # hdo\n) -> torch.Tensor:\n \"\"\"\n This function computes the norm of the product of attention values and the output weight matrix\n (W_O in the transformer-circuits convention, or c_proj in many internal settings).\n The attention values are represented by the tensor attn_value and the output weight matrix by W_O.\n The function returns a tensor representing the norm of the product.\n \"\"\"\n\n num_attended_to_sequence_tokens, nheads, d_head = attn_value.shape\n assert W_O.shape[:2] == (nheads, d_head) # third dim is d_model\n v_times_Wo = torch.einsum(\"thd,hdo->tho\", attn_value, W_O)\n return torch.", "reference": "returntorch.linalg.norm(v_times_Wo,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(v_times_Wo,dim=-1)", "y_neg": " return torch.norm(v_times_Wo, p=2, dim=-1)", "retain": "def _compute_v_times_Wo_norm(\n attn_value: torch.Tensor, # thd\n W_O: torch.Tensor, # hdo\n) -> torch.Tensor:\n \"\"\"\n This function computes the norm of the product of attention values and the output weight matrix\n (W_O in the transformer-circuits convention, or c_proj in many internal settings).\n The attention values are represented by the tensor attn_value and the output weight matrix by W_O.\n The function returns a tensor representing the norm of the product.\n \"\"\"\n\n num_attended_to_sequence_tokens, nheads, d_head = attn_value.shape\n assert W_O.shape[:2] == (nheads, d_head) # third dim is d_model\n v_times_Wo = torch.einsum(\"thd,hdo->tho\", attn_value, W_O)\n return torch.linalg.norm(v_times_Wo, dim=-1)" }, { "id": 7222, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def query_embedding(self, HDWD, cam_xyz, photometric_confidence, img_feats, c2ws, w2cs, intrinsics, cam_vid, pointdir_w=False):\n\n HD, WD = HDWD\n points_embedding = []\n points_dirs = None\n points_conf = None\n points_colors = None\n for feat_str in getattr(self.args, feature_str_lst[cam_vid]):\n if feat_str.startswith(\"imgfeat\"):\n _, view_ids, layer_ids = feat_str.split(\"_\")\n view_ids = [int(a) for a in list(view_ids)]\n layer_ids = [int(a) for a in list(layer_ids)]\n twoD_feats, points_colors = self.extract_2d(img_feats, view_ids, layer_ids, intrinsics, c2ws, w2cs, cam_xyz, HD, WD, cam_vid=cam_vid)\n points_embedding.append(twoD_feats)\n elif feat_str.startswith(\"dir\"):\n _, view_ids = feat_str.split(\"_\")\n view_ids = torch.as_tensor([int(a) for a in list(view_ids)], dtype=torch.int64, device=cam_xyz.device)\n cam_pos_world = c2ws[:, view_ids, :, 3] # B, V, 4\n cam_trans = w2cs[:, cam_vid, ...] # B, 4, 4\n cam_pos_cam = (cam_pos_world @ cam_trans.transpose(1, 2))[...,:3] # B, V, 4\n points_dirs = cam_xyz[:,:, None, :] - cam_pos_cam[:, None, :, :] # B, N, V, 3 in current cam coord\n points_dirs = points_dirs / (torch.linalg.norm(points_dirs, dim=-1, keepdims=True) + 1e-6) # B, N, V, 3\n points_dirs = points_dirs.view(cam_xyz.shape[0], -1, 3) @ c2ws[:, cam_vid, :3, :3].transpose(1, 2)\n if not pointdir_w:\n points_dirs = points_dirs @ c2ws[:, self.args.ref_vid, :3, :3].transpose(1, 2) # in ref cam coord\n # print(\"points_dirs\", points_dirs.shape)\n points_dirs = points_dirs.view(cam_xyz.shape[0], cam_xyz.shape[1], -1)\n elif feat_str.startswith(\"point_conf\"):\n if photometric_confidence is None:\n photometric_confidence = torch.ones_like(points_embedding[0][...,0:1])\n points_conf = photometric_confidence\n points_embedding = torch.cat(points_embedding, dim=-1)\n if self.args.shading_feature_mlp_layer0 > 0:\n points_embedding = self.premlp(torch.cat([points_embedding, points_colors, points_dirs, points_conf], dim=-1))\n return points_embedding, points_colors, points_dirs, points_conf", "probing input": " def query_embedding(self, HDWD, cam_xyz, photometric_confidence, img_feats, c2ws, w2cs, intrinsics, cam_vid, pointdir_w=False):\n\n HD, WD = HDWD\n points_embedding = []\n points_dirs = None\n points_conf = None\n points_colors = None\n for feat_str in getattr(self.args, feature_str_lst[cam_vid]):\n if feat_str.startswith(\"imgfeat\"):\n _, view_ids, layer_ids = feat_str.split(\"_\")\n view_ids = [int(a) for a in list(view_ids)]\n layer_ids = [int(a) for a in list(layer_ids)]\n twoD_feats, points_colors = self.extract_2d(img_feats, view_ids, layer_ids, intrinsics, c2ws, w2cs, cam_xyz, HD, WD, cam_vid=cam_vid)\n points_embedding.append(twoD_feats)\n elif feat_str.startswith(\"dir\"):\n _, view_ids = feat_str.split(\"_\")\n view_ids = torch.as_tensor([int(a) for a in list(view_ids)], dtype=torch.int64, device=cam_xyz.device)\n cam_pos_world = c2ws[:, view_ids, :, 3] # B, V, 4\n cam_trans = w2cs[:, cam_vid, ...] # B, 4, 4\n cam_pos_cam = (cam_pos_world @ cam_trans.transpose(1, 2))[...,:3] # B, V, 4\n points_dirs = cam_xyz[:,:, None, :] - cam_pos_cam[:, None, :, :] # B, N, V, 3 in current cam coord\n", "probing input new": " def query_embedding(self, HDWD, cam_xyz, photometric_confidence, img_feats, c2ws, w2cs, intrinsics, cam_vid, pointdir_w=False):\n\n HD, WD = HDWD\n points_embedding = []\n points_dirs = None\n points_conf = None\n points_colors = None\n for feat_str in getattr(self.args, feature_str_lst[cam_vid]):\n if feat_str.startswith(\"imgfeat\"):\n _, view_ids, layer_ids = feat_str.split(\"_\")\n view_ids = [int(a) for a in list(view_ids)]\n layer_ids = [int(a) for a in list(layer_ids)]\n twoD_feats, points_colors = self.extract_2d(img_feats, view_ids, layer_ids, intrinsics, c2ws, w2cs, cam_xyz, HD, WD, cam_vid=cam_vid)\n points_embedding.append(twoD_feats)\n elif feat_str.startswith(\"dir\"):\n _, view_ids = feat_str.split(\"_\")\n view_ids = torch.as_tensor([int(a) for a in list(view_ids)], dtype=torch.int64, device=cam_xyz.device)\n cam_pos_world = c2ws[:, view_ids, :, 3] # B, V, 4\n cam_trans = w2cs[:, cam_vid, ...] # B, 4, 4\n cam_pos_cam = (cam_pos_world @ cam_trans.transpose(1, 2))[...,:3] # B, V, 4\n points_dirs = cam_xyz[:,:, None, :] - cam_pos_cam[:, None, :, :] # B, N, V, 3 in current cam coord\n points_dirs = points_dirs / (torch.", "reference": "points_dirs=points_dirs/(torch.linalg.norm(points_dirs,dim=-1,keepdims=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "points_dirs=points_dirs/(torch.linalg.norm(points_dirs,dim=-1,keepdims=True)+1e-6)", "y_neg": " points_dirs = points_dirs / (torch.norm(points_dirs, dim=-1, keepdim=True) + 1e-10) # B, N, V, 3", "retain": " def query_embedding(self, HDWD, cam_xyz, photometric_confidence, img_feats, c2ws, w2cs, intrinsics, cam_vid, pointdir_w=False):\n\n HD, WD = HDWD\n points_embedding = []\n points_dirs = None\n points_conf = None\n points_colors = None\n for feat_str in getattr(self.args, feature_str_lst[cam_vid]):\n if feat_str.startswith(\"imgfeat\"):\n _, view_ids, layer_ids = feat_str.split(\"_\")\n view_ids = [int(a) for a in list(view_ids)]\n layer_ids = [int(a) for a in list(layer_ids)]\n twoD_feats, points_colors = self.extract_2d(img_feats, view_ids, layer_ids, intrinsics, c2ws, w2cs, cam_xyz, HD, WD, cam_vid=cam_vid)\n points_embedding.append(twoD_feats)\n elif feat_str.startswith(\"dir\"):\n _, view_ids = feat_str.split(\"_\")\n view_ids = torch.as_tensor([int(a) for a in list(view_ids)], dtype=torch.int64, device=cam_xyz.device)\n cam_pos_world = c2ws[:, view_ids, :, 3] # B, V, 4\n cam_trans = w2cs[:, cam_vid, ...] # B, 4, 4\n cam_pos_cam = (cam_pos_world @ cam_trans.transpose(1, 2))[...,:3] # B, V, 4\n points_dirs = cam_xyz[:,:, None, :] - cam_pos_cam[:, None, :, :] # B, N, V, 3 in current cam coord\n points_dirs = points_dirs / (torch.linalg.norm(points_dirs, dim=-1, keepdims=True) + 1e-6) # B, N, V, 3\n points_dirs = points_dirs.view(cam_xyz.shape[0], -1, 3) @ c2ws[:, cam_vid, :3, :3].transpose(1, 2)\n if not pointdir_w:\n points_dirs = points_dirs @ c2ws[:, self.args.ref_vid, :3, :3].transpose(1, 2) # in ref cam coord\n # print(\"points_dirs\", points_dirs.shape)\n points_dirs = points_dirs.view(cam_xyz.shape[0], cam_xyz.shape[1], -1)\n elif feat_str.startswith(\"point_conf\"):\n if photometric_confidence is None:\n photometric_confidence = torch.ones_like(points_embedding[0][...,0:1])\n points_conf = photometric_confidence\n points_embedding = torch.cat(points_embedding, dim=-1)\n if self.args.shading_feature_mlp_layer0 > 0:\n points_embedding = self.premlp(torch.cat([points_embedding, points_colors, points_dirs, points_conf], dim=-1))\n return points_embedding, points_colors, points_dirs, points_conf" }, { "id": 7228, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def update(self, joints_rst: Tensor, joints_ref: Tensor,\n lengths: List[int]):\n \n assert joints_rst.shape == joints_ref.shape\n assert joints_rst.dim() == 4\n # (bs, seq, njoint=22, 3)\n\n self.count += sum(lengths)\n self.count_seq += len(lengths)\n\n rst = torch.flatten(joints_rst, start_dim=2)\n ref = torch.flatten(joints_ref, start_dim=2)\n \n for i, l in enumerate(lengths):\n if self.task == \"pred\":\n pred_start = int(l*self.cfg.ABLATION.predict_ratio)\n diff = rst[i,pred_start:] - ref[i,pred_start:]\n elif self.task == \"inbetween\":\n inbetween_start = int(l*self.cfg.ABLATION.inbetween_ratio)\n inbetween_end = l - int(l*self.cfg.ABLATION.inbetween_ratio)\n diff = rst[i,inbetween_start:inbetween_end] - ref[i,inbetween_start:inbetween_end]\n else:\n print(f\"Task {self.task} not implemented.\")\n diff = rst - ref\n \n dist = torch.linalg.norm(diff, dim=-1)[None]\n\n ade = dist.mean(dim=1)\n fde = dist[:,-1]\n self.ADE = self.ADE + ade\n self.FDE = self.FDE + fde", "probing input": " def update(self, joints_rst: Tensor, joints_ref: Tensor,\n lengths: List[int]):\n \n assert joints_rst.shape == joints_ref.shape\n assert joints_rst.dim() == 4\n # (bs, seq, njoint=22, 3)\n\n self.count += sum(lengths)\n self.count_seq += len(lengths)\n\n rst = torch.flatten(joints_rst, start_dim=2)\n ref = torch.flatten(joints_ref, start_dim=2)\n \n for i, l in enumerate(lengths):\n if self.task == \"pred\":\n pred_start = int(l*self.cfg.ABLATION.predict_ratio)\n diff = rst[i,pred_start:] - ref[i,pred_start:]\n elif self.task == \"inbetween\":\n inbetween_start = int(l*self.cfg.ABLATION.inbetween_ratio)\n inbetween_end = l - int(l*self.cfg.ABLATION.inbetween_ratio)\n diff = rst[i,inbetween_start:inbetween_end] - ref[i,inbetween_start:inbetween_end]\n else:\n print(f\"Task {self.task} not implemented.\")\n diff = rst - ref\n \n", "probing input new": " def update(self, joints_rst: Tensor, joints_ref: Tensor,\n lengths: List[int]):\n \n assert joints_rst.shape == joints_ref.shape\n assert joints_rst.dim() == 4\n # (bs, seq, njoint=22, 3)\n\n self.count += sum(lengths)\n self.count_seq += len(lengths)\n\n rst = torch.flatten(joints_rst, start_dim=2)\n ref = torch.flatten(joints_ref, start_dim=2)\n \n for i, l in enumerate(lengths):\n if self.task == \"pred\":\n pred_start = int(l*self.cfg.ABLATION.predict_ratio)\n diff = rst[i,pred_start:] - ref[i,pred_start:]\n elif self.task == \"inbetween\":\n inbetween_start = int(l*self.cfg.ABLATION.inbetween_ratio)\n inbetween_end = l - int(l*self.cfg.ABLATION.inbetween_ratio)\n diff = rst[i,inbetween_start:inbetween_end] - ref[i,inbetween_start:inbetween_end]\n else:\n print(f\"Task {self.task} not implemented.\")\n diff = rst - ref\n \n dist = torch.", "reference": "dist=torch.linalg.norm(diff,dim=-1)[None]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(diff,dim=-1)[None]", "y_neg": " dist = torch.norm(diff, p=2, dim=1)", "retain": " def update(self, joints_rst: Tensor, joints_ref: Tensor,\n lengths: List[int]):\n \n assert joints_rst.shape == joints_ref.shape\n assert joints_rst.dim() == 4\n # (bs, seq, njoint=22, 3)\n\n self.count += sum(lengths)\n self.count_seq += len(lengths)\n\n rst = torch.flatten(joints_rst, start_dim=2)\n ref = torch.flatten(joints_ref, start_dim=2)\n \n for i, l in enumerate(lengths):\n if self.task == \"pred\":\n pred_start = int(l*self.cfg.ABLATION.predict_ratio)\n diff = rst[i,pred_start:] - ref[i,pred_start:]\n elif self.task == \"inbetween\":\n inbetween_start = int(l*self.cfg.ABLATION.inbetween_ratio)\n inbetween_end = l - int(l*self.cfg.ABLATION.inbetween_ratio)\n diff = rst[i,inbetween_start:inbetween_end] - ref[i,inbetween_start:inbetween_end]\n else:\n print(f\"Task {self.task} not implemented.\")\n diff = rst - ref\n \n dist = torch.linalg.norm(diff, dim=-1)[None]\n\n ade = dist.mean(dim=1)\n fde = dist[:,-1]\n self.ADE = self.ADE + ade\n self.FDE = self.FDE + fde" }, { "id": 7231, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds = image_class_embeds / (torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6)\n query_embeds = query_embeds / (torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6)\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)", "probing input": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n", "probing input new": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds = image_class_embeds / (torch.", "reference": "image_class_embeds=image_class_embeds/(torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "image_class_embeds=image_class_embeds/(torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6)", "y_neg": " image_class_embeds = image_class_embeds / (torch.norm(image_class_embeds, dim=1, keepdim=True) + 1e-12)", "retain": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: Optional[torch.FloatTensor],\n query_mask: Optional[torch.Tensor],\n ) -> Tuple[torch.FloatTensor]:\n image_class_embeds = self.dense0(image_embeds)\n if query_embeds is None:\n device = image_class_embeds.device\n batch_size, num_patches = image_class_embeds.shape[:2]\n pred_logits = torch.zeros((batch_size, num_patches, self.query_dim)).to(device)\n return (pred_logits, image_class_embeds)\n\n # Normalize image and text features\n image_class_embeds = image_class_embeds / (torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6)\n query_embeds = query_embeds / (torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6)\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)" }, { "id": 7233, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_rays, 3\n rays_v = torch.matmul(c2w[None, :3, :3], rays_v[:, :, None]).squeeze() # N_rays, 3\n rays_o = c2w[None, :3, 3].expand(rays_v.shape) # N_rays, 3\n\n image = image.permute(1, 2, 0)\n color = image.view(-1, 3)\n depth = depth.view(-1, 1) if depth is not None else None\n mask = mask.view(-1, 1) if mask is not None else torch.ones([H * W, 1]).to(device)\n sample = {\n 'rays_o': rays_o,\n 'rays_v': rays_v,\n 'rays_ndc_uv': rays_ndc_uv,\n 'rays_color': color,\n # 'rays_depth': depth,\n 'rays_mask': mask,\n 'rays_norm_XYZ_cam': p # - XYZ_cam, before multiply depth\n }\n if depth is not None:\n sample['rays_depth'] = depth\n\n return sample", "probing input": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n", "probing input new": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # N_rays, 3", "retain": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_rays, 3\n rays_v = torch.matmul(c2w[None, :3, :3], rays_v[:, :, None]).squeeze() # N_rays, 3\n rays_o = c2w[None, :3, 3].expand(rays_v.shape) # N_rays, 3\n\n image = image.permute(1, 2, 0)\n color = image.view(-1, 3)\n depth = depth.view(-1, 1) if depth is not None else None\n mask = mask.view(-1, 1) if mask is not None else torch.ones([H * W, 1]).to(device)\n sample = {\n 'rays_o': rays_o,\n 'rays_v': rays_v,\n 'rays_ndc_uv': rays_ndc_uv,\n 'rays_color': color,\n # 'rays_depth': depth,\n 'rays_mask': mask,\n 'rays_norm_XYZ_cam': p # - XYZ_cam, before multiply depth\n }\n if depth is not None:\n sample['rays_depth'] = depth\n\n return sample" }, { "id": 7234, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty, indexing=\"ij\")\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = c2w_0[:3, 3] * (1.0 - ratio) + c2w_1[:3, 3] * ratio\n\n pose_0 = c2w_0.detach().cpu().numpy()\n pose_1 = c2w_1.detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n\n c2w = torch.from_numpy(pose).to(device)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return c2w, rays_o.transpose(0, 1).contiguous().view(-1, 3), rays_v.transpose(0, 1).contiguous().view(-1, 3)", "probing input": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty, indexing=\"ij\")\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty, indexing=\"ij\")\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p[:, :, 2:], dim=-1, keepdim=True) # W, H, 3", "retain": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty, indexing=\"ij\")\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = c2w_0[:3, 3] * (1.0 - ratio) + c2w_1[:3, 3] * ratio\n\n pose_0 = c2w_0.detach().cpu().numpy()\n pose_1 = c2w_1.detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n\n c2w = torch.from_numpy(pose).to(device)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return c2w, rays_o.transpose(0, 1).contiguous().view(-1, 3), rays_v.transpose(0, 1).contiguous().view(-1, 3)" }, { "id": 7235, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def extract_udf_mesh(self, world_space=False, resolution=256, dist_threshold_ratio=1.0):\n if self.model_type == 'udf':\n func = self.udf_network_fine.udf\n\n def func_grad(xyz):\n gradients = self.udf_network_fine.gradient(xyz)\n gradients_mag = torch.linalg.norm(gradients, ord=2, dim=-1, keepdim=True)\n gradients_norm = gradients / (gradients_mag + 1e-5) # normalize to unit vector\n return gradients_norm\n\n elif self.model_type == 'neus':\n func = lambda pts: torch.abs(self.sdf_network_fine.sdf(pts))\n func_grad = self.sdf_network_fine.gradient\n\n try:\n pred_v, pred_f, pred_mesh, samples, indices = get_mesh_udf_fast(func, func_grad, samples=None,\n indices=None, N_MC=resolution,\n gradient=True, eps=0.005,\n border_gradients=True,\n smooth_borders=True,\n dist_threshold_ratio=dist_threshold_ratio)\n except:\n pred_v, pred_f, pred_mesh, samples, indices = get_mesh_udf_fast(func, func_grad, samples=None,\n indices=None, N_MC=resolution,\n gradient=True, eps=0.005,\n border_gradients=False,\n smooth_borders=False,\n dist_threshold_ratio=dist_threshold_ratio)\n\n vertices, triangles = pred_mesh.vertices, pred_mesh.faces\n if world_space:\n vertices = vertices * self.dataset.scale_mats_np[0][0, 0] + self.dataset.scale_mats_np[0][:3, 3][None]\n\n mesh = trimesh.Trimesh(vertices, triangles)\n\n os.makedirs(os.path.join(self.base_exp_dir, 'udf_meshes'), exist_ok=True)\n mesh.export(\n os.path.join(self.base_exp_dir, 'udf_meshes', 'udf_res{}_step{}.ply'.format(resolution, self.iter_step)))", "probing input": " def extract_udf_mesh(self, world_space=False, resolution=256, dist_threshold_ratio=1.0):\n if self.model_type == 'udf':\n func = self.udf_network_fine.udf\n\n def func_grad(xyz):\n gradients = self.udf_network_fine.gradient(xyz)\n", "probing input new": " def extract_udf_mesh(self, world_space=False, resolution=256, dist_threshold_ratio=1.0):\n if self.model_type == 'udf':\n func = self.udf_network_fine.udf\n\n def func_grad(xyz):\n gradients = self.udf_network_fine.gradient(xyz)\n gradients_mag = torch.", "reference": "gradients_mag=torch.linalg.norm(gradients,ord=2,dim=-1,keepdim=True)", "reference dict": { "mesh": "trimesh.Trimesh" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "gradients_mag=torch.linalg.norm(gradients,ord=2,dim=-1,keepdim=True)", "y_neg": " gradients_mag = torch.norm(gradients, dim=-1)", "retain": " def extract_udf_mesh(self, world_space=False, resolution=256, dist_threshold_ratio=1.0):\n if self.model_type == 'udf':\n func = self.udf_network_fine.udf\n\n def func_grad(xyz):\n gradients = self.udf_network_fine.gradient(xyz)\n gradients_mag = torch.linalg.norm(gradients, ord=2, dim=-1, keepdim=True)\n gradients_norm = gradients / (gradients_mag + 1e-5) # normalize to unit vector\n return gradients_norm\n\n elif self.model_type == 'neus':\n func = lambda pts: torch.abs(self.sdf_network_fine.sdf(pts))\n func_grad = self.sdf_network_fine.gradient\n\n try:\n pred_v, pred_f, pred_mesh, samples, indices = get_mesh_udf_fast(func, func_grad, samples=None,\n indices=None, N_MC=resolution,\n gradient=True, eps=0.005,\n border_gradients=True,\n smooth_borders=True,\n dist_threshold_ratio=dist_threshold_ratio)\n except:\n pred_v, pred_f, pred_mesh, samples, indices = get_mesh_udf_fast(func, func_grad, samples=None,\n indices=None, N_MC=resolution,\n gradient=True, eps=0.005,\n border_gradients=False,\n smooth_borders=False,\n dist_threshold_ratio=dist_threshold_ratio)\n\n vertices, triangles = pred_mesh.vertices, pred_mesh.faces\n if world_space:\n vertices = vertices * self.dataset.scale_mats_np[0][0, 0] + self.dataset.scale_mats_np[0][:3, 3][None]\n\n mesh = trimesh.Trimesh(vertices, triangles)\n\n os.makedirs(os.path.join(self.base_exp_dir, 'udf_meshes'), exist_ok=True)\n mesh.export(\n os.path.join(self.base_exp_dir, 'udf_meshes', 'udf_res{}_step{}.ply'.format(resolution, self.iter_step)))" }, { "id": 7236, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gmres(\n A,\n b,\n x0=None,\n M=NoOp(),\n tol=1e-10,\n maxiter: int = 100,\n check=5,\n return_iters=False,\n eps=1.0e-15,\n):\n \"\"\"\n Solve a linear system of equations using GMRES\n\n Args:\n A (torch.tensor): black matrix\n b (torch.tensor): black RHS\n\n Keyword Args:\n x0 (torch.tensor): initial guess, defaults to zeros\n M (LinearOperator): preconditioning operator\n tol (float): absolute tolerance for solve\n maxiter (int): maximum number of iterations\n check (int): how often to check the residual\n return_iters (bool): return iteration count along with solution\n eps (float): small number to avoid zero vectors\n\n Returns:\n x (torch.tensor): block results\n k (int, optional): iteration count\n \"\"\"\n # Should fix code at some point to treat batch dimensions right\n nbatch = A.shape[0]\n\n # Initial guess\n if x0 is None:\n x0 = torch.zeros_like(b)\n x = x0\n\n # Initial residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n\n # Basis\n V = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n V[..., :, 0] = r / torch.linalg.norm(r, dim=-1)[:, None]\n\n # Preconditioned basis\n Z = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n Z[..., :, 0] = M.dot(V[..., :, 0])\n\n # Hessenberg matrix\n H = torch.zeros((nbatch, maxiter + 1, maxiter), device=A.device)\n\n # Residual norm\n nR = torch.linalg.vector_norm(r, dim=-1)\n\n # Check for an initial zero\n if torch.all(nR < tol):\n if return_iters:\n return x0, 0\n return x0\n\n # Unit vector\n e1 = torch.zeros((nbatch, maxiter + 1), device=A.device)\n e1[:, 0] = nR\n\n # Start iterating\n for k in range(maxiter):\n # A \\cdot v\n w = A.bmm(Z[..., :, k].unsqueeze(-1)).squeeze(-1)\n\n # Orthogonalize\n for j in range(k + 1):\n H[..., j, k] = (\n V[..., :, j].unsqueeze(-2).bmm(w.unsqueeze(-1)).squeeze(-2).squeeze(-1)\n )\n w -= H[..., j, k].unsqueeze(-1) * V[..., :, j]\n\n # Next Arnoldi vector\n H[..., k + 1, k] = torch.linalg.vector_norm(w, dim=-1) + eps\n V[..., :, k + 1] = w / H[..., k + 1, k][:, None]\n\n # Preconditioned\n Z[..., :, k + 1] = M.dot(V[..., :, k + 1])\n\n # If it's time, check the new residual value\n if (k + 1) % check == 0 or (k + 1) == maxiter:\n # Project onto our basis\n y, _, _, _ = torch.linalg.lstsq(\n H[..., : k + 1, :k], e1[..., : k + 1], rcond=None\n )\n # Calculate the value of x\n x = Z[..., :, :k].bmm(y.unsqueeze(-1)).squeeze(-1) + x0\n # Calculate the residual and the norm of the residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n nRc = torch.linalg.vector_norm(r, dim=-1)\n # Check for convergence\n if torch.all(nRc < tol):\n break\n\n if return_iters:\n return x, k\n return x", "probing input": "def gmres(\n A,\n b,\n x0=None,\n M=NoOp(),\n tol=1e-10,\n maxiter: int = 100,\n check=5,\n return_iters=False,\n eps=1.0e-15,\n):\n \"\"\"\n Solve a linear system of equations using GMRES\n\n Args:\n A (torch.tensor): black matrix\n b (torch.tensor): black RHS\n\n Keyword Args:\n x0 (torch.tensor): initial guess, defaults to zeros\n M (LinearOperator): preconditioning operator\n tol (float): absolute tolerance for solve\n maxiter (int): maximum number of iterations\n check (int): how often to check the residual\n return_iters (bool): return iteration count along with solution\n eps (float): small number to avoid zero vectors\n\n Returns:\n x (torch.tensor): block results\n k (int, optional): iteration count\n \"\"\"\n # Should fix code at some point to treat batch dimensions right\n nbatch = A.shape[0]\n\n # Initial guess\n if x0 is None:\n x0 = torch.zeros_like(b)\n x = x0\n\n # Initial residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n\n # Basis\n V = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n", "probing input new": "def gmres(\n A,\n b,\n x0=None,\n M=NoOp(),\n tol=1e-10,\n maxiter: int = 100,\n check=5,\n return_iters=False,\n eps=1.0e-15,\n):\n \"\"\"\n Solve a linear system of equations using GMRES\n\n Args:\n A (torch.tensor): black matrix\n b (torch.tensor): black RHS\n\n Keyword Args:\n x0 (torch.tensor): initial guess, defaults to zeros\n M (LinearOperator): preconditioning operator\n tol (float): absolute tolerance for solve\n maxiter (int): maximum number of iterations\n check (int): how often to check the residual\n return_iters (bool): return iteration count along with solution\n eps (float): small number to avoid zero vectors\n\n Returns:\n x (torch.tensor): block results\n k (int, optional): iteration count\n \"\"\"\n # Should fix code at some point to treat batch dimensions right\n nbatch = A.shape[0]\n\n # Initial guess\n if x0 is None:\n x0 = torch.zeros_like(b)\n x = x0\n\n # Initial residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n\n # Basis\n V = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n V[..., :, 0] = r / torch.", "reference": "V[...,:,0]=r/torch.linalg.norm(r,dim=-1)[:,None]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "V[...,:,0]=r/torch.linalg.norm(r,dim=-1)[:,None]", "y_neg": " V[..., :, 0] = r / torch.norm(r, p=2, dim=-1, keepdim=True)", "retain": "def gmres(\n A,\n b,\n x0=None,\n M=NoOp(),\n tol=1e-10,\n maxiter: int = 100,\n check=5,\n return_iters=False,\n eps=1.0e-15,\n):\n \"\"\"\n Solve a linear system of equations using GMRES\n\n Args:\n A (torch.tensor): black matrix\n b (torch.tensor): black RHS\n\n Keyword Args:\n x0 (torch.tensor): initial guess, defaults to zeros\n M (LinearOperator): preconditioning operator\n tol (float): absolute tolerance for solve\n maxiter (int): maximum number of iterations\n check (int): how often to check the residual\n return_iters (bool): return iteration count along with solution\n eps (float): small number to avoid zero vectors\n\n Returns:\n x (torch.tensor): block results\n k (int, optional): iteration count\n \"\"\"\n # Should fix code at some point to treat batch dimensions right\n nbatch = A.shape[0]\n\n # Initial guess\n if x0 is None:\n x0 = torch.zeros_like(b)\n x = x0\n\n # Initial residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n\n # Basis\n V = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n V[..., :, 0] = r / torch.linalg.norm(r, dim=-1)[:, None]\n\n # Preconditioned basis\n Z = torch.zeros((nbatch, b.shape[-1], maxiter + 1), device=A.device)\n Z[..., :, 0] = M.dot(V[..., :, 0])\n\n # Hessenberg matrix\n H = torch.zeros((nbatch, maxiter + 1, maxiter), device=A.device)\n\n # Residual norm\n nR = torch.linalg.vector_norm(r, dim=-1)\n\n # Check for an initial zero\n if torch.all(nR < tol):\n if return_iters:\n return x0, 0\n return x0\n\n # Unit vector\n e1 = torch.zeros((nbatch, maxiter + 1), device=A.device)\n e1[:, 0] = nR\n\n # Start iterating\n for k in range(maxiter):\n # A \\cdot v\n w = A.bmm(Z[..., :, k].unsqueeze(-1)).squeeze(-1)\n\n # Orthogonalize\n for j in range(k + 1):\n H[..., j, k] = (\n V[..., :, j].unsqueeze(-2).bmm(w.unsqueeze(-1)).squeeze(-2).squeeze(-1)\n )\n w -= H[..., j, k].unsqueeze(-1) * V[..., :, j]\n\n # Next Arnoldi vector\n H[..., k + 1, k] = torch.linalg.vector_norm(w, dim=-1) + eps\n V[..., :, k + 1] = w / H[..., k + 1, k][:, None]\n\n # Preconditioned\n Z[..., :, k + 1] = M.dot(V[..., :, k + 1])\n\n # If it's time, check the new residual value\n if (k + 1) % check == 0 or (k + 1) == maxiter:\n # Project onto our basis\n y, _, _, _ = torch.linalg.lstsq(\n H[..., : k + 1, :k], e1[..., : k + 1], rcond=None\n )\n # Calculate the value of x\n x = Z[..., :, :k].bmm(y.unsqueeze(-1)).squeeze(-1) + x0\n # Calculate the residual and the norm of the residual\n r = b - A.bmm(x.unsqueeze(-1)).squeeze(-1)\n nRc = torch.linalg.vector_norm(r, dim=-1)\n # Check for convergence\n if torch.all(nRc < tol):\n break\n\n if return_iters:\n return x, k\n return x" }, { "id": 7239, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = next_z_vals - prev_z_vals\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(torch.cat([torch.ones([batch_size, 1]), 1.0 - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = next_z_vals - prev_z_vals\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(torch.cat([torch.ones([batch_size, 1]), 1.0 - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7240, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _compute_norm_for_weight(weight, scheme, ord):\n \"\"\"Compute and return operator norm for given matrix.\"\"\"\n # fold into matrix operator\n weight = scheme.fold(weight.detach())\n\n # get and return operator norm of flattened weight\n return torch.linalg.norm(weight, ord=ord)", "probing input": " def _compute_norm_for_weight(weight, scheme, ord):\n \"\"\"Compute and return operator norm for given matrix.\"\"\"\n # fold into matrix operator\n weight = scheme.fold(weight.detach())\n\n # get and return operator norm of flattened weight\n", "probing input new": " def _compute_norm_for_weight(weight, scheme, ord):\n \"\"\"Compute and return operator norm for given matrix.\"\"\"\n # fold into matrix operator\n weight = scheme.fold(weight.detach())\n\n # get and return operator norm of flattened weight\n return torch.", "reference": "returntorch.linalg.norm(weight,ord=ord)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(weight,ord=ord)", "y_neg": " return torch.norm(weight, ord=ord)", "retain": " def _compute_norm_for_weight(weight, scheme, ord):\n \"\"\"Compute and return operator norm for given matrix.\"\"\"\n # fold into matrix operator\n weight = scheme.fold(weight.detach())\n\n # get and return operator norm of flattened weight\n return torch.linalg.norm(weight, ord=ord)" }, { "id": 7241, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, A: Tensor, b: Tensor, x: Optional[Tensor]=None,\n M: Optional[Tensor]=None) -> Tensor:\n '''\n Args:\n A (Tensor): the input tensor. It is assumed to be a symmetric\n positive-definite matrix. Layout is allowed to be COO, CSR, BSR, or dense.\n b (Tensor): the tensor on the right hand side. Layout could be sparse or dense\n but is only allowed to be a type that is compatible with the layout of A.\n In other words, `A @ b` operation must be supported by the layout of A.\n x (Tensor, optional): the initial guess for the solution. Default: ``None``.\n M (Tensor, optional): the preconditioner for A. Layout is allowed to be COO,\n CSR, BSR, or dense. Default: ``None``.\n\n Return:\n Tensor: the solved tensor. Layout is the same as the layout of b.\n '''\n if A.ndim == b.ndim:\n b = b.squeeze(-1)\n else:\n assert A.ndim == b.ndim + 1, \\\n 'The number of dimensions of A and b must differ by 1'\n if x is None:\n x = torch.zeros_like(b)\n bnrm2 = torch.linalg.norm(b, dim=-1)\n if (bnrm2 == 0).all():\n return b\n atol = self.tol * bnrm2\n n = b.shape[-1]\n\n if self.maxiter is None:\n maxiter = n * 10\n else:\n maxiter = self.maxiter\n r = b - bmv(A, x) if x.any() else b.clone()\n rho_prev, p = None, None\n\n for iteration in range(maxiter):\n if (torch.linalg.norm(r, dim=-1) < atol).all():\n return x\n\n z = bmv(M, r) if M is not None else r\n rho_cur = vecdot(r, z)\n if iteration > 0:\n beta = rho_cur / rho_prev\n p = p * beta.unsqueeze(-1) + z\n else: # First spin\n p = torch.empty_like(r)\n p[:] = z[:]\n\n q = bmv(A, p)\n alpha = rho_cur / vecdot(p, q)\n x += alpha.unsqueeze(-1)*p\n r -= alpha.unsqueeze(-1)*q\n rho_prev = rho_cur\n\n return x", "probing input": " def forward(self, A: Tensor, b: Tensor, x: Optional[Tensor]=None,\n M: Optional[Tensor]=None) -> Tensor:\n '''\n Args:\n A (Tensor): the input tensor. It is assumed to be a symmetric\n positive-definite matrix. Layout is allowed to be COO, CSR, BSR, or dense.\n b (Tensor): the tensor on the right hand side. Layout could be sparse or dense\n but is only allowed to be a type that is compatible with the layout of A.\n In other words, `A @ b` operation must be supported by the layout of A.\n x (Tensor, optional): the initial guess for the solution. Default: ``None``.\n M (Tensor, optional): the preconditioner for A. Layout is allowed to be COO,\n CSR, BSR, or dense. Default: ``None``.\n\n Return:\n Tensor: the solved tensor. Layout is the same as the layout of b.\n '''\n if A.ndim == b.ndim:\n b = b.squeeze(-1)\n else:\n assert A.ndim == b.ndim + 1, \\\n 'The number of dimensions of A and b must differ by 1'\n if x is None:\n x = torch.zeros_like(b)\n", "probing input new": " def forward(self, A: Tensor, b: Tensor, x: Optional[Tensor]=None,\n M: Optional[Tensor]=None) -> Tensor:\n '''\n Args:\n A (Tensor): the input tensor. It is assumed to be a symmetric\n positive-definite matrix. Layout is allowed to be COO, CSR, BSR, or dense.\n b (Tensor): the tensor on the right hand side. Layout could be sparse or dense\n but is only allowed to be a type that is compatible with the layout of A.\n In other words, `A @ b` operation must be supported by the layout of A.\n x (Tensor, optional): the initial guess for the solution. Default: ``None``.\n M (Tensor, optional): the preconditioner for A. Layout is allowed to be COO,\n CSR, BSR, or dense. Default: ``None``.\n\n Return:\n Tensor: the solved tensor. Layout is the same as the layout of b.\n '''\n if A.ndim == b.ndim:\n b = b.squeeze(-1)\n else:\n assert A.ndim == b.ndim + 1, \\\n 'The number of dimensions of A and b must differ by 1'\n if x is None:\n x = torch.zeros_like(b)\n bnrm2 = torch.", "reference": "bnrm2=torch.linalg.norm(b,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "bnrm2=torch.linalg.norm(b,dim=-1)", "y_neg": " bnrm2 = torch.norm(b, p='fro', dim=-1, keepdim=True)", "retain": " def forward(self, A: Tensor, b: Tensor, x: Optional[Tensor]=None,\n M: Optional[Tensor]=None) -> Tensor:\n '''\n Args:\n A (Tensor): the input tensor. It is assumed to be a symmetric\n positive-definite matrix. Layout is allowed to be COO, CSR, BSR, or dense.\n b (Tensor): the tensor on the right hand side. Layout could be sparse or dense\n but is only allowed to be a type that is compatible with the layout of A.\n In other words, `A @ b` operation must be supported by the layout of A.\n x (Tensor, optional): the initial guess for the solution. Default: ``None``.\n M (Tensor, optional): the preconditioner for A. Layout is allowed to be COO,\n CSR, BSR, or dense. Default: ``None``.\n\n Return:\n Tensor: the solved tensor. Layout is the same as the layout of b.\n '''\n if A.ndim == b.ndim:\n b = b.squeeze(-1)\n else:\n assert A.ndim == b.ndim + 1, \\\n 'The number of dimensions of A and b must differ by 1'\n if x is None:\n x = torch.zeros_like(b)\n bnrm2 = torch.linalg.norm(b, dim=-1)\n if (bnrm2 == 0).all():\n return b\n atol = self.tol * bnrm2\n n = b.shape[-1]\n\n if self.maxiter is None:\n maxiter = n * 10\n else:\n maxiter = self.maxiter\n r = b - bmv(A, x) if x.any() else b.clone()\n rho_prev, p = None, None\n\n for iteration in range(maxiter):\n if (torch.linalg.norm(r, dim=-1) < atol).all():\n return x\n\n z = bmv(M, r) if M is not None else r\n rho_cur = vecdot(r, z)\n if iteration > 0:\n beta = rho_cur / rho_prev\n p = p * beta.unsqueeze(-1) + z\n else: # First spin\n p = torch.empty_like(r)\n p[:] = z[:]\n\n q = bmv(A, p)\n alpha = rho_cur / vecdot(p, q)\n x += alpha.unsqueeze(-1)*p\n r -= alpha.unsqueeze(-1)*q\n rho_prev = rho_cur\n\n return x" }, { "id": 7242, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(v: torch.Tensor) -> torch.Tensor:\n return v / torch.linalg.norm(v, dim=-1, keepdim=True)", "probing input": "def normalize(v: torch.Tensor) -> torch.Tensor:\n", "probing input new": "def normalize(v: torch.Tensor) -> torch.Tensor:\n return v / torch.", "reference": "returnv/torch.linalg.norm(v,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnv/torch.linalg.norm(v,dim=-1,keepdim=True)", "y_neg": " return v / torch.norm(v, p=2, dim=0, keepdim=True)", "retain": "def normalize(v: torch.Tensor) -> torch.Tensor:\n return v / torch.linalg.norm(v, dim=-1, keepdim=True)" }, { "id": 7243, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7244, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()" }, { "id": 7246, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sh():\n from gsplat import _torch_impl\n from gsplat import sh\n\n num_points = 1\n degree = 4\n gt_colors = torch.ones(num_points, 3, device=device) * 0.5\n viewdirs = torch.randn(num_points, 3, device=device)\n viewdirs /= torch.linalg.norm(viewdirs, dim=-1, keepdim=True)\n sh_coeffs = torch.rand(\n num_points, sh.num_sh_bases(degree), 3, device=device, requires_grad=True\n )\n optim = torch.optim.Adam([sh_coeffs], lr=1e-2)\n\n num_iters = 1000\n for _ in range(num_iters):\n optim.zero_grad()\n\n # compute PyTorch's color and grad\n check_colors = _torch_impl.compute_sh_color(viewdirs, sh_coeffs)\n check_loss = torch.square(check_colors - gt_colors).mean()\n check_loss.backward()\n check_grad = sh_coeffs.grad.detach()\n\n optim.zero_grad()\n\n # compute our colors and grads\n colors = sh.spherical_harmonics(degree, viewdirs, sh_coeffs)\n loss = torch.square(colors - gt_colors).mean()\n loss.backward()\n grad = sh_coeffs.grad.detach()\n optim.step()\n\n torch.testing.assert_close(check_grad, grad)\n torch.testing.assert_close(check_colors, colors)\n\n # check final optimized color\n torch.testing.assert_close(check_colors, gt_colors)", "probing input": "def test_sh():\n from gsplat import _torch_impl\n from gsplat import sh\n\n num_points = 1\n degree = 4\n gt_colors = torch.ones(num_points, 3, device=device) * 0.5\n viewdirs = torch.randn(num_points, 3, device=device)\n", "probing input new": "def test_sh():\n from gsplat import _torch_impl\n from gsplat import sh\n\n num_points = 1\n degree = 4\n gt_colors = torch.ones(num_points, 3, device=device) * 0.5\n viewdirs = torch.randn(num_points, 3, device=device)\n viewdirs /= torch.", "reference": "viewdirs/=torch.linalg.norm(viewdirs,dim=-1,keepdim=True)", "reference dict": { "optim": "torch.optim.Adam" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "viewdirs/=torch.linalg.norm(viewdirs,dim=-1,keepdim=True)", "y_neg": " viewdirs /= torch.norm(viewdirs, dim=-1, keepdim=True)", "retain": "def test_sh():\n from gsplat import _torch_impl\n from gsplat import sh\n\n num_points = 1\n degree = 4\n gt_colors = torch.ones(num_points, 3, device=device) * 0.5\n viewdirs = torch.randn(num_points, 3, device=device)\n viewdirs /= torch.linalg.norm(viewdirs, dim=-1, keepdim=True)\n sh_coeffs = torch.rand(\n num_points, sh.num_sh_bases(degree), 3, device=device, requires_grad=True\n )\n optim = torch.optim.Adam([sh_coeffs], lr=1e-2)\n\n num_iters = 1000\n for _ in range(num_iters):\n optim.zero_grad()\n\n # compute PyTorch's color and grad\n check_colors = _torch_impl.compute_sh_color(viewdirs, sh_coeffs)\n check_loss = torch.square(check_colors - gt_colors).mean()\n check_loss.backward()\n check_grad = sh_coeffs.grad.detach()\n\n optim.zero_grad()\n\n # compute our colors and grads\n colors = sh.spherical_harmonics(degree, viewdirs, sh_coeffs)\n loss = torch.square(colors - gt_colors).mean()\n loss.backward()\n grad = sh_coeffs.grad.detach()\n optim.step()\n\n torch.testing.assert_close(check_grad, grad)\n torch.testing.assert_close(check_colors, colors)\n\n # check final optimized color\n torch.testing.assert_close(check_colors, gt_colors)" }, { "id": 7247, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_franka_kinematics(cfg):\n tensor_args = TensorDeviceType()\n\n robot_model = CudaRobotModel(cfg)\n q_test = torch.as_tensor(\n [0.0, -1.2, 0.0, -2.0, 0.0, 1.0, 0.0], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_position = torch.as_tensor(\n [6.0860e-02, -4.7547e-12, 7.6373e-01], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_quat = torch.as_tensor(\n [0.0382, 0.9193, 0.3808, 0.0922], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n b_list = [1, 10, 100, 5000][:1]\n for b in b_list:\n state = robot_model.get_state(q_test.repeat(b, 1).clone())\n pos_err = torch.linalg.norm(state.ee_position - ee_position)\n q_err = torch.linalg.norm(state.ee_quaternion - ee_quat)\n # check if all values are equal to position and quaternion\n assert pos_err < 1e-3\n assert q_err < 1e-1", "probing input": "def test_franka_kinematics(cfg):\n tensor_args = TensorDeviceType()\n\n robot_model = CudaRobotModel(cfg)\n q_test = torch.as_tensor(\n [0.0, -1.2, 0.0, -2.0, 0.0, 1.0, 0.0], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_position = torch.as_tensor(\n [6.0860e-02, -4.7547e-12, 7.6373e-01], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_quat = torch.as_tensor(\n [0.0382, 0.9193, 0.3808, 0.0922], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n b_list = [1, 10, 100, 5000][:1]\n for b in b_list:\n state = robot_model.get_state(q_test.repeat(b, 1).clone())\n", "probing input new": "def test_franka_kinematics(cfg):\n tensor_args = TensorDeviceType()\n\n robot_model = CudaRobotModel(cfg)\n q_test = torch.as_tensor(\n [0.0, -1.2, 0.0, -2.0, 0.0, 1.0, 0.0], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_position = torch.as_tensor(\n [6.0860e-02, -4.7547e-12, 7.6373e-01], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_quat = torch.as_tensor(\n [0.0382, 0.9193, 0.3808, 0.0922], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n b_list = [1, 10, 100, 5000][:1]\n for b in b_list:\n state = robot_model.get_state(q_test.repeat(b, 1).clone())\n pos_err = torch.", "reference": "pos_err=torch.linalg.norm(state.ee_position-ee_position)", "reference dict": { "tensor_args": "TensorDeviceType", "robot_model": "CudaRobotModel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "pos_err=torch.linalg.norm(state.ee_position-ee_position)", "y_neg": " pos_err = torch.norm(state.ee_position - ee_position, p=2, dim=-1)", "retain": "def test_franka_kinematics(cfg):\n tensor_args = TensorDeviceType()\n\n robot_model = CudaRobotModel(cfg)\n q_test = torch.as_tensor(\n [0.0, -1.2, 0.0, -2.0, 0.0, 1.0, 0.0], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_position = torch.as_tensor(\n [6.0860e-02, -4.7547e-12, 7.6373e-01], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n ee_quat = torch.as_tensor(\n [0.0382, 0.9193, 0.3808, 0.0922], **(tensor_args.as_torch_dict())\n ).view(1, -1)\n b_list = [1, 10, 100, 5000][:1]\n for b in b_list:\n state = robot_model.get_state(q_test.repeat(b, 1).clone())\n pos_err = torch.linalg.norm(state.ee_position - ee_position)\n q_err = torch.linalg.norm(state.ee_quaternion - ee_quat)\n # check if all values are equal to position and quaternion\n assert pos_err < 1e-3\n assert q_err < 1e-1" }, { "id": 7251, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def predict(self, image, gen_model=\"icgan\", conditional_class=None, num_samples=1, seed=0):\n assert isinstance(seed, int), \"seed should be an integer\"\n if gen_model == 'cc_icgan':\n assert conditional_class is not None, 'please set conditional_class for cc_icgan'\n num_samples_ranked = num_samples\n experiment_name = (\n \"icgan_biggan_imagenet_res256\"\n if gen_model == \"icgan\"\n else \"cc_icgan_biggan_imagenet_res256\"\n )\n num_samples_total = num_samples * 10\n truncation = 0.7\n if conditional_class is not None:\n class_index = NAME2IND[conditional_class]\n\n input_image_instance = str(image)\n\n if gen_model == \"icgan\":\n class_index = None\n\n if seed == 0:\n seed = None\n\n state = None if not seed else np.random.RandomState(seed)\n np.random.seed(seed)\n\n feature_extractor_name = (\"classification\" if gen_model == \"cc_icgan\" else \"selfsupervised\")\n\n # Load feature extractor (outlier filtering and optionally input image feature extraction)\n self.feature_extractor, self.last_feature_extractor = load_feature_extractor(\n gen_model, self.last_feature_extractor, self.feature_extractor)\n # Load features\n if input_image_instance not in [\"None\", \"\", None]:\n print(\"Obtaining instance features from input image!\")\n input_feature_index = None\n input_image_tensor = preprocess_input_image(input_image_instance, self.size)\n with torch.no_grad():\n input_features, _ = self.feature_extractor(input_image_tensor.cuda())\n input_features /= torch.linalg.norm(input_features, dim=-1, keepdims=True)\n elif input_feature_index is not None:\n print(\"Selecting an instance from pre-extracted vectors!\")\n input_features = np.load(\n \"stored_instances/imagenet_res\"\n + str(self.size)\n + \"_rn50_\"\n + feature_extractor_name\n + \"_kmeans_k1000_instance_features.npy\",\n allow_pickle=True,\n ).item()[\"instance_features\"][input_feature_index: input_feature_index + 1]\n else:\n input_features = None\n\n # Load generative model\n self.model, self.last_gen_model = load_generative_model(\n gen_model, self.last_gen_model, experiment_name, self.model)\n # Prepare other variables\n\n replace_to_inplace_relu(self.model)\n\n # Create noise, instance and class vector\n noise_vector = truncnorm.rvs(\n -2 * truncation,\n 2 * truncation,\n size=(num_samples_total, self.noise_size),\n random_state=state,\n ).astype(np.float32)\n noise_vector = torch.tensor(noise_vector, requires_grad=False, device=\"cuda\")\n if input_features is not None:\n instance_vector = torch.tensor(\n input_features, requires_grad=False, device=\"cuda\"\n ).repeat(num_samples_total, 1)\n else:\n instance_vector = None\n if class_index is not None:\n input_label = torch.LongTensor([class_index] * num_samples_total)\n else:\n input_label = None\n if input_feature_index is not None:\n print(\"Conditioning on instance with index: \", input_feature_index)\n\n all_outs, all_dists = [], []\n for i_bs in range(num_samples_total // self.batch_size + 1):\n start = i_bs * self.batch_size\n end = min(start + self.batch_size, num_samples_total)\n if start == end:\n break\n out = get_output(\n noise_vector[start:end],\n input_label[start:end] if input_label is not None else None,\n instance_vector[start:end] if instance_vector is not None else None,\n self.model,\n truncation,\n channels=3,\n )\n\n if instance_vector is not None:\n # Get features from generated images + feature extractor\n out_ = preprocess_generated_image(out)\n with torch.no_grad():\n out_features, _ = self.feature_extractor(out_.cuda())\n out_features /= torch.linalg.norm(out_features, dim=-1, keepdims=True)\n dists = sklearn.metrics.pairwise_distances(\n out_features.cpu(),\n instance_vector[start:end].cpu(),\n metric=\"euclidean\",\n n_jobs=-1,\n )\n all_dists.append(np.diagonal(dists))\n all_outs.append(out.detach().cpu())\n del out\n all_outs = torch.cat(all_outs)\n all_dists = np.concatenate(all_dists)\n\n # Order samples by distance to conditioning feature vector and select only num_samples_ranked images\n selected_idxs = np.argsort(all_dists)[:num_samples_ranked]\n # Create figure\n row_i, col_i, i_im = 0, 0, 0\n all_images_mosaic = np.zeros(\n (\n 3,\n self.size * (int(np.sqrt(num_samples_ranked))),\n self.size * (int(np.sqrt(num_samples_ranked))),\n )\n )\n for j in selected_idxs:\n all_images_mosaic[\n :,\n row_i * self.size: row_i * self.size + self.size,\n col_i * self.size: col_i * self.size + self.size,\n ] = all_outs[j]\n if row_i == int(np.sqrt(num_samples_ranked)) - 1:\n row_i = 0\n if col_i == int(np.sqrt(num_samples_ranked)) - 1:\n col_i = 0\n else:\n col_i += 1\n else:\n row_i += 1\n i_im += 1\n\n out_path = Path(tempfile.mkdtemp()) / \"out.png\"\n save(all_images_mosaic[np.newaxis, ...], str(out_path), torch_format=False)\n return out_path", "probing input": " def predict(self, image, gen_model=\"icgan\", conditional_class=None, num_samples=1, seed=0):\n assert isinstance(seed, int), \"seed should be an integer\"\n if gen_model == 'cc_icgan':\n assert conditional_class is not None, 'please set conditional_class for cc_icgan'\n num_samples_ranked = num_samples\n experiment_name = (\n \"icgan_biggan_imagenet_res256\"\n if gen_model == \"icgan\"\n else \"cc_icgan_biggan_imagenet_res256\"\n )\n num_samples_total = num_samples * 10\n truncation = 0.7\n if conditional_class is not None:\n class_index = NAME2IND[conditional_class]\n\n input_image_instance = str(image)\n\n if gen_model == \"icgan\":\n class_index = None\n\n if seed == 0:\n seed = None\n\n state = None if not seed else np.random.RandomState(seed)\n np.random.seed(seed)\n\n feature_extractor_name = (\"classification\" if gen_model == \"cc_icgan\" else \"selfsupervised\")\n\n # Load feature extractor (outlier filtering and optionally input image feature extraction)\n self.feature_extractor, self.last_feature_extractor = load_feature_extractor(\n gen_model, self.last_feature_extractor, self.feature_extractor)\n # Load features\n if input_image_instance not in [\"None\", \"\", None]:\n print(\"Obtaining instance features from input image!\")\n input_feature_index = None\n input_image_tensor = preprocess_input_image(input_image_instance, self.size)\n with torch.no_grad():\n input_features, _ = self.feature_extractor(input_image_tensor.cuda())\n", "probing input new": " def predict(self, image, gen_model=\"icgan\", conditional_class=None, num_samples=1, seed=0):\n assert isinstance(seed, int), \"seed should be an integer\"\n if gen_model == 'cc_icgan':\n assert conditional_class is not None, 'please set conditional_class for cc_icgan'\n num_samples_ranked = num_samples\n experiment_name = (\n \"icgan_biggan_imagenet_res256\"\n if gen_model == \"icgan\"\n else \"cc_icgan_biggan_imagenet_res256\"\n )\n num_samples_total = num_samples * 10\n truncation = 0.7\n if conditional_class is not None:\n class_index = NAME2IND[conditional_class]\n\n input_image_instance = str(image)\n\n if gen_model == \"icgan\":\n class_index = None\n\n if seed == 0:\n seed = None\n\n state = None if not seed else np.random.RandomState(seed)\n np.random.seed(seed)\n\n feature_extractor_name = (\"classification\" if gen_model == \"cc_icgan\" else \"selfsupervised\")\n\n # Load feature extractor (outlier filtering and optionally input image feature extraction)\n self.feature_extractor, self.last_feature_extractor = load_feature_extractor(\n gen_model, self.last_feature_extractor, self.feature_extractor)\n # Load features\n if input_image_instance not in [\"None\", \"\", None]:\n print(\"Obtaining instance features from input image!\")\n input_feature_index = None\n input_image_tensor = preprocess_input_image(input_image_instance, self.size)\n with torch.no_grad():\n input_features, _ = self.feature_extractor(input_image_tensor.cuda())\n input_features /= torch.", "reference": "input_features/=torch.linalg.norm(input_features,dim=-1,keepdims=True)", "reference dict": { "input_label": "torch.LongTensor" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "input_features/=torch.linalg.norm(input_features,dim=-1,keepdims=True)", "y_neg": " input_features /= torch.norm(input_features, dim=1, keepdim=True)", "retain": " def predict(self, image, gen_model=\"icgan\", conditional_class=None, num_samples=1, seed=0):\n assert isinstance(seed, int), \"seed should be an integer\"\n if gen_model == 'cc_icgan':\n assert conditional_class is not None, 'please set conditional_class for cc_icgan'\n num_samples_ranked = num_samples\n experiment_name = (\n \"icgan_biggan_imagenet_res256\"\n if gen_model == \"icgan\"\n else \"cc_icgan_biggan_imagenet_res256\"\n )\n num_samples_total = num_samples * 10\n truncation = 0.7\n if conditional_class is not None:\n class_index = NAME2IND[conditional_class]\n\n input_image_instance = str(image)\n\n if gen_model == \"icgan\":\n class_index = None\n\n if seed == 0:\n seed = None\n\n state = None if not seed else np.random.RandomState(seed)\n np.random.seed(seed)\n\n feature_extractor_name = (\"classification\" if gen_model == \"cc_icgan\" else \"selfsupervised\")\n\n # Load feature extractor (outlier filtering and optionally input image feature extraction)\n self.feature_extractor, self.last_feature_extractor = load_feature_extractor(\n gen_model, self.last_feature_extractor, self.feature_extractor)\n # Load features\n if input_image_instance not in [\"None\", \"\", None]:\n print(\"Obtaining instance features from input image!\")\n input_feature_index = None\n input_image_tensor = preprocess_input_image(input_image_instance, self.size)\n with torch.no_grad():\n input_features, _ = self.feature_extractor(input_image_tensor.cuda())\n input_features /= torch.linalg.norm(input_features, dim=-1, keepdims=True)\n elif input_feature_index is not None:\n print(\"Selecting an instance from pre-extracted vectors!\")\n input_features = np.load(\n \"stored_instances/imagenet_res\"\n + str(self.size)\n + \"_rn50_\"\n + feature_extractor_name\n + \"_kmeans_k1000_instance_features.npy\",\n allow_pickle=True,\n ).item()[\"instance_features\"][input_feature_index: input_feature_index + 1]\n else:\n input_features = None\n\n # Load generative model\n self.model, self.last_gen_model = load_generative_model(\n gen_model, self.last_gen_model, experiment_name, self.model)\n # Prepare other variables\n\n replace_to_inplace_relu(self.model)\n\n # Create noise, instance and class vector\n noise_vector = truncnorm.rvs(\n -2 * truncation,\n 2 * truncation,\n size=(num_samples_total, self.noise_size),\n random_state=state,\n ).astype(np.float32)\n noise_vector = torch.tensor(noise_vector, requires_grad=False, device=\"cuda\")\n if input_features is not None:\n instance_vector = torch.tensor(\n input_features, requires_grad=False, device=\"cuda\"\n ).repeat(num_samples_total, 1)\n else:\n instance_vector = None\n if class_index is not None:\n input_label = torch.LongTensor([class_index] * num_samples_total)\n else:\n input_label = None\n if input_feature_index is not None:\n print(\"Conditioning on instance with index: \", input_feature_index)\n\n all_outs, all_dists = [], []\n for i_bs in range(num_samples_total // self.batch_size + 1):\n start = i_bs * self.batch_size\n end = min(start + self.batch_size, num_samples_total)\n if start == end:\n break\n out = get_output(\n noise_vector[start:end],\n input_label[start:end] if input_label is not None else None,\n instance_vector[start:end] if instance_vector is not None else None,\n self.model,\n truncation,\n channels=3,\n )\n\n if instance_vector is not None:\n # Get features from generated images + feature extractor\n out_ = preprocess_generated_image(out)\n with torch.no_grad():\n out_features, _ = self.feature_extractor(out_.cuda())\n out_features /= torch.linalg.norm(out_features, dim=-1, keepdims=True)\n dists = sklearn.metrics.pairwise_distances(\n out_features.cpu(),\n instance_vector[start:end].cpu(),\n metric=\"euclidean\",\n n_jobs=-1,\n )\n all_dists.append(np.diagonal(dists))\n all_outs.append(out.detach().cpu())\n del out\n all_outs = torch.cat(all_outs)\n all_dists = np.concatenate(all_dists)\n\n # Order samples by distance to conditioning feature vector and select only num_samples_ranked images\n selected_idxs = np.argsort(all_dists)[:num_samples_ranked]\n # Create figure\n row_i, col_i, i_im = 0, 0, 0\n all_images_mosaic = np.zeros(\n (\n 3,\n self.size * (int(np.sqrt(num_samples_ranked))),\n self.size * (int(np.sqrt(num_samples_ranked))),\n )\n )\n for j in selected_idxs:\n all_images_mosaic[\n :,\n row_i * self.size: row_i * self.size + self.size,\n col_i * self.size: col_i * self.size + self.size,\n ] = all_outs[j]\n if row_i == int(np.sqrt(num_samples_ranked)) - 1:\n row_i = 0\n if col_i == int(np.sqrt(num_samples_ranked)) - 1:\n col_i = 0\n else:\n col_i += 1\n else:\n row_i += 1\n i_im += 1\n\n out_path = Path(tempfile.mkdtemp()) / \"out.png\"\n save(all_images_mosaic[np.newaxis, ...], str(out_path), torch_format=False)\n return out_path" }, { "id": 7259, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def plan_path_mpnet(model, enc, start, goal, device, collisionFn, worldBounds):\n '''\n Plan a path using MPNet.\n :param model: The NN model used for planning.\n :param enc: The latent space representation of the map.\n :param start: A numpy array of size 2 with the normalized start state.\n :param goal: A numpy array of size 2 with the normalized goal state.\n :param device: The device used for torch computations.\n :param collisionFn: A function to check if a state is in collision\n :param worldBounds: A numpy array of worldBounds\n :returns np.array: A set of scaled trajectories\n '''\n goalS = torch.tensor(normalize_state(goal, worldBounds)[None,:], device=device, dtype=torch.float)\n startS = torch.tensor(normalize_state(start, worldBounds)[None,:], device=device, dtype=torch.float)\n reachedGoal = False\n normPredTraj = [startS.cpu().numpy().squeeze()]\n vertex = 0\n for _ in range(10):\n # Check if we can connect start and goal state\n if not check_edge_collision(scale_state(startS.cpu().numpy().squeeze()), goal, collisionFn):\n reachedGoal = True\n break\n inputs = torch.cat([enc, startS, goalS], dim=1)\n for _ in range(10):\n with torch.no_grad():\n tempS = model(inputs)\n temp = tempS.cpu().numpy().squeeze()\n if collisionFn(scale_state(temp)):\n vertex +=1 \n startS = tempS\n normPredTraj.append(temp)\n break\n # Check if we can connect to the goal or reached near it\n if torch.linalg.norm(startS-goalS)*24<0.1:\n reachedGoal = True\n break\n if reachedGoal:\n normPredTraj.append(normalize_state(goal, worldBounds))\n return scale_state(np.array(normPredTraj)), reachedGoal, vertex", "probing input": "def plan_path_mpnet(model, enc, start, goal, device, collisionFn, worldBounds):\n '''\n Plan a path using MPNet.\n :param model: The NN model used for planning.\n :param enc: The latent space representation of the map.\n :param start: A numpy array of size 2 with the normalized start state.\n :param goal: A numpy array of size 2 with the normalized goal state.\n :param device: The device used for torch computations.\n :param collisionFn: A function to check if a state is in collision\n :param worldBounds: A numpy array of worldBounds\n :returns np.array: A set of scaled trajectories\n '''\n goalS = torch.tensor(normalize_state(goal, worldBounds)[None,:], device=device, dtype=torch.float)\n startS = torch.tensor(normalize_state(start, worldBounds)[None,:], device=device, dtype=torch.float)\n reachedGoal = False\n normPredTraj = [startS.cpu().numpy().squeeze()]\n vertex = 0\n for _ in range(10):\n # Check if we can connect start and goal state\n if not check_edge_collision(scale_state(startS.cpu().numpy().squeeze()), goal, collisionFn):\n reachedGoal = True\n break\n inputs = torch.cat([enc, startS, goalS], dim=1)\n for _ in range(10):\n with torch.no_grad():\n tempS = model(inputs)\n temp = tempS.cpu().numpy().squeeze()\n if collisionFn(scale_state(temp)):\n vertex +=1 \n startS = tempS\n normPredTraj.append(temp)\n break\n # Check if we can connect to the goal or reached near it\n", "probing input new": "def plan_path_mpnet(model, enc, start, goal, device, collisionFn, worldBounds):\n '''\n Plan a path using MPNet.\n :param model: The NN model used for planning.\n :param enc: The latent space representation of the map.\n :param start: A numpy array of size 2 with the normalized start state.\n :param goal: A numpy array of size 2 with the normalized goal state.\n :param device: The device used for torch computations.\n :param collisionFn: A function to check if a state is in collision\n :param worldBounds: A numpy array of worldBounds\n :returns np.array: A set of scaled trajectories\n '''\n goalS = torch.tensor(normalize_state(goal, worldBounds)[None,:], device=device, dtype=torch.float)\n startS = torch.tensor(normalize_state(start, worldBounds)[None,:], device=device, dtype=torch.float)\n reachedGoal = False\n normPredTraj = [startS.cpu().numpy().squeeze()]\n vertex = 0\n for _ in range(10):\n # Check if we can connect start and goal state\n if not check_edge_collision(scale_state(startS.cpu().numpy().squeeze()), goal, collisionFn):\n reachedGoal = True\n break\n inputs = torch.cat([enc, startS, goalS], dim=1)\n for _ in range(10):\n with torch.no_grad():\n tempS = model(inputs)\n temp = tempS.cpu().numpy().squeeze()\n if collisionFn(scale_state(temp)):\n vertex +=1 \n startS = tempS\n normPredTraj.append(temp)\n break\n # Check if we can connect to the goal or reached near it\n if torch.", "reference": "iftorch.linalg.norm(startS-goalS)*24<0.1:", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "iftorch.linalg.norm(startS-goalS)*24<0.1:", "y_neg": " if torch.norm(startS - goalS) < 0.01:", "retain": "def plan_path_mpnet(model, enc, start, goal, device, collisionFn, worldBounds):\n '''\n Plan a path using MPNet.\n :param model: The NN model used for planning.\n :param enc: The latent space representation of the map.\n :param start: A numpy array of size 2 with the normalized start state.\n :param goal: A numpy array of size 2 with the normalized goal state.\n :param device: The device used for torch computations.\n :param collisionFn: A function to check if a state is in collision\n :param worldBounds: A numpy array of worldBounds\n :returns np.array: A set of scaled trajectories\n '''\n goalS = torch.tensor(normalize_state(goal, worldBounds)[None,:], device=device, dtype=torch.float)\n startS = torch.tensor(normalize_state(start, worldBounds)[None,:], device=device, dtype=torch.float)\n reachedGoal = False\n normPredTraj = [startS.cpu().numpy().squeeze()]\n vertex = 0\n for _ in range(10):\n # Check if we can connect start and goal state\n if not check_edge_collision(scale_state(startS.cpu().numpy().squeeze()), goal, collisionFn):\n reachedGoal = True\n break\n inputs = torch.cat([enc, startS, goalS], dim=1)\n for _ in range(10):\n with torch.no_grad():\n tempS = model(inputs)\n temp = tempS.cpu().numpy().squeeze()\n if collisionFn(scale_state(temp)):\n vertex +=1 \n startS = tempS\n normPredTraj.append(temp)\n break\n # Check if we can connect to the goal or reached near it\n if torch.linalg.norm(startS-goalS)*24<0.1:\n reachedGoal = True\n break\n if reachedGoal:\n normPredTraj.append(normalize_state(goal, worldBounds))\n return scale_state(np.array(normPredTraj)), reachedGoal, vertex" }, { "id": 7260, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.linalg.norm(w,dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w/theta\n tan = torch.tan(0.5*theta)\n\n t = T[:,:3,3]\n wnorm_x_t = torch.cross(w_norm,t)\n V_inv_t = t - (0.5 * t) * wnorm_x_t + (1.0 - theta/(2.0*tan)) * torch.cross(w_norm, wnorm_x_t)\n xi = torch.cat((w, V_inv_t),dim=-1)\n\n return xi", "probing input": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n", "probing input new": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.", "reference": "theta=torch.linalg.norm(w,dim=(1))", "reference dict": { "w": "SO3_logmap" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(w,dim=(1))", "y_neg": " theta = torch.log(torch.norm(T[:,:3,:3]) + eps)", "retain": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:,:3,:3])\n theta = torch.linalg.norm(w,dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w/theta\n tan = torch.tan(0.5*theta)\n\n t = T[:,:3,3]\n wnorm_x_t = torch.cross(w_norm,t)\n V_inv_t = t - (0.5 * t) * wnorm_x_t + (1.0 - theta/(2.0*tan)) * torch.cross(w_norm, wnorm_x_t)\n xi = torch.cat((w, V_inv_t),dim=-1)\n\n return xi" }, { "id": 7261, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def contract_to_unisphere(\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: Union[str, int] = 2,\n # ord: Union[float, int] = float(\"inf\"),\n eps: float = 1e-6,\n derivative: bool = False,\n):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n mask = mag.squeeze(-1) > 1\n\n if derivative:\n dev = (2 * mag - 1) / mag**2 + 2 * x**2 * (\n 1 / mag**3 - (2 * mag - 1) / mag**4\n )\n dev[~mask] = 1.0\n dev = torch.clamp(dev, min=eps)\n return dev\n else:\n x[mask] = (2 - 1 / mag[mask]) * (x[mask] / mag[mask])\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x", "probing input": "def contract_to_unisphere(\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: Union[str, int] = 2,\n # ord: Union[float, int] = float(\"inf\"),\n eps: float = 1e-6,\n derivative: bool = False,\n):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n", "probing input new": "def contract_to_unisphere(\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: Union[str, int] = 2,\n # ord: Union[float, int] = float(\"inf\"),\n eps: float = 1e-6,\n derivative: bool = False,\n):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "y_neg": " mag = torch.norm(x, p=ord, dim=-1, keepdim=True)", "retain": "def contract_to_unisphere(\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: Union[str, int] = 2,\n # ord: Union[float, int] = float(\"inf\"),\n eps: float = 1e-6,\n derivative: bool = False,\n):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n mask = mag.squeeze(-1) > 1\n\n if derivative:\n dev = (2 * mag - 1) / mag**2 + 2 * x**2 * (\n 1 / mag**3 - (2 * mag - 1) / mag**4\n )\n dev[~mask] = 1.0\n dev = torch.clamp(dev, min=eps)\n return dev\n else:\n x[mask] = (2 - 1 / mag[mask]) * (x[mask] / mag[mask])\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x" }, { "id": 7266, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(x: torch.Tensor) -> Float[Tensor, \"*batch\"]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)", "probing input": "def normalize(x: torch.Tensor) -> Float[Tensor, \"*batch\"]:\n \"\"\"Returns a normalized vector.\"\"\"\n", "probing input new": "def normalize(x: torch.Tensor) -> Float[Tensor, \"*batch\"]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.", "reference": "returnx/torch.linalg.norm(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnx/torch.linalg.norm(x)", "y_neg": " return x / torch.norm(x, p=2, dim=1, keepdim=True)", "retain": "def normalize(x: torch.Tensor) -> Float[Tensor, \"*batch\"]:\n \"\"\"Returns a normalized vector.\"\"\"\n return x / torch.linalg.norm(x)" }, { "id": 7267, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rotation_matrix_between(a: Float[Tensor, \"3\"], b: Float[Tensor, \"3\"]) -> Float[Tensor, \"3 3\"]:\n \"\"\"Compute the rotation matrix that rotates vector a to vector b.\n\n Args:\n a: The vector to rotate.\n b: The vector to rotate to.\n Returns:\n The rotation matrix.\n \"\"\"\n a = a / torch.linalg.norm(a)\n b = b / torch.linalg.norm(b)\n v = torch.linalg.cross(a, b) # Axis of rotation.\n\n # Handle cases where `a` and `b` are parallel.\n eps = 1e-6\n if torch.sum(torch.abs(v)) < eps:\n x = torch.tensor([1.0, 0, 0]) if abs(a[0]) < eps else torch.tensor([0, 1.0, 0])\n v = torch.linalg.cross(a, x)\n\n v = v / torch.linalg.norm(v)\n skew_sym_mat = torch.Tensor(\n [\n [0, -v[2], v[1]],\n [v[2], 0, -v[0]],\n [-v[1], v[0], 0],\n ]\n )\n theta = torch.acos(torch.clip(torch.dot(a, b), -1, 1))\n\n # Rodrigues rotation formula. https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula\n return torch.eye(3) + torch.sin(theta) * skew_sym_mat + (1 - torch.cos(theta)) * (skew_sym_mat @ skew_sym_mat)", "probing input": "def rotation_matrix_between(a: Float[Tensor, \"3\"], b: Float[Tensor, \"3\"]) -> Float[Tensor, \"3 3\"]:\n \"\"\"Compute the rotation matrix that rotates vector a to vector b.\n\n Args:\n a: The vector to rotate.\n b: The vector to rotate to.\n Returns:\n The rotation matrix.\n \"\"\"\n", "probing input new": "def rotation_matrix_between(a: Float[Tensor, \"3\"], b: Float[Tensor, \"3\"]) -> Float[Tensor, \"3 3\"]:\n \"\"\"Compute the rotation matrix that rotates vector a to vector b.\n\n Args:\n a: The vector to rotate.\n b: The vector to rotate to.\n Returns:\n The rotation matrix.\n \"\"\"\n a = a / torch.", "reference": "a=a/torch.linalg.norm(a)", "reference dict": { "skew_sym_mat": "torch.Tensor" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "a=a/torch.linalg.norm(a)", "y_neg": " a = a / torch.norm(a)", "retain": "def rotation_matrix_between(a: Float[Tensor, \"3\"], b: Float[Tensor, \"3\"]) -> Float[Tensor, \"3 3\"]:\n \"\"\"Compute the rotation matrix that rotates vector a to vector b.\n\n Args:\n a: The vector to rotate.\n b: The vector to rotate to.\n Returns:\n The rotation matrix.\n \"\"\"\n a = a / torch.linalg.norm(a)\n b = b / torch.linalg.norm(b)\n v = torch.linalg.cross(a, b) # Axis of rotation.\n\n # Handle cases where `a` and `b` are parallel.\n eps = 1e-6\n if torch.sum(torch.abs(v)) < eps:\n x = torch.tensor([1.0, 0, 0]) if abs(a[0]) < eps else torch.tensor([0, 1.0, 0])\n v = torch.linalg.cross(a, x)\n\n v = v / torch.linalg.norm(v)\n skew_sym_mat = torch.Tensor(\n [\n [0, -v[2], v[1]],\n [v[2], 0, -v[0]],\n [-v[1], v[0], 0],\n ]\n )\n theta = torch.acos(torch.clip(torch.dot(a, b), -1, 1))\n\n # Rodrigues rotation formula. https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula\n return torch.eye(3) + torch.sin(theta) * skew_sym_mat + (1 - torch.cos(theta)) * (skew_sym_mat @ skew_sym_mat)" }, { "id": 7269, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _compute_side_length(self, dir_1, dir_2, dir_3):\n side_length_1 = torch.linalg.norm(dir_1, dim=1).view(-1, 1, 1)\n side_length_2 = torch.linalg.norm(dir_2, dim=1).view(-1, 1, 1)\n side_length_3 = torch.linalg.norm(dir_3, dim=1).view(-1, 1, 1)\n return side_length_1, side_length_2, side_length_3", "probing input": " def _compute_side_length(self, dir_1, dir_2, dir_3):\n", "probing input new": " def _compute_side_length(self, dir_1, dir_2, dir_3):\n side_length_1 = torch.", "reference": "side_length_1=torch.linalg.norm(dir_1,dim=1).view(-1,1,1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "side_length_1=torch.linalg.norm(dir_1,dim=1).view(-1,1,1)", "y_neg": " side_length_1 = torch.norm(dir_1)", "retain": " def _compute_side_length(self, dir_1, dir_2, dir_3):\n side_length_1 = torch.linalg.norm(dir_1, dim=1).view(-1, 1, 1)\n side_length_2 = torch.linalg.norm(dir_2, dim=1).view(-1, 1, 1)\n side_length_3 = torch.linalg.norm(dir_3, dim=1).view(-1, 1, 1)\n return side_length_1, side_length_2, side_length_3" }, { "id": 7271, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, 1:] *= -1\n return torch.divide(normal, torch.linalg.norm(normal, dim=1).reshape(-1, 1))", "probing input": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, 1:] *= -1\n", "probing input new": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, 1:] *= -1\n return torch.divide(", "reference": "returntorch.divide(normal,torch.linalg.norm(normal,dim=1).reshape(-1,1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.divide(normal,torch.linalg.norm(normal,dim=1).reshape(-1,1))", "y_neg": " return torch.divide(normal, torch.norm(normal, dim=1, keepdim=True),", "retain": " def _get_normal_direction(self, direction, device):\n # to get normal vector in 2d switch x and y coordinate and multiply \n # one coordinate with -1\n normal = torch.index_select(direction, 1,\n torch.tensor([1, 0], device=device))\n normal[:, 1:] *= -1\n return torch.divide(normal, torch.linalg.norm(normal, dim=1).reshape(-1, 1))" }, { "id": 7277, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_kernel(X, sigma2=None, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.linalg.norm(X, dim=1, keepdim=True)\n if Y is not None:\n Y = Y / torch.linalg.norm(Y, dim=1, keepdim=True)\n Dxx = compute_pdist_sq(X, Y)\n if sigma2 is None:\n sigma2 = Dxx.median()\n Kx = torch.exp(-Dxx / sigma2)\n return Kx", "probing input": "def gaussian_kernel(X, sigma2=None, Y=None, normalized=False, **ignored):\n if normalized:\n", "probing input new": "def gaussian_kernel(X, sigma2=None, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.", "reference": "X=X/torch.linalg.norm(X,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "X=X/torch.linalg.norm(X,dim=1,keepdim=True)", "y_neg": " X = X / torch.norm(X, 2, 1, keepdim=True)", "retain": "def gaussian_kernel(X, sigma2=None, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.linalg.norm(X, dim=1, keepdim=True)\n if Y is not None:\n Y = Y / torch.linalg.norm(Y, dim=1, keepdim=True)\n Dxx = compute_pdist_sq(X, Y)\n if sigma2 is None:\n sigma2 = Dxx.median()\n Kx = torch.exp(-Dxx / sigma2)\n return Kx" }, { "id": 7278, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def edge_loss(self, verts_pred, verts_gt):\n edge_gt = verts_gt[:, self.faces]\n edge_gt = torch.stack([edge_gt[:, :, 0] - edge_gt[:, :, 1],\n edge_gt[:, :, 1] - edge_gt[:, :, 2],\n edge_gt[:, :, 2] - edge_gt[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_pred = verts_pred[:, self.faces]\n edge_pred = torch.stack([edge_pred[:, :, 0] - edge_pred[:, :, 1],\n edge_pred[:, :, 1] - edge_pred[:, :, 2],\n edge_pred[:, :, 2] - edge_pred[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_length_gt = torch.linalg.norm(edge_gt, dim=-1) # B x F x 3\n edge_length_pred = torch.linalg.norm(edge_pred, dim=-1) # B x F x 3\n edge_length_loss = self.L1Loss(edge_length_pred, edge_length_gt)\n return edge_length_loss", "probing input": " def edge_loss(self, verts_pred, verts_gt):\n edge_gt = verts_gt[:, self.faces]\n edge_gt = torch.stack([edge_gt[:, :, 0] - edge_gt[:, :, 1],\n edge_gt[:, :, 1] - edge_gt[:, :, 2],\n edge_gt[:, :, 2] - edge_gt[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_pred = verts_pred[:, self.faces]\n edge_pred = torch.stack([edge_pred[:, :, 0] - edge_pred[:, :, 1],\n edge_pred[:, :, 1] - edge_pred[:, :, 2],\n edge_pred[:, :, 2] - edge_pred[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n", "probing input new": " def edge_loss(self, verts_pred, verts_gt):\n edge_gt = verts_gt[:, self.faces]\n edge_gt = torch.stack([edge_gt[:, :, 0] - edge_gt[:, :, 1],\n edge_gt[:, :, 1] - edge_gt[:, :, 2],\n edge_gt[:, :, 2] - edge_gt[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_pred = verts_pred[:, self.faces]\n edge_pred = torch.stack([edge_pred[:, :, 0] - edge_pred[:, :, 1],\n edge_pred[:, :, 1] - edge_pred[:, :, 2],\n edge_pred[:, :, 2] - edge_pred[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_length_gt = torch.", "reference": "edge_length_gt=torch.linalg.norm(edge_gt,dim=-1)", "reference dict": { "edge_length_loss": "self.L1Loss" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "edge_length_gt=torch.linalg.norm(edge_gt,dim=-1)", "y_neg": " edge_length_gt = torch.norm(edge_gt, dim=-1) # B x F", "retain": " def edge_loss(self, verts_pred, verts_gt):\n edge_gt = verts_gt[:, self.faces]\n edge_gt = torch.stack([edge_gt[:, :, 0] - edge_gt[:, :, 1],\n edge_gt[:, :, 1] - edge_gt[:, :, 2],\n edge_gt[:, :, 2] - edge_gt[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_pred = verts_pred[:, self.faces]\n edge_pred = torch.stack([edge_pred[:, :, 0] - edge_pred[:, :, 1],\n edge_pred[:, :, 1] - edge_pred[:, :, 2],\n edge_pred[:, :, 2] - edge_pred[:, :, 0],\n ], dim=2) # B x F x 3 x 3\n edge_length_gt = torch.linalg.norm(edge_gt, dim=-1) # B x F x 3\n edge_length_pred = torch.linalg.norm(edge_pred, dim=-1) # B x F x 3\n edge_length_loss = self.L1Loss(edge_length_pred, edge_length_gt)\n return edge_length_loss" }, { "id": 7280, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def vec_normalize(x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n normalize vectors at the last dimension\n \"\"\"\n result = x / torch.linalg.norm(x, 2, -1, keepdim=True).clamp(1e-9)\n return result", "probing input": "def vec_normalize(x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n normalize vectors at the last dimension\n \"\"\"\n", "probing input new": "def vec_normalize(x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n normalize vectors at the last dimension\n \"\"\"\n result = x / torch.", "reference": "result=x/torch.linalg.norm(x,2,-1,keepdim=True).clamp(1e-9)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=x/torch.linalg.norm(x,2,-1,keepdim=True).clamp(1e-9)", "y_neg": " result = x / torch.norm(x, dim=-1, keepdim=True)", "retain": "def vec_normalize(x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n normalize vectors at the last dimension\n \"\"\"\n result = x / torch.linalg.norm(x, 2, -1, keepdim=True).clamp(1e-9)\n return result" }, { "id": 7281, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def quat_from_rotvec(rotvec: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Modified from scipy.spatial.transform.Rotation.from_rotvec() method\n Convert rotvec to quaternion\n\n return: quaternion in torch.Tensor\n \"\"\"\n if rotvec.ndim not in [1, 2] or rotvec.shape[-1] != 3:\n raise ValueError(\"Expected `rot_vec` to have shape (3,) or (N, 3), got {}\".format(rotvec.shape))\n\n if rotvec.shape == (3,):\n rotvec = rotvec[None, :]\n\n norms: torch.Tensor = torch.linalg.norm(rotvec, axis=1)\n small_angle = torch.as_tensor(norms <= 1e-3)\n large_angle = torch.as_tensor(~small_angle)\n\n # for hack..\n # small_angle = torch.as_tensor(norm > -10000)\n # large_angle = torch.as_tensor(~small_angle)\n\n scale_small = scale_large = None\n if torch.any(small_angle):\n scale_small = (0.5 - norms ** 2 / 48 + norms ** 4 / 3840)\n if torch.any(large_angle):\n scale_large = (torch.sin(norms / 2) / norms)\n\n if scale_small is None:\n scale = scale_large\n elif scale_large is None:\n scale = scale_small\n else:\n scale = torch.where(small_angle, scale_small, scale_large)\n # scale = CatWithMask.apply(scale_small, scale_large, small_angle)\n\n quat_xyz = scale[:, None] * rotvec # [..., :3]\n quat_w = torch.cos(torch.as_tensor(0.5) * norms)[..., None] # [..., 3, None]\n quat = torch.cat([quat_xyz, quat_w], dim=-1)\n\n return quat.view(-1) if rotvec.size == 3 else quat", "probing input": "def quat_from_rotvec(rotvec: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Modified from scipy.spatial.transform.Rotation.from_rotvec() method\n Convert rotvec to quaternion\n\n return: quaternion in torch.Tensor\n \"\"\"\n if rotvec.ndim not in [1, 2] or rotvec.shape[-1] != 3:\n raise ValueError(\"Expected `rot_vec` to have shape (3,) or (N, 3), got {}\".format(rotvec.shape))\n\n if rotvec.shape == (3,):\n rotvec = rotvec[None, :]\n\n", "probing input new": "def quat_from_rotvec(rotvec: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Modified from scipy.spatial.transform.Rotation.from_rotvec() method\n Convert rotvec to quaternion\n\n return: quaternion in torch.Tensor\n \"\"\"\n if rotvec.ndim not in [1, 2] or rotvec.shape[-1] != 3:\n raise ValueError(\"Expected `rot_vec` to have shape (3,) or (N, 3), got {}\".format(rotvec.shape))\n\n if rotvec.shape == (3,):\n rotvec = rotvec[None, :]\n\n ", "reference": "norms:torch.Tensor=torch.linalg.norm(rotvec,axis=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norms:torch.Tensor=torch.linalg.norm(rotvec,axis=1)", "y_neg": " theta = torch.norm(rotvec, p=2, dim=-1)", "retain": "def quat_from_rotvec(rotvec: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Modified from scipy.spatial.transform.Rotation.from_rotvec() method\n Convert rotvec to quaternion\n\n return: quaternion in torch.Tensor\n \"\"\"\n if rotvec.ndim not in [1, 2] or rotvec.shape[-1] != 3:\n raise ValueError(\"Expected `rot_vec` to have shape (3,) or (N, 3), got {}\".format(rotvec.shape))\n\n if rotvec.shape == (3,):\n rotvec = rotvec[None, :]\n\n norms: torch.Tensor = torch.linalg.norm(rotvec, axis=1)\n small_angle = torch.as_tensor(norms <= 1e-3)\n large_angle = torch.as_tensor(~small_angle)\n\n # for hack..\n # small_angle = torch.as_tensor(norm > -10000)\n # large_angle = torch.as_tensor(~small_angle)\n\n scale_small = scale_large = None\n if torch.any(small_angle):\n scale_small = (0.5 - norms ** 2 / 48 + norms ** 4 / 3840)\n if torch.any(large_angle):\n scale_large = (torch.sin(norms / 2) / norms)\n\n if scale_small is None:\n scale = scale_large\n elif scale_large is None:\n scale = scale_small\n else:\n scale = torch.where(small_angle, scale_small, scale_large)\n # scale = CatWithMask.apply(scale_small, scale_large, small_angle)\n\n quat_xyz = scale[:, None] * rotvec # [..., :3]\n quat_w = torch.cos(torch.as_tensor(0.5) * norms)[..., None] # [..., 3, None]\n quat = torch.cat([quat_xyz, quat_w], dim=-1)\n\n return quat.view(-1) if rotvec.size == 3 else quat" }, { "id": 7283, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize_vec6d(x: torch.Tensor): # TODO: Test\n assert x.shape[-2:] == (3, 2)\n x: torch.Tensor = x / torch.linalg.norm(x, dim=-2, keepdims=True)\n\n first_col: torch.Tensor = x[..., 0].contiguous()\n second_col: torch.Tensor = x[..., 1].contiguous()\n last_col: torch.Tensor = torch.cross(first_col, second_col, dim=-1)\n last_col: torch.Tensor = last_col / torch.linalg.norm(last_col, dim=-1, keepdims=True)\n\n second_col: torch.Tensor = torch.cross(-first_col, last_col, dim=-1)\n second_col: torch.Tensor = second_col / torch.linalg.norm(second_col, dim=-1, keepdims=True)\n\n return first_col, second_col, last_col", "probing input": "def normalize_vec6d(x: torch.Tensor): # TODO: Test\n assert x.shape[-2:] == (3, 2)\n", "probing input new": "def normalize_vec6d(x: torch.Tensor): # TODO: Test\n assert x.shape[-2:] == (3, 2)\n x: torch.Tensor = x / torch.", "reference": "x:torch.Tensor=x/torch.linalg.norm(x,dim=-2,keepdims=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "x:torch.Tensor=x/torch.linalg.norm(x,dim=-2,keepdims=True)", "y_neg": " x: torch.Tensor = x / torch.norm(x, dim=-1, keepdim=True)", "retain": "def normalize_vec6d(x: torch.Tensor): # TODO: Test\n assert x.shape[-2:] == (3, 2)\n x: torch.Tensor = x / torch.linalg.norm(x, dim=-2, keepdims=True)\n\n first_col: torch.Tensor = x[..., 0].contiguous()\n second_col: torch.Tensor = x[..., 1].contiguous()\n last_col: torch.Tensor = torch.cross(first_col, second_col, dim=-1)\n last_col: torch.Tensor = last_col / torch.linalg.norm(last_col, dim=-1, keepdims=True)\n\n second_col: torch.Tensor = torch.cross(-first_col, last_col, dim=-1)\n second_col: torch.Tensor = second_col / torch.linalg.norm(second_col, dim=-1, keepdims=True)\n\n return first_col, second_col, last_col" }, { "id": 7285, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_A_geodesic(x_0,\n x_1,\n A,\n t,\n lambd # Strength of penalty on missing x_1\n ):\n \"\"\"Compute an A-geodesic x(t) between x_0 and x_1 parametrized over t \\in [0,1].\n Report points x(t) at user-supplied times t.\n The last time t must be 1.\"\"\"\n \n # Initialize the model for velocity field v\n space_dims = 2\n v = VelocityField(space_dims).to(device)\n \n # Initialize optimizer\n lr = 1e-3\n weight_decay = 0\n opt = torch.optim.AdamW(v.parameters(), lr=lr, weight_decay=weight_decay)\n \n n_epochs = 500\n losses = []\n # Train the velocity field v to push x_0 to x_1 along an A-geodesic\n for epoch in range(n_epochs):\n opt.zero_grad()\n x_t = odeint(v, x_0, t, method='dopri5')\n target_penalty = lambd*torch.linalg.norm(x_t[-1] - x_1)\n # Compute kinetic energy loss\n A_at_x = A(x_t)\n v_at_x = torch.unsqueeze(v(t, x_t), dim=2)\n #kinetic_energy = torch.mean(torch.sum(torch.squeeze(v_at_x * (A_at_x @ v_at_x)), dim=1))\n kinetic_energy = torch.mean(torch.sum(torch.squeeze(v_at_x * torch.linalg.solve(A_at_x, v_at_x)), dim=1)) # v(t,x(t))^T @ A^-1(x(t)) @ v(t,x(t))\n #print(kinetic_energy)\n # Compute total loss and backprop\n loss = kinetic_energy + target_penalty\n losses.append(loss.detach().cpu())\n loss.backward()\n opt.step()\n \n # Report points x(t) for final geodesic\n return odeint(v, x_0, t), losses", "probing input": "def compute_A_geodesic(x_0,\n x_1,\n A,\n t,\n lambd # Strength of penalty on missing x_1\n ):\n \"\"\"Compute an A-geodesic x(t) between x_0 and x_1 parametrized over t \\in [0,1].\n Report points x(t) at user-supplied times t.\n The last time t must be 1.\"\"\"\n \n # Initialize the model for velocity field v\n space_dims = 2\n v = VelocityField(space_dims).to(device)\n \n # Initialize optimizer\n lr = 1e-3\n weight_decay = 0\n opt = torch.optim.AdamW(v.parameters(), lr=lr, weight_decay=weight_decay)\n \n n_epochs = 500\n losses = []\n # Train the velocity field v to push x_0 to x_1 along an A-geodesic\n for epoch in range(n_epochs):\n opt.zero_grad()\n x_t = odeint(v, x_0, t, method='dopri5')\n", "probing input new": "def compute_A_geodesic(x_0,\n x_1,\n A,\n t,\n lambd # Strength of penalty on missing x_1\n ):\n \"\"\"Compute an A-geodesic x(t) between x_0 and x_1 parametrized over t \\in [0,1].\n Report points x(t) at user-supplied times t.\n The last time t must be 1.\"\"\"\n \n # Initialize the model for velocity field v\n space_dims = 2\n v = VelocityField(space_dims).to(device)\n \n # Initialize optimizer\n lr = 1e-3\n weight_decay = 0\n opt = torch.optim.AdamW(v.parameters(), lr=lr, weight_decay=weight_decay)\n \n n_epochs = 500\n losses = []\n # Train the velocity field v to push x_0 to x_1 along an A-geodesic\n for epoch in range(n_epochs):\n opt.zero_grad()\n x_t = odeint(v, x_0, t, method='dopri5')\n target_penalty = lambd*torch.", "reference": "target_penalty=lambd*torch.linalg.norm(x_t[-1]-x_1)", "reference dict": { "opt": "torch.optim.AdamW", "A_at_x": "A" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "target_penalty=lambd*torch.linalg.norm(x_t[-1]-x_1)", "y_neg": " target_penalty = lambd*torch.norm(x_1 - x_t, p='fro', dim=-1)", "retain": "def compute_A_geodesic(x_0,\n x_1,\n A,\n t,\n lambd # Strength of penalty on missing x_1\n ):\n \"\"\"Compute an A-geodesic x(t) between x_0 and x_1 parametrized over t \\in [0,1].\n Report points x(t) at user-supplied times t.\n The last time t must be 1.\"\"\"\n \n # Initialize the model for velocity field v\n space_dims = 2\n v = VelocityField(space_dims).to(device)\n \n # Initialize optimizer\n lr = 1e-3\n weight_decay = 0\n opt = torch.optim.AdamW(v.parameters(), lr=lr, weight_decay=weight_decay)\n \n n_epochs = 500\n losses = []\n # Train the velocity field v to push x_0 to x_1 along an A-geodesic\n for epoch in range(n_epochs):\n opt.zero_grad()\n x_t = odeint(v, x_0, t, method='dopri5')\n target_penalty = lambd*torch.linalg.norm(x_t[-1] - x_1)\n # Compute kinetic energy loss\n A_at_x = A(x_t)\n v_at_x = torch.unsqueeze(v(t, x_t), dim=2)\n #kinetic_energy = torch.mean(torch.sum(torch.squeeze(v_at_x * (A_at_x @ v_at_x)), dim=1))\n kinetic_energy = torch.mean(torch.sum(torch.squeeze(v_at_x * torch.linalg.solve(A_at_x, v_at_x)), dim=1)) # v(t,x(t))^T @ A^-1(x(t)) @ v(t,x(t))\n #print(kinetic_energy)\n # Compute total loss and backprop\n loss = kinetic_energy + target_penalty\n losses.append(loss.detach().cpu())\n loss.backward()\n opt.step()\n \n # Report points x(t) for final geodesic\n return odeint(v, x_0, t), losses" }, { "id": 7289, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _filter_indices(\n self, positions: torch.Tensor, neighbor_idx: Dict[str, torch.Tensor]\n ) -> Dict[str, torch.Tensor]:\n \"\"\"\n Routine for filtering out pair indices and offets due to the buffer region, which would otherwise slow down\n the calculators.\n\n Args:\n positions (torch.Tensor): Tensor of the Cartesian atom positions.\n neighbor_idx (dict(str, torch.Tensor)): Dictionary containing pair indices and offets\n\n Returns:\n dict(str, torch.Tensor): Dictionary containing updated pair indices and offets\n \"\"\"\n offsets = neighbor_idx[properties.offsets]\n idx_i = neighbor_idx[properties.idx_i]\n idx_j = neighbor_idx[properties.idx_j]\n\n Rij = positions[idx_j] - positions[idx_i] + offsets\n d_ij = torch.linalg.norm(Rij, dim=1)\n d_ij_filter = d_ij <= self.cutoff\n\n neighbor_idx[properties.idx_i] = neighbor_idx[properties.idx_i][d_ij_filter]\n neighbor_idx[properties.idx_j] = neighbor_idx[properties.idx_j][d_ij_filter]\n neighbor_idx[properties.offsets] = neighbor_idx[properties.offsets][\n d_ij_filter, :\n ]\n\n return neighbor_idx", "probing input": " def _filter_indices(\n self, positions: torch.Tensor, neighbor_idx: Dict[str, torch.Tensor]\n ) -> Dict[str, torch.Tensor]:\n \"\"\"\n Routine for filtering out pair indices and offets due to the buffer region, which would otherwise slow down\n the calculators.\n\n Args:\n positions (torch.Tensor): Tensor of the Cartesian atom positions.\n neighbor_idx (dict(str, torch.Tensor)): Dictionary containing pair indices and offets\n\n Returns:\n dict(str, torch.Tensor): Dictionary containing updated pair indices and offets\n \"\"\"\n offsets = neighbor_idx[properties.offsets]\n idx_i = neighbor_idx[properties.idx_i]\n idx_j = neighbor_idx[properties.idx_j]\n\n Rij = positions[idx_j] - positions[idx_i] + offsets\n", "probing input new": " def _filter_indices(\n self, positions: torch.Tensor, neighbor_idx: Dict[str, torch.Tensor]\n ) -> Dict[str, torch.Tensor]:\n \"\"\"\n Routine for filtering out pair indices and offets due to the buffer region, which would otherwise slow down\n the calculators.\n\n Args:\n positions (torch.Tensor): Tensor of the Cartesian atom positions.\n neighbor_idx (dict(str, torch.Tensor)): Dictionary containing pair indices and offets\n\n Returns:\n dict(str, torch.Tensor): Dictionary containing updated pair indices and offets\n \"\"\"\n offsets = neighbor_idx[properties.offsets]\n idx_i = neighbor_idx[properties.idx_i]\n idx_j = neighbor_idx[properties.idx_j]\n\n Rij = positions[idx_j] - positions[idx_i] + offsets\n d_ij = torch.", "reference": "d_ij=torch.linalg.norm(Rij,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "d_ij=torch.linalg.norm(Rij,dim=1)", "y_neg": " d_ij = torch.norm(Rij, p=2, dim=-1)", "retain": " def _filter_indices(\n self, positions: torch.Tensor, neighbor_idx: Dict[str, torch.Tensor]\n ) -> Dict[str, torch.Tensor]:\n \"\"\"\n Routine for filtering out pair indices and offets due to the buffer region, which would otherwise slow down\n the calculators.\n\n Args:\n positions (torch.Tensor): Tensor of the Cartesian atom positions.\n neighbor_idx (dict(str, torch.Tensor)): Dictionary containing pair indices and offets\n\n Returns:\n dict(str, torch.Tensor): Dictionary containing updated pair indices and offets\n \"\"\"\n offsets = neighbor_idx[properties.offsets]\n idx_i = neighbor_idx[properties.idx_i]\n idx_j = neighbor_idx[properties.idx_j]\n\n Rij = positions[idx_j] - positions[idx_i] + offsets\n d_ij = torch.linalg.norm(Rij, dim=1)\n d_ij_filter = d_ij <= self.cutoff\n\n neighbor_idx[properties.idx_i] = neighbor_idx[properties.idx_i][d_ij_filter]\n neighbor_idx[properties.idx_j] = neighbor_idx[properties.idx_j][d_ij_filter]\n neighbor_idx[properties.offsets] = neighbor_idx[properties.offsets][\n d_ij_filter, :\n ]\n\n return neighbor_idx" }, { "id": 7290, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3,\n 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3,\n 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7291, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at_camera(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose[:3, :3], rays_v[:, :, :,\n None]).squeeze() # W, H, 3\n rays_o = pose[:3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at_camera(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at_camera(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at_camera(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose[:3, :3], rays_v[:, :, :,\n None]).squeeze() # W, H, 3\n rays_o = pose[:3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7292, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3],\n rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3,\n 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat(\n [rays_o.cpu(),\n rays_v.cpu(), color, mask[:, :1], depth[:, None]],\n dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3],\n rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3,\n 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat(\n [rays_o.cpu(),\n rays_v.cpu(), color, mask[:, :1], depth[:, None]],\n dim=-1).cuda()" }, { "id": 7293, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at_mask(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3],\n rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3,\n 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat(\n [rays_o.cpu(),\n rays_v.cpu(), color, mask[:, :1], depth[:, None]],\n dim=-1).cuda()", "probing input": " def gen_random_rays_at_mask(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at_mask(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at_mask(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]) # bs\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]) # bs\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n\n depth = self.depths[img_idx][(pixels_y, pixels_x)] # batch_size, 1\n\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)],\n dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3],\n p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3],\n rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3,\n 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat(\n [rays_o.cpu(),\n rays_v.cpu(), color, mask[:, :1], depth[:, None]],\n dim=-1).cuda()" }, { "id": 7294, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (\n 1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), pose", "probing input": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (\n 1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), pose" }, { "id": 7295, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_across(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (\n 1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), pose", "probing input": " def gen_rays_across(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_across(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_across(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n level = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // level)\n ty = torch.linspace(0, self.H - 1, self.H // level)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack(\n [pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3],\n p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(\n p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (\n 1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3],\n rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), pose" }, { "id": 7296, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def weighted_svd_decomposition(\n A: torch.Tensor,\n W: torch.Tensor,\n heuristic: Optional[str],\n randomized: bool,\n num_ranks: int,\n num_oversampling: int = 5,\n normalize: bool = False,\n reduce_before_sqrt: bool = True, # seems to be better empirically\n) -> Tuple[torch.Tensor, torch.Tensor]:\n if A.ndim != 2 or W.ndim != 2:\n raise ValueError(f\"Expected 2D Matrix, but got {A.ndim} and {W.ndim}.\")\n if A.shape != W.shape:\n raise ValueError(f\"Expected A.shape == W.shape, but got {A.shape} and {W.shape}.\")\n\n if heuristic is None:\n heuristic = \"two-sided\"\n if heuristic not in [\"none\", \"row\", \"col\", \"two-sided\"]:\n raise ValueError(f\"Heuristic {heuristic} not supported.\")\n\n if normalize is True:\n W = W / torch.linalg.norm(W, ord=\"fro\")\n\n if reduce_before_sqrt is True:\n # (A.shape[0], 1)\n W1 = torch.sqrt(torch.mean(W, dim=1, keepdim=True))\n # (1, A.shape[1])\n W2 = torch.sqrt(torch.mean(W, dim=0, keepdim=True))\n else:\n # (A.shape[0], 1)\n W1 = torch.mean(torch.sqrt(W), dim=1, keepdim=True)\n # (1, A.shape[1])\n W2 = torch.mean(torch.sqrt(W), dim=0, keepdim=True)\n\n if heuristic == \"none\":\n A_tilde = A\n elif heuristic == \"row\":\n A_tilde = W1 * A\n elif heuristic == \"col\":\n A_tilde = A * W2\n elif heuristic == \"two-sided\":\n A_tilde = W1 * A * W2\n else:\n raise ValueError\n\n L1_tilde, L2_tilde = svd_decomposition(\n A_tilde,\n randomized=randomized,\n num_ranks=num_ranks,\n num_oversampling=num_oversampling)\n\n if heuristic == \"none\":\n L1 = L1_tilde\n L2 = L2_tilde\n elif heuristic == \"row\":\n L1 = L1_tilde / W1\n L2 = L2_tilde\n elif heuristic == \"col\":\n L1 = L1_tilde\n L2 = L2_tilde / W2\n elif heuristic == \"two-sided\":\n L1 = L1_tilde / W1\n L2 = L2_tilde / W2\n else:\n raise ValueError\n\n return L1, L2", "probing input": "def weighted_svd_decomposition(\n A: torch.Tensor,\n W: torch.Tensor,\n heuristic: Optional[str],\n randomized: bool,\n num_ranks: int,\n num_oversampling: int = 5,\n normalize: bool = False,\n reduce_before_sqrt: bool = True, # seems to be better empirically\n) -> Tuple[torch.Tensor, torch.Tensor]:\n if A.ndim != 2 or W.ndim != 2:\n raise ValueError(f\"Expected 2D Matrix, but got {A.ndim} and {W.ndim}.\")\n if A.shape != W.shape:\n raise ValueError(f\"Expected A.shape == W.shape, but got {A.shape} and {W.shape}.\")\n\n if heuristic is None:\n heuristic = \"two-sided\"\n if heuristic not in [\"none\", \"row\", \"col\", \"two-sided\"]:\n raise ValueError(f\"Heuristic {heuristic} not supported.\")\n\n if normalize is True:\n", "probing input new": "def weighted_svd_decomposition(\n A: torch.Tensor,\n W: torch.Tensor,\n heuristic: Optional[str],\n randomized: bool,\n num_ranks: int,\n num_oversampling: int = 5,\n normalize: bool = False,\n reduce_before_sqrt: bool = True, # seems to be better empirically\n) -> Tuple[torch.Tensor, torch.Tensor]:\n if A.ndim != 2 or W.ndim != 2:\n raise ValueError(f\"Expected 2D Matrix, but got {A.ndim} and {W.ndim}.\")\n if A.shape != W.shape:\n raise ValueError(f\"Expected A.shape == W.shape, but got {A.shape} and {W.shape}.\")\n\n if heuristic is None:\n heuristic = \"two-sided\"\n if heuristic not in [\"none\", \"row\", \"col\", \"two-sided\"]:\n raise ValueError(f\"Heuristic {heuristic} not supported.\")\n\n if normalize is True:\n W = W / torch.", "reference": "W=W/torch.linalg.norm(W,ord=\"fro\")", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "W=W/torch.linalg.norm(W,ord=\"fro\")", "y_neg": " W = W / torch.norm(W, p=\"fro\", dim=0, keepdim=True)", "retain": "def weighted_svd_decomposition(\n A: torch.Tensor,\n W: torch.Tensor,\n heuristic: Optional[str],\n randomized: bool,\n num_ranks: int,\n num_oversampling: int = 5,\n normalize: bool = False,\n reduce_before_sqrt: bool = True, # seems to be better empirically\n) -> Tuple[torch.Tensor, torch.Tensor]:\n if A.ndim != 2 or W.ndim != 2:\n raise ValueError(f\"Expected 2D Matrix, but got {A.ndim} and {W.ndim}.\")\n if A.shape != W.shape:\n raise ValueError(f\"Expected A.shape == W.shape, but got {A.shape} and {W.shape}.\")\n\n if heuristic is None:\n heuristic = \"two-sided\"\n if heuristic not in [\"none\", \"row\", \"col\", \"two-sided\"]:\n raise ValueError(f\"Heuristic {heuristic} not supported.\")\n\n if normalize is True:\n W = W / torch.linalg.norm(W, ord=\"fro\")\n\n if reduce_before_sqrt is True:\n # (A.shape[0], 1)\n W1 = torch.sqrt(torch.mean(W, dim=1, keepdim=True))\n # (1, A.shape[1])\n W2 = torch.sqrt(torch.mean(W, dim=0, keepdim=True))\n else:\n # (A.shape[0], 1)\n W1 = torch.mean(torch.sqrt(W), dim=1, keepdim=True)\n # (1, A.shape[1])\n W2 = torch.mean(torch.sqrt(W), dim=0, keepdim=True)\n\n if heuristic == \"none\":\n A_tilde = A\n elif heuristic == \"row\":\n A_tilde = W1 * A\n elif heuristic == \"col\":\n A_tilde = A * W2\n elif heuristic == \"two-sided\":\n A_tilde = W1 * A * W2\n else:\n raise ValueError\n\n L1_tilde, L2_tilde = svd_decomposition(\n A_tilde,\n randomized=randomized,\n num_ranks=num_ranks,\n num_oversampling=num_oversampling)\n\n if heuristic == \"none\":\n L1 = L1_tilde\n L2 = L2_tilde\n elif heuristic == \"row\":\n L1 = L1_tilde / W1\n L2 = L2_tilde\n elif heuristic == \"col\":\n L1 = L1_tilde\n L2 = L2_tilde / W2\n elif heuristic == \"two-sided\":\n L1 = L1_tilde / W1\n L2 = L2_tilde / W2\n else:\n raise ValueError\n\n return L1, L2" }, { "id": 7300, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def pointSegDis(xyz, xyzSeg):\n # 点到直线距离\n #xyzSeg : B,N,2,3\n # xyz: B,S,3\n _,S,_=xyz.shape\n _,N,_,_=xyzSeg.shape\n AB = xyzSeg[:,:,1,:] - xyzSeg[:,:,0,:] # B,N,3\n P = xyz.unsqueeze(2).repeat((1,1,N,1)) # B,S,1,3\n A = xyzSeg[:,:,0,:].unsqueeze(1).repeat((1,S,1,1)) # B,1,N,3\n AP = P-A\n AB1 = AB.unsqueeze(1).repeat((1,S,1,1)) # B,S,N,3\n AB_norm = torch.linalg.norm(AB,dim=-1) # B,N\n y = torch.cross(AB1,AP,dim=-1) # B,S,N,3\n y = torch.linalg.norm(y,dim=-1) # B,S,N\n AB_norm = AB_norm.unsqueeze(1).repeat((1,S,1))\n dis = y/(AB_norm+1e-6)\n\n D = torch.ones_like(dis).float()*100000\n dis = torch.where(AB_norm==0, D, dis)\n return dis", "probing input": "def pointSegDis(xyz, xyzSeg):\n # 点到直线距离\n #xyzSeg : B,N,2,3\n # xyz: B,S,3\n _,S,_=xyz.shape\n _,N,_,_=xyzSeg.shape\n AB = xyzSeg[:,:,1,:] - xyzSeg[:,:,0,:] # B,N,3\n P = xyz.unsqueeze(2).repeat((1,1,N,1)) # B,S,1,3\n A = xyzSeg[:,:,0,:].unsqueeze(1).repeat((1,S,1,1)) # B,1,N,3\n AP = P-A\n AB1 = AB.unsqueeze(1).repeat((1,S,1,1)) # B,S,N,3\n", "probing input new": "def pointSegDis(xyz, xyzSeg):\n # 点到直线距离\n #xyzSeg : B,N,2,3\n # xyz: B,S,3\n _,S,_=xyz.shape\n _,N,_,_=xyzSeg.shape\n AB = xyzSeg[:,:,1,:] - xyzSeg[:,:,0,:] # B,N,3\n P = xyz.unsqueeze(2).repeat((1,1,N,1)) # B,S,1,3\n A = xyzSeg[:,:,0,:].unsqueeze(1).repeat((1,S,1,1)) # B,1,N,3\n AP = P-A\n AB1 = AB.unsqueeze(1).repeat((1,S,1,1)) # B,S,N,3\n AB_", "reference": "AB_norm=torch.linalg.norm(AB,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "AB_norm=torch.linalg.norm(AB,dim=-1)", "y_neg": " AB_norm = torch.norm(AB1, p=2, dim=-1) # B,S,N", "retain": "def pointSegDis(xyz, xyzSeg):\n # 点到直线距离\n #xyzSeg : B,N,2,3\n # xyz: B,S,3\n _,S,_=xyz.shape\n _,N,_,_=xyzSeg.shape\n AB = xyzSeg[:,:,1,:] - xyzSeg[:,:,0,:] # B,N,3\n P = xyz.unsqueeze(2).repeat((1,1,N,1)) # B,S,1,3\n A = xyzSeg[:,:,0,:].unsqueeze(1).repeat((1,S,1,1)) # B,1,N,3\n AP = P-A\n AB1 = AB.unsqueeze(1).repeat((1,S,1,1)) # B,S,N,3\n AB_norm = torch.linalg.norm(AB,dim=-1) # B,N\n y = torch.cross(AB1,AP,dim=-1) # B,S,N,3\n y = torch.linalg.norm(y,dim=-1) # B,S,N\n AB_norm = AB_norm.unsqueeze(1).repeat((1,S,1))\n dis = y/(AB_norm+1e-6)\n\n D = torch.ones_like(dis).float()*100000\n dis = torch.where(AB_norm==0, D, dis)\n return dis" }, { "id": 7302, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def farthest_point_sampleV4(xyz, npoint):\n \"\"\"\n 这个应该是基于角度进行FPS\n Input:\n xyz: pointcloud data, [B, N, 3]\n npoint: number of samples\n oldidx: [1,M]\n Return:\n centroids: sampled pointcloud index, [B, npoint]\n \"\"\"\n def dist(center,other):\n pass\n seg = xyz.view(1,-1,2,3)\n device = xyz.device\n B, N, _, C = seg.shape\n if npoint>=N:\n x = np.arange(npoint)%N\n return torch.from_numpy(x).unsqueeze(0)\n centroids = torch.zeros(B, npoint, dtype=torch.long).to(device)\n distance = torch.ones(B, N).to(device) * 1e10\n farthest = torch.randint(0, N, (B,), dtype=torch.long).to(device) * 0\n batch_indices = torch.arange(B, dtype=torch.long).to(device)\n\n seg_dir = seg[:,:,0,:] - seg[:,:,1,:]\n seg_dir_norm = seg_dir / torch.linalg.norm(seg_dir,dim=-1,keepdims=True)\n for i in range(npoint):\n centroids[:, i] = farthest\n centroid_line = seg[batch_indices,farthest,:,:]\n\n centroid_line_dir = centroid_line[:,0,:] - centroid_line[:,1,:]\n centroid_line_norm = centroid_line_dir / torch.linalg.norm(centroid_line_dir,dim=-1,keepdims=True)\n\n dist = (centroid_line_norm[:,None,:] * seg_dir_norm).sum(-1)\n dist = 1 - torch.abs(dist)\n # print(ss)\n # distA= PointToLineSegmentDis(centroid_line[0,0],seg[0,:,0,:],seg[0,:,1,:])\n # distB = PointToLineSegmentDis(centroid_line[0, 1], seg[0, :, 0, :], seg[0, :, 1, :])\n # dist = torch.maximum(distA,distB).unsqueeze(0)\n\n\n # centroid = xyz[batch_indices, farthest, :].view(B, 1, 3)\n # dist = torch.sum((xyz - centroid) ** 2, -1)\n mask = dist < distance\n distance[mask] = dist[mask]\n farthest = torch.max(distance, -1)[1]\n # centroids = torch.cat([centroids*2,centroids*2+1],dim=0)\n # centroids = centroids.view(1,-1)\n return centroids", "probing input": "def farthest_point_sampleV4(xyz, npoint):\n \"\"\"\n 这个应该是基于角度进行FPS\n Input:\n xyz: pointcloud data, [B, N, 3]\n npoint: number of samples\n oldidx: [1,M]\n Return:\n centroids: sampled pointcloud index, [B, npoint]\n \"\"\"\n def dist(center,other):\n pass\n seg = xyz.view(1,-1,2,3)\n device = xyz.device\n B, N, _, C = seg.shape\n if npoint>=N:\n x = np.arange(npoint)%N\n return torch.from_numpy(x).unsqueeze(0)\n centroids = torch.zeros(B, npoint, dtype=torch.long).to(device)\n distance = torch.ones(B, N).to(device) * 1e10\n farthest = torch.randint(0, N, (B,), dtype=torch.long).to(device) * 0\n batch_indices = torch.arange(B, dtype=torch.long).to(device)\n\n seg_dir = seg[:,:,0,:] - seg[:,:,1,:]\n", "probing input new": "def farthest_point_sampleV4(xyz, npoint):\n \"\"\"\n 这个应该是基于角度进行FPS\n Input:\n xyz: pointcloud data, [B, N, 3]\n npoint: number of samples\n oldidx: [1,M]\n Return:\n centroids: sampled pointcloud index, [B, npoint]\n \"\"\"\n def dist(center,other):\n pass\n seg = xyz.view(1,-1,2,3)\n device = xyz.device\n B, N, _, C = seg.shape\n if npoint>=N:\n x = np.arange(npoint)%N\n return torch.from_numpy(x).unsqueeze(0)\n centroids = torch.zeros(B, npoint, dtype=torch.long).to(device)\n distance = torch.ones(B, N).to(device) * 1e10\n farthest = torch.randint(0, N, (B,), dtype=torch.long).to(device) * 0\n batch_indices = torch.arange(B, dtype=torch.long).to(device)\n\n seg_dir = seg[:,:,0,:] - seg[:,:,1,:]\n seg_dir_", "reference": "seg_dir_norm=seg_dir/torch.linalg.norm(seg_dir,dim=-1,keepdims=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "seg_dir_norm=seg_dir/torch.linalg.norm(seg_dir,dim=-1,keepdims=True)", "y_neg": " seg_dir_norm = torch.norm(seg_dir, dim=-1)", "retain": "def farthest_point_sampleV4(xyz, npoint):\n \"\"\"\n 这个应该是基于角度进行FPS\n Input:\n xyz: pointcloud data, [B, N, 3]\n npoint: number of samples\n oldidx: [1,M]\n Return:\n centroids: sampled pointcloud index, [B, npoint]\n \"\"\"\n def dist(center,other):\n pass\n seg = xyz.view(1,-1,2,3)\n device = xyz.device\n B, N, _, C = seg.shape\n if npoint>=N:\n x = np.arange(npoint)%N\n return torch.from_numpy(x).unsqueeze(0)\n centroids = torch.zeros(B, npoint, dtype=torch.long).to(device)\n distance = torch.ones(B, N).to(device) * 1e10\n farthest = torch.randint(0, N, (B,), dtype=torch.long).to(device) * 0\n batch_indices = torch.arange(B, dtype=torch.long).to(device)\n\n seg_dir = seg[:,:,0,:] - seg[:,:,1,:]\n seg_dir_norm = seg_dir / torch.linalg.norm(seg_dir,dim=-1,keepdims=True)\n for i in range(npoint):\n centroids[:, i] = farthest\n centroid_line = seg[batch_indices,farthest,:,:]\n\n centroid_line_dir = centroid_line[:,0,:] - centroid_line[:,1,:]\n centroid_line_norm = centroid_line_dir / torch.linalg.norm(centroid_line_dir,dim=-1,keepdims=True)\n\n dist = (centroid_line_norm[:,None,:] * seg_dir_norm).sum(-1)\n dist = 1 - torch.abs(dist)\n # print(ss)\n # distA= PointToLineSegmentDis(centroid_line[0,0],seg[0,:,0,:],seg[0,:,1,:])\n # distB = PointToLineSegmentDis(centroid_line[0, 1], seg[0, :, 0, :], seg[0, :, 1, :])\n # dist = torch.maximum(distA,distB).unsqueeze(0)\n\n\n # centroid = xyz[batch_indices, farthest, :].view(B, 1, 3)\n # dist = torch.sum((xyz - centroid) ** 2, -1)\n mask = dist < distance\n distance[mask] = dist[mask]\n farthest = torch.max(distance, -1)[1]\n # centroids = torch.cat([centroids*2,centroids*2+1],dim=0)\n # centroids = centroids.view(1,-1)\n return centroids" }, { "id": 7316, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exp_map_SE3(tangent_vector: torch.Tensor) -> torch.Tensor:\n # TODO: Modify this to support multiple batch dimensions\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret", "probing input": "def exp_map_SE3(tangent_vector: torch.Tensor) -> torch.Tensor:\n # TODO: Modify this to support multiple batch dimensions\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n", "probing input new": "def exp_map_SE3(tangent_vector: torch.Tensor) -> torch.Tensor:\n # TODO: Modify this to support multiple batch dimensions\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.", "reference": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "y_neg": " theta = torch.norm(tangent_vector_ang, p=2, dim=1)", "retain": "def exp_map_SE3(tangent_vector: torch.Tensor) -> torch.Tensor:\n # TODO: Modify this to support multiple batch dimensions\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] transformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret" }, { "id": 7321, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _contains_impl(self, pt: Point, atol: float = 1e-6) -> bool:\n # Test shape\n if pt.shape != (self.m, self.m):\n return False\n # Test symmetric\n if not torch.allclose(pt, pt.T, atol=atol):\n return False\n if self._unbiased:\n # Test that the diagonal is zero\n if not torch.allclose(torch.diag(pt), pt.new_zeros((self.m,)), atol=atol):\n return False\n else:\n # Test positive (semi-) definiteness\n e = torch.linalg.eigvalsh(pt)\n if not all(e >= -atol):\n return False\n # Test that the matrix is centered\n if not is_centered(pt, atol=atol):\n return False\n # Test unit Frobenius norm\n if not torch.isclose(torch.linalg.norm(pt, ord='fro'), pt.new_ones((1,)), atol=atol):\n return False\n return True", "probing input": " def _contains_impl(self, pt: Point, atol: float = 1e-6) -> bool:\n # Test shape\n if pt.shape != (self.m, self.m):\n return False\n # Test symmetric\n if not torch.allclose(pt, pt.T, atol=atol):\n return False\n if self._unbiased:\n # Test that the diagonal is zero\n if not torch.allclose(torch.diag(pt), pt.new_zeros((self.m,)), atol=atol):\n return False\n else:\n # Test positive (semi-) definiteness\n e = torch.linalg.eigvalsh(pt)\n if not all(e >= -atol):\n return False\n # Test that the matrix is centered\n if not is_centered(pt, atol=atol):\n return False\n # Test unit Frobenius norm\n", "probing input new": " def _contains_impl(self, pt: Point, atol: float = 1e-6) -> bool:\n # Test shape\n if pt.shape != (self.m, self.m):\n return False\n # Test symmetric\n if not torch.allclose(pt, pt.T, atol=atol):\n return False\n if self._unbiased:\n # Test that the diagonal is zero\n if not torch.allclose(torch.diag(pt), pt.new_zeros((self.m,)), atol=atol):\n return False\n else:\n # Test positive (semi-) definiteness\n e = torch.linalg.eigvalsh(pt)\n if not all(e >= -atol):\n return False\n # Test that the matrix is centered\n if not is_centered(pt, atol=atol):\n return False\n # Test unit Frobenius norm\n if not torch.isclose(torch.", "reference": "ifnottorch.isclose(torch.linalg.norm(pt,ord='fro'),pt.new_ones((1,)),atol=atol):", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "ifnottorch.isclose(torch.linalg.norm(pt,ord='fro'),pt.new_ones((1,)),atol=atol):", "y_neg": " if not torch.isclose(torch.norm(pt, 'fro'), 1, atol=atol):", "retain": " def _contains_impl(self, pt: Point, atol: float = 1e-6) -> bool:\n # Test shape\n if pt.shape != (self.m, self.m):\n return False\n # Test symmetric\n if not torch.allclose(pt, pt.T, atol=atol):\n return False\n if self._unbiased:\n # Test that the diagonal is zero\n if not torch.allclose(torch.diag(pt), pt.new_zeros((self.m,)), atol=atol):\n return False\n else:\n # Test positive (semi-) definiteness\n e = torch.linalg.eigvalsh(pt)\n if not all(e >= -atol):\n return False\n # Test that the matrix is centered\n if not is_centered(pt, atol=atol):\n return False\n # Test unit Frobenius norm\n if not torch.isclose(torch.linalg.norm(pt, ord='fro'), pt.new_ones((1,)), atol=atol):\n return False\n return True" }, { "id": 7322, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _matrix_unit_norm(A):\n \"\"\"Scale a matrix to have unit Frobenius norm.\n\n :param A: a matrix\n :return: the matrix divided by its Frobenius norm\n \"\"\"\n return A / torch.linalg.norm(A, ord='fro')", "probing input": "def _matrix_unit_norm(A):\n \"\"\"Scale a matrix to have unit Frobenius norm.\n\n :param A: a matrix\n :return: the matrix divided by its Frobenius norm\n \"\"\"\n", "probing input new": "def _matrix_unit_norm(A):\n \"\"\"Scale a matrix to have unit Frobenius norm.\n\n :param A: a matrix\n :return: the matrix divided by its Frobenius norm\n \"\"\"\n return A / torch.", "reference": "returnA/torch.linalg.norm(A,ord='fro')", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnA/torch.linalg.norm(A,ord='fro')", "y_neg": " return A / torch.norm(A, 'fro')", "retain": "def _matrix_unit_norm(A):\n \"\"\"Scale a matrix to have unit Frobenius norm.\n\n :param A: a matrix\n :return: the matrix divided by its Frobenius norm\n \"\"\"\n return A / torch.linalg.norm(A, ord='fro')" }, { "id": 7325, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_subset_active_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 0.0], [2.0, 0.0], [3.0, 0.0], [4.0, 0.0]]).view(2, 2, 2)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]), active_dims=[0])\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-5)", "probing input": " def test_subset_active_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 0.0], [2.0, 0.0], [3.0, 0.0], [4.0, 0.0]]).view(2, 2, 2)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]), active_dims=[0])\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n res = kernel(a, b).to_dense()\n", "probing input new": " def test_subset_active_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 0.0], [2.0, 0.0], [3.0, 0.0], [4.0, 0.0]]).view(2, 2, 2)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]), active_dims=[0])\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(res-actual),1e-5)", "reference dict": { "kernel": "ExponentialDecayKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(res-actual),1e-5)", "y_neg": " self.assertLess(torch.norm(res - actual), 1e-5)", "retain": " def test_subset_active_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 0.0], [2.0, 0.0], [3.0, 0.0], [4.0, 0.0]]).view(2, 2, 2)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]), active_dims=[0])\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + torch.tensor([1.0]).div(diff.pow(power))\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-5)" }, { "id": 7326, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_computes_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 2.0], [3.0, 4.0]]).view(2, 2, 1)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + diff.pow(-power)\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + diff.pow(-power)\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-5)", "probing input": " def test_computes_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 2.0], [3.0, 4.0]]).view(2, 2, 1)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + diff.pow(-power)\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + diff.pow(-power)\n\n res = kernel(a, b).to_dense()\n", "probing input new": " def test_computes_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 2.0], [3.0, 4.0]]).view(2, 2, 1)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + diff.pow(-power)\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + diff.pow(-power)\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(res-actual),1e-5)", "reference dict": { "kernel": "ExponentialDecayKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(res-actual),1e-5)", "y_neg": " self.assertLess(torch.norm(res - actual), 1e-5)", "retain": " def test_computes_exponential_decay_function_batch(self):\n a = torch.tensor([[1.0, 2.0], [3.0, 4.0]]).view(2, 2, 1)\n b = torch.tensor([[5.0, 6.0], [7.0, 8.0]]).view(2, 2, 1)\n lengthscale = 1\n power = 1\n offset = 1\n\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n kernel.initialize(lengthscale=lengthscale, power=power, offset=offset)\n kernel.eval()\n\n actual = torch.zeros(2, 2, 2)\n\n diff = torch.tensor([[7.0, 8.0], [8.0, 9.0]])\n actual[0, :, :] = offset + diff.pow(-power)\n\n diff = torch.tensor([[11.0, 12.0], [12.0, 13.0]])\n actual[1, :, :] = offset + diff.pow(-power)\n\n res = kernel(a, b).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-5)" }, { "id": 7327, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_lengthscale(self):\n kernel = ExponentialDecayKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)", "probing input": " def test_initialize_lengthscale(self):\n kernel = ExponentialDecayKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n", "probing input new": " def test_initialize_lengthscale(self):\n kernel = ExponentialDecayKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "reference dict": { "kernel": "ExponentialDecayKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.lengthscale - actual_value), 1e-5)", "retain": " def test_initialize_lengthscale(self):\n kernel = ExponentialDecayKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)" }, { "id": 7328, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_lengthscale_batch(self):\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)", "probing input": " def test_initialize_lengthscale_batch(self):\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n", "probing input new": " def test_initialize_lengthscale_batch(self):\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "reference dict": { "kernel": "ExponentialDecayKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.lengthscale - actual_value), 1e-5)", "retain": " def test_initialize_lengthscale_batch(self):\n kernel = ExponentialDecayKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)" }, { "id": 7338, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def calculate(self, data_batch, label_batch):\n cove_set = set()\n SA_batch = []\n batch_size = label_batch.size(0)\n layer_output_dict = tool.get_layer_output(self.model, data_batch)\n for (layer_name, layer_output) in layer_output_dict.items():\n SA_batch.append(layer_output[:, self.mask_index_dict[layer_name]].view(batch_size, -1))\n SA_batch = torch.cat(SA_batch, 1).detach().cpu().numpy() # [batch_size, num_neuron]\n for i, label in enumerate(label_batch):\n SA = SA_batch[i]\n \n # # using numpy \n # dist_a_list = np.linalg.norm(SA - self.SA_cache[int(label.cpu())], axis=1)\n # idx_a = np.argmin(dist_a_list, 0)\n\n dist_a_list = torch.linalg.norm(\n torch.from_numpy(SA).to(self.device) - torch.from_numpy(self.SA_cache[int(label.cpu())]).to(self.device), dim=1)\n idx_a = torch.argmin(dist_a_list, 0).item()\n\n (SA_a, dist_a) = (self.SA_cache[int(label.cpu())][idx_a], dist_a_list[idx_a])\n dist_a = dist_a.cpu().numpy()\n\n dist_b_list = []\n for j in range(self.num_class):\n if ( j != int(label.cpu()) ) and ( j in self.SA_cache.keys() ):\n # # using numpy\n # dist_b_list += np.linalg.norm(SA - self.SA_cache[j], axis=1).tolist()\n dist_b_list += torch.linalg.norm(\n torch.from_numpy(SA).to(self.device) - torch.from_numpy(self.SA_cache[j]).to(self.device),\n dim=1).cpu().numpy().tolist()\n \n dist_b = np.min(dist_b_list)\n dsa = dist_a / dist_b if dist_b > 0 else 1e-6\n if (not np.isnan(dsa)) and (not np.isinf(dsa)):\n cove_set.add(int(dsa / self.threshold))\n cove_set = self.coverage_set.union(cove_set)\n return cove_set", "probing input": " def calculate(self, data_batch, label_batch):\n cove_set = set()\n SA_batch = []\n batch_size = label_batch.size(0)\n layer_output_dict = tool.get_layer_output(self.model, data_batch)\n for (layer_name, layer_output) in layer_output_dict.items():\n SA_batch.append(layer_output[:, self.mask_index_dict[layer_name]].view(batch_size, -1))\n SA_batch = torch.cat(SA_batch, 1).detach().cpu().numpy() # [batch_size, num_neuron]\n for i, label in enumerate(label_batch):\n SA = SA_batch[i]\n \n # # using numpy \n # dist_a_list = np.linalg.norm(SA - self.SA_cache[int(label.cpu())], axis=1)\n # idx_a = np.argmin(dist_a_list, 0)\n\n", "probing input new": " def calculate(self, data_batch, label_batch):\n cove_set = set()\n SA_batch = []\n batch_size = label_batch.size(0)\n layer_output_dict = tool.get_layer_output(self.model, data_batch)\n for (layer_name, layer_output) in layer_output_dict.items():\n SA_batch.append(layer_output[:, self.mask_index_dict[layer_name]].view(batch_size, -1))\n SA_batch = torch.cat(SA_batch, 1).detach().cpu().numpy() # [batch_size, num_neuron]\n for i, label in enumerate(label_batch):\n SA = SA_batch[i]\n \n # # using numpy \n # dist_a_list = np.linalg.norm(SA - self.SA_cache[int(label.cpu())], axis=1)\n # idx_a = np.argmin(dist_a_list, 0)\n\n dist_a_list = torch.", "reference": "dist_a_list=torch.linalg.norm(torch.from_numpy(SA).to(self.device)-torch.from_numpy(self.SA_cache[int(label.cpu())]).to(self.device),dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist_a_list=torch.linalg.norm(torch.from_numpy(SA).to(self.device)-torch.from_numpy(self.SA_cache[int(label.cpu())]).to(self.device),dim=1)", "y_neg": " dist_a_list = torch.norm(SA - self.SA_cache[int(label.cpu())], dim=1)", "retain": " def calculate(self, data_batch, label_batch):\n cove_set = set()\n SA_batch = []\n batch_size = label_batch.size(0)\n layer_output_dict = tool.get_layer_output(self.model, data_batch)\n for (layer_name, layer_output) in layer_output_dict.items():\n SA_batch.append(layer_output[:, self.mask_index_dict[layer_name]].view(batch_size, -1))\n SA_batch = torch.cat(SA_batch, 1).detach().cpu().numpy() # [batch_size, num_neuron]\n for i, label in enumerate(label_batch):\n SA = SA_batch[i]\n \n # # using numpy \n # dist_a_list = np.linalg.norm(SA - self.SA_cache[int(label.cpu())], axis=1)\n # idx_a = np.argmin(dist_a_list, 0)\n\n dist_a_list = torch.linalg.norm(\n torch.from_numpy(SA).to(self.device) - torch.from_numpy(self.SA_cache[int(label.cpu())]).to(self.device), dim=1)\n idx_a = torch.argmin(dist_a_list, 0).item()\n\n (SA_a, dist_a) = (self.SA_cache[int(label.cpu())][idx_a], dist_a_list[idx_a])\n dist_a = dist_a.cpu().numpy()\n\n dist_b_list = []\n for j in range(self.num_class):\n if ( j != int(label.cpu()) ) and ( j in self.SA_cache.keys() ):\n # # using numpy\n # dist_b_list += np.linalg.norm(SA - self.SA_cache[j], axis=1).tolist()\n dist_b_list += torch.linalg.norm(\n torch.from_numpy(SA).to(self.device) - torch.from_numpy(self.SA_cache[j]).to(self.device),\n dim=1).cpu().numpy().tolist()\n \n dist_b = np.min(dist_b_list)\n dsa = dist_a / dist_b if dist_b > 0 else 1e-6\n if (not np.isnan(dsa)) and (not np.isinf(dsa)):\n cove_set.add(int(dsa / self.threshold))\n cove_set = self.coverage_set.union(cove_set)\n return cove_set" }, { "id": 7342, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_quat(shape: tuple[int] | int, device: Optional[str] = None) -> Tensor:\n \"\"\"\n Uniformly samples SO3 elements parameterized as quaternions.\n\n Arguments:\n - shape: Int or tuple denoting the shape of the output tensor.\n - device: device on which the new tensor is created.\n\n Returns:\n - Tensor of shape `(*shape, 4)`.\n \"\"\"\n shape = shape if type(shape) is tuple else (shape,)\n\n q = torch.randn(*shape, 4, device=device)\n q = q / torch.linalg.norm(q, dim=-1, keepdim=True)\n\n return q", "probing input": "def random_quat(shape: tuple[int] | int, device: Optional[str] = None) -> Tensor:\n \"\"\"\n Uniformly samples SO3 elements parameterized as quaternions.\n\n Arguments:\n - shape: Int or tuple denoting the shape of the output tensor.\n - device: device on which the new tensor is created.\n\n Returns:\n - Tensor of shape `(*shape, 4)`.\n \"\"\"\n shape = shape if type(shape) is tuple else (shape,)\n\n q = torch.randn(*shape, 4, device=device)\n", "probing input new": "def random_quat(shape: tuple[int] | int, device: Optional[str] = None) -> Tensor:\n \"\"\"\n Uniformly samples SO3 elements parameterized as quaternions.\n\n Arguments:\n - shape: Int or tuple denoting the shape of the output tensor.\n - device: device on which the new tensor is created.\n\n Returns:\n - Tensor of shape `(*shape, 4)`.\n \"\"\"\n shape = shape if type(shape) is tuple else (shape,)\n\n q = torch.randn(*shape, 4, device=device)\n q = q / torch.", "reference": "q=q/torch.linalg.norm(q,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "q=q/torch.linalg.norm(q,dim=-1,keepdim=True)", "y_neg": " q = q / torch.norm(q, dim=-1, keepdim=True)", "retain": "def random_quat(shape: tuple[int] | int, device: Optional[str] = None) -> Tensor:\n \"\"\"\n Uniformly samples SO3 elements parameterized as quaternions.\n\n Arguments:\n - shape: Int or tuple denoting the shape of the output tensor.\n - device: device on which the new tensor is created.\n\n Returns:\n - Tensor of shape `(*shape, 4)`.\n \"\"\"\n shape = shape if type(shape) is tuple else (shape,)\n\n q = torch.randn(*shape, 4, device=device)\n q = q / torch.linalg.norm(q, dim=-1, keepdim=True)\n\n return q" }, { "id": 7343, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def quaternion_log(q: Tensor) -> Tensor:\n \"\"\"\n Calculates logarithm of quaternions.\n\n NOTE: log of identity quaternion will be set to the zero\n vector.\n\n Arguments:\n - q: Tensor of shape `(N, 4)`.\n\n Returns:\n - Tensor of shape `(N, 4)`.\n \"\"\"\n q_norm = torch.linalg.norm(q, dim=-1, keepdim=True)\n\n inverse_v_norm = 1 / torch.linalg.norm(q[:, 1:], dim=-1, keepdim=True)\n inverse_v_norm[inverse_v_norm == torch.inf] = 0\n\n log_q_norm = torch.log(q_norm)\n vector_part = (inverse_v_norm * torch.acos(q[:, 0].view(-1, 1) / q_norm)) * q[:, 1:]\n\n return torch.hstack((log_q_norm, vector_part))", "probing input": "def quaternion_log(q: Tensor) -> Tensor:\n \"\"\"\n Calculates logarithm of quaternions.\n\n NOTE: log of identity quaternion will be set to the zero\n vector.\n\n Arguments:\n - q: Tensor of shape `(N, 4)`.\n\n Returns:\n - Tensor of shape `(N, 4)`.\n \"\"\"\n", "probing input new": "def quaternion_log(q: Tensor) -> Tensor:\n \"\"\"\n Calculates logarithm of quaternions.\n\n NOTE: log of identity quaternion will be set to the zero\n vector.\n\n Arguments:\n - q: Tensor of shape `(N, 4)`.\n\n Returns:\n - Tensor of shape `(N, 4)`.\n \"\"\"\n q_", "reference": "q_norm=torch.linalg.norm(q,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "q_norm=torch.linalg.norm(q,dim=-1,keepdim=True)", "y_neg": " q_norm = torch.norm(q, p=2, dim=1, keepdim=True)", "retain": "def quaternion_log(q: Tensor) -> Tensor:\n \"\"\"\n Calculates logarithm of quaternions.\n\n NOTE: log of identity quaternion will be set to the zero\n vector.\n\n Arguments:\n - q: Tensor of shape `(N, 4)`.\n\n Returns:\n - Tensor of shape `(N, 4)`.\n \"\"\"\n q_norm = torch.linalg.norm(q, dim=-1, keepdim=True)\n\n inverse_v_norm = 1 / torch.linalg.norm(q[:, 1:], dim=-1, keepdim=True)\n inverse_v_norm[inverse_v_norm == torch.inf] = 0\n\n log_q_norm = torch.log(q_norm)\n vector_part = (inverse_v_norm * torch.acos(q[:, 0].view(-1, 1) / q_norm)) * q[:, 1:]\n\n return torch.hstack((log_q_norm, vector_part))" }, { "id": 7345, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def QUEscore(temp_feats, n_dim):\n\n n_samples = temp_feats.shape[1]\n alpha = 4.0\n Sigma = torch.matmul(temp_feats, temp_feats.T) / n_samples\n I = torch.eye(n_dim).cuda()\n Q = torch.exp((alpha * (Sigma - I)) / (torch.linalg.norm(Sigma, ord=2) - 1))\n trace_Q = torch.trace(Q)\n\n taus = []\n for i in range(n_samples):\n h_i = temp_feats[:, i:i + 1]\n tau_i = torch.matmul(h_i.T, torch.matmul(Q, h_i)) / trace_Q\n tau_i = tau_i.item()\n taus.append(tau_i)\n taus = np.array(taus)\n\n return taus", "probing input": "def QUEscore(temp_feats, n_dim):\n\n n_samples = temp_feats.shape[1]\n alpha = 4.0\n Sigma = torch.matmul(temp_feats, temp_feats.T) / n_samples\n I = torch.eye(n_dim).cuda()\n", "probing input new": "def QUEscore(temp_feats, n_dim):\n\n n_samples = temp_feats.shape[1]\n alpha = 4.0\n Sigma = torch.matmul(temp_feats, temp_feats.T) / n_samples\n I = torch.eye(n_dim).cuda()\n Q = torch.exp((alpha * (Sigma - I)) / (torch.", "reference": "Q=torch.exp((alpha*(Sigma-I))/(torch.linalg.norm(Sigma,ord=2)-1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "Q=torch.exp((alpha*(Sigma-I))/(torch.linalg.norm(Sigma,ord=2)-1))", "y_neg": " Q = torch.exp((alpha * (Sigma - I)) / (torch.norm(Sigma - I, p='fro') ** 2))", "retain": "def QUEscore(temp_feats, n_dim):\n\n n_samples = temp_feats.shape[1]\n alpha = 4.0\n Sigma = torch.matmul(temp_feats, temp_feats.T) / n_samples\n I = torch.eye(n_dim).cuda()\n Q = torch.exp((alpha * (Sigma - I)) / (torch.linalg.norm(Sigma, ord=2) - 1))\n trace_Q = torch.trace(Q)\n\n taus = []\n for i in range(n_samples):\n h_i = temp_feats[:, i:i + 1]\n tau_i = torch.matmul(h_i.T, torch.matmul(Q, h_i)) / trace_Q\n tau_i = tau_i.item()\n taus.append(tau_i)\n taus = np.array(taus)\n\n return taus" }, { "id": 7346, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def select_gripper_pose(sdf, pg, score, cp1, cp2, gripper_depth,\n num_angle=32, max_width=0.08,\n th_s=0.997, th_c=0.999,\n check_tray=True,\n post_processed=True, gaussian_blur=True):\n \"\"\"\n Select collision-free pose according to the quality scores of the contact points.\n :param sdf: the SDF instance\n :param pg: a python dictionary containing the surface vertices of the gripper\n :param score: an N-D torch tensor representing the grasp qualities of contact point pairs.\n :param cp1: an Nx3-D torch tensor representing the 3D locations of the left contact points.\n :param cp2: an Nx3-D torch tensor representing the 3D locations of the right contact points.\n :param gripper_depth:y[:, 0:2]\n :param num_angle: the number of discretized angles in x-z plane\n :param max_width:\n :param th_s:\n :param th_c:\n :param check_tray:\n :param post_processed:\n :param gaussian_blur:\n :return: 4 torch tensor representing sets of gripper position, rotations, and contact points\n \"\"\"\n dtype = score.dtype\n dev = score.device\n score = torch.sigmoid(score)\n score, rank = torch.sort(score, descending=True)\n th_s = score[0] * th_s # select top 0.1% contact points as candidates\n rank = rank[score >= th_s]\n num_cp = rank.shape[0]\n cp1, cp2 = cp1[rank], cp2[rank]\n pos = (cp1 + cp2) / 2 # num_cp * 3\n y = cp1 - cp2\n distance = torch.linalg.norm(y, dim=1, keepdim=True)\n y = y / distance # num_cp * 3\n width = torch.clamp(distance + 0.02, 0.0, max_width) # num_cp * 1\n offset = (max_width - width) / 2\n offset = offset.unsqueeze(-1).unsqueeze(-1) # num_cp * 1 * 1 * 1\n z = torch.zeros_like(y, dtype=dtype, device=dev)\n z_norm = torch.linalg.norm(y[:, 0:2], dim=1)\n z[:, 0] = y[:, 1] / z_norm\n z[:, 1] = -y[:, 0] / z_norm\n x = torch.cross(y, z, dim=1)\n x = x / torch.linalg.norm(x, dim=1, keepdim=True)\n # u, _, _ = torch.linalg.svd(y.view(num_cp, 3, 1)) # the shape of u: num_cp * 3 * 3\n # x = u[..., 1] # num_cp * 3\n # z = torch.cross(x, y, dim=1)\n rot0 = torch.stack([x, y, z], dim=2) # num_cp * 3 * 3\n angles = torch.arange(num_angle, dtype=dtype, device=dev) / num_angle * torch.pi # num_angle\n delta_rots = basic_rots(angles, axis='y') # num_angle * 3 * 3\n rots = torch.matmul(rot0.unsqueeze(dim=1), delta_rots.unsqueeze(dim=0)) # num_cp * num_angle * 3 * 3\n z_flag = rots[..., -1, -1] > 0\n i, j = torch.meshgrid(torch.arange(num_cp, device=dev), torch.arange(num_angle, device=dev))\n i, j = i[z_flag], j[z_flag]\n rots[i, j, :, 0], rots[i, j, :, 2] = -rots[i, j, :, 0], -rots[i, j, :, 2]\n ys = rots[..., 1].unsqueeze(dim=2) # num_cp * num_angle * 1 * 3\n n_h, n_l, n_r = pg['hand'].shape[0], pg['left_finger'].shape[0], pg['right_finger'].shape[0]\n vs = torch.from_numpy(np.concatenate([pg['hand'], pg['left_finger'], pg['right_finger']], axis=0)).to(dtype).to(dev)\n num_v = vs.shape[0]\n gripper_pos = pos.reshape(num_cp, 1, 3) - rots[..., 2] * gripper_depth # num_cp * num_angle * 3\n vs = torch.matmul(rots, vs.permute(1, 0).unsqueeze(0).unsqueeze(0)).permute(0, 1, 3, 2) + gripper_pos.unsqueeze(2) # num_cp * num_angle * num_v * 3\n vs[..., n_h:n_h+n_l, :] = vs[..., n_h:n_h+n_l, :] - offset * ys # left finger vertices\n vs[..., n_h+n_l:n_h+n_l+n_r, :] = vs[..., n_h+n_l:n_h+n_l+n_r, :] + offset * ys # right finger vertices\n sdv = sdf.interpolation(vs.reshape(-1, 3),\n use_post_processed=post_processed, smooth=gaussian_blur).reshape(num_cp, num_angle, num_v)\n if check_tray:\n vs_ids = sdf.get_ids(vs.reshape(-1, 3)).reshape(num_cp, num_angle, num_v, 3)\n oob_flag = torch.logical_or(torch.logical_or(vs_ids[..., 0] < 0, vs_ids[..., 0] >= sdf.shape[0]),\n torch.logical_or(vs_ids[..., 1] < 0, vs_ids[..., 1] >= sdf.shape[1]))\n sdv[oob_flag] = -1\n num_free = torch.sum(sdv > 0.2, dim=-1) # num_cp * num_angle\n flag_c = num_free > torch.max(num_free) * th_c\n rots = rots[flag_c]\n gripper_pos = gripper_pos[flag_c]\n width = torch.cat([width] * num_angle, dim=1)[flag_c]\n distance = torch.cat([distance] * num_angle, dim=1)[flag_c]\n pos = torch.stack([pos] * num_angle, dim=1)[flag_c]\n num_free = num_free[flag_c]\n col_score = num_free / num_v\n # resort the contact points\n # _, ids = torch.sort(score_n, descending=True)\n # rots = rots[ids]\n # gripper_pos = gripper_pos[ids]\n # width = width[ids]\n # distance = distance[ids]\n # pos = pos[ids]\n grasp_directions = rots[..., 1]\n cp1 = (pos + grasp_directions * distance.reshape(-1, 1) / 2)\n cp2 = (pos - grasp_directions * distance.reshape(-1, 1) / 2)\n return gripper_pos, rots, width, cp1, cp2", "probing input": "def select_gripper_pose(sdf, pg, score, cp1, cp2, gripper_depth,\n num_angle=32, max_width=0.08,\n th_s=0.997, th_c=0.999,\n check_tray=True,\n post_processed=True, gaussian_blur=True):\n \"\"\"\n Select collision-free pose according to the quality scores of the contact points.\n :param sdf: the SDF instance\n :param pg: a python dictionary containing the surface vertices of the gripper\n :param score: an N-D torch tensor representing the grasp qualities of contact point pairs.\n :param cp1: an Nx3-D torch tensor representing the 3D locations of the left contact points.\n :param cp2: an Nx3-D torch tensor representing the 3D locations of the right contact points.\n :param gripper_depth:y[:, 0:2]\n :param num_angle: the number of discretized angles in x-z plane\n :param max_width:\n :param th_s:\n :param th_c:\n :param check_tray:\n :param post_processed:\n :param gaussian_blur:\n :return: 4 torch tensor representing sets of gripper position, rotations, and contact points\n \"\"\"\n dtype = score.dtype\n dev = score.device\n score = torch.sigmoid(score)\n score, rank = torch.sort(score, descending=True)\n th_s = score[0] * th_s # select top 0.1% contact points as candidates\n rank = rank[score >= th_s]\n num_cp = rank.shape[0]\n cp1, cp2 = cp1[rank], cp2[rank]\n pos = (cp1 + cp2) / 2 # num_cp * 3\n y = cp1 - cp2\n", "probing input new": "def select_gripper_pose(sdf, pg, score, cp1, cp2, gripper_depth,\n num_angle=32, max_width=0.08,\n th_s=0.997, th_c=0.999,\n check_tray=True,\n post_processed=True, gaussian_blur=True):\n \"\"\"\n Select collision-free pose according to the quality scores of the contact points.\n :param sdf: the SDF instance\n :param pg: a python dictionary containing the surface vertices of the gripper\n :param score: an N-D torch tensor representing the grasp qualities of contact point pairs.\n :param cp1: an Nx3-D torch tensor representing the 3D locations of the left contact points.\n :param cp2: an Nx3-D torch tensor representing the 3D locations of the right contact points.\n :param gripper_depth:y[:, 0:2]\n :param num_angle: the number of discretized angles in x-z plane\n :param max_width:\n :param th_s:\n :param th_c:\n :param check_tray:\n :param post_processed:\n :param gaussian_blur:\n :return: 4 torch tensor representing sets of gripper position, rotations, and contact points\n \"\"\"\n dtype = score.dtype\n dev = score.device\n score = torch.sigmoid(score)\n score, rank = torch.sort(score, descending=True)\n th_s = score[0] * th_s # select top 0.1% contact points as candidates\n rank = rank[score >= th_s]\n num_cp = rank.shape[0]\n cp1, cp2 = cp1[rank], cp2[rank]\n pos = (cp1 + cp2) / 2 # num_cp * 3\n y = cp1 - cp2\n distance = torch.", "reference": "distance=torch.linalg.norm(y,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distance=torch.linalg.norm(y,dim=1,keepdim=True)", "y_neg": " distance = torch.norm(y, p=2, dim=1)", "retain": "def select_gripper_pose(sdf, pg, score, cp1, cp2, gripper_depth,\n num_angle=32, max_width=0.08,\n th_s=0.997, th_c=0.999,\n check_tray=True,\n post_processed=True, gaussian_blur=True):\n \"\"\"\n Select collision-free pose according to the quality scores of the contact points.\n :param sdf: the SDF instance\n :param pg: a python dictionary containing the surface vertices of the gripper\n :param score: an N-D torch tensor representing the grasp qualities of contact point pairs.\n :param cp1: an Nx3-D torch tensor representing the 3D locations of the left contact points.\n :param cp2: an Nx3-D torch tensor representing the 3D locations of the right contact points.\n :param gripper_depth:y[:, 0:2]\n :param num_angle: the number of discretized angles in x-z plane\n :param max_width:\n :param th_s:\n :param th_c:\n :param check_tray:\n :param post_processed:\n :param gaussian_blur:\n :return: 4 torch tensor representing sets of gripper position, rotations, and contact points\n \"\"\"\n dtype = score.dtype\n dev = score.device\n score = torch.sigmoid(score)\n score, rank = torch.sort(score, descending=True)\n th_s = score[0] * th_s # select top 0.1% contact points as candidates\n rank = rank[score >= th_s]\n num_cp = rank.shape[0]\n cp1, cp2 = cp1[rank], cp2[rank]\n pos = (cp1 + cp2) / 2 # num_cp * 3\n y = cp1 - cp2\n distance = torch.linalg.norm(y, dim=1, keepdim=True)\n y = y / distance # num_cp * 3\n width = torch.clamp(distance + 0.02, 0.0, max_width) # num_cp * 1\n offset = (max_width - width) / 2\n offset = offset.unsqueeze(-1).unsqueeze(-1) # num_cp * 1 * 1 * 1\n z = torch.zeros_like(y, dtype=dtype, device=dev)\n z_norm = torch.linalg.norm(y[:, 0:2], dim=1)\n z[:, 0] = y[:, 1] / z_norm\n z[:, 1] = -y[:, 0] / z_norm\n x = torch.cross(y, z, dim=1)\n x = x / torch.linalg.norm(x, dim=1, keepdim=True)\n # u, _, _ = torch.linalg.svd(y.view(num_cp, 3, 1)) # the shape of u: num_cp * 3 * 3\n # x = u[..., 1] # num_cp * 3\n # z = torch.cross(x, y, dim=1)\n rot0 = torch.stack([x, y, z], dim=2) # num_cp * 3 * 3\n angles = torch.arange(num_angle, dtype=dtype, device=dev) / num_angle * torch.pi # num_angle\n delta_rots = basic_rots(angles, axis='y') # num_angle * 3 * 3\n rots = torch.matmul(rot0.unsqueeze(dim=1), delta_rots.unsqueeze(dim=0)) # num_cp * num_angle * 3 * 3\n z_flag = rots[..., -1, -1] > 0\n i, j = torch.meshgrid(torch.arange(num_cp, device=dev), torch.arange(num_angle, device=dev))\n i, j = i[z_flag], j[z_flag]\n rots[i, j, :, 0], rots[i, j, :, 2] = -rots[i, j, :, 0], -rots[i, j, :, 2]\n ys = rots[..., 1].unsqueeze(dim=2) # num_cp * num_angle * 1 * 3\n n_h, n_l, n_r = pg['hand'].shape[0], pg['left_finger'].shape[0], pg['right_finger'].shape[0]\n vs = torch.from_numpy(np.concatenate([pg['hand'], pg['left_finger'], pg['right_finger']], axis=0)).to(dtype).to(dev)\n num_v = vs.shape[0]\n gripper_pos = pos.reshape(num_cp, 1, 3) - rots[..., 2] * gripper_depth # num_cp * num_angle * 3\n vs = torch.matmul(rots, vs.permute(1, 0).unsqueeze(0).unsqueeze(0)).permute(0, 1, 3, 2) + gripper_pos.unsqueeze(2) # num_cp * num_angle * num_v * 3\n vs[..., n_h:n_h+n_l, :] = vs[..., n_h:n_h+n_l, :] - offset * ys # left finger vertices\n vs[..., n_h+n_l:n_h+n_l+n_r, :] = vs[..., n_h+n_l:n_h+n_l+n_r, :] + offset * ys # right finger vertices\n sdv = sdf.interpolation(vs.reshape(-1, 3),\n use_post_processed=post_processed, smooth=gaussian_blur).reshape(num_cp, num_angle, num_v)\n if check_tray:\n vs_ids = sdf.get_ids(vs.reshape(-1, 3)).reshape(num_cp, num_angle, num_v, 3)\n oob_flag = torch.logical_or(torch.logical_or(vs_ids[..., 0] < 0, vs_ids[..., 0] >= sdf.shape[0]),\n torch.logical_or(vs_ids[..., 1] < 0, vs_ids[..., 1] >= sdf.shape[1]))\n sdv[oob_flag] = -1\n num_free = torch.sum(sdv > 0.2, dim=-1) # num_cp * num_angle\n flag_c = num_free > torch.max(num_free) * th_c\n rots = rots[flag_c]\n gripper_pos = gripper_pos[flag_c]\n width = torch.cat([width] * num_angle, dim=1)[flag_c]\n distance = torch.cat([distance] * num_angle, dim=1)[flag_c]\n pos = torch.stack([pos] * num_angle, dim=1)[flag_c]\n num_free = num_free[flag_c]\n col_score = num_free / num_v\n # resort the contact points\n # _, ids = torch.sort(score_n, descending=True)\n # rots = rots[ids]\n # gripper_pos = gripper_pos[ids]\n # width = width[ids]\n # distance = distance[ids]\n # pos = pos[ids]\n grasp_directions = rots[..., 1]\n cp1 = (pos + grasp_directions * distance.reshape(-1, 1) / 2)\n cp2 = (pos - grasp_directions * distance.reshape(-1, 1) / 2)\n return gripper_pos, rots, width, cp1, cp2" }, { "id": 7348, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def relative_translation_error(gt_translations, translations):\n r\"\"\"Isotropic Relative Rotation Error.\n\n RTE = \\lVert t - \\bar{t} \\rVert_2\n\n Args:\n gt_translations (Tensor): ground truth translation vector (*, 3)\n translations (Tensor): estimated translation vector (*, 3)\n\n Returns:\n rre (Tensor): relative rotation errors (*)\n \"\"\"\n rte = torch.linalg.norm(gt_translations - translations, dim=-1)\n return rte", "probing input": "def relative_translation_error(gt_translations, translations):\n r\"\"\"Isotropic Relative Rotation Error.\n\n RTE = \\lVert t - \\bar{t} \\rVert_2\n\n Args:\n gt_translations (Tensor): ground truth translation vector (*, 3)\n translations (Tensor): estimated translation vector (*, 3)\n\n Returns:\n rre (Tensor): relative rotation errors (*)\n \"\"\"\n", "probing input new": "def relative_translation_error(gt_translations, translations):\n r\"\"\"Isotropic Relative Rotation Error.\n\n RTE = \\lVert t - \\bar{t} \\rVert_2\n\n Args:\n gt_translations (Tensor): ground truth translation vector (*, 3)\n translations (Tensor): estimated translation vector (*, 3)\n\n Returns:\n rre (Tensor): relative rotation errors (*)\n \"\"\"\n rte = torch.", "reference": "rte=torch.linalg.norm(gt_translations-translations,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rte=torch.linalg.norm(gt_translations-translations,dim=-1)", "y_neg": " rte = torch.norm(gt_translations - translations, p=2, dim=-1)", "retain": "def relative_translation_error(gt_translations, translations):\n r\"\"\"Isotropic Relative Rotation Error.\n\n RTE = \\lVert t - \\bar{t} \\rVert_2\n\n Args:\n gt_translations (Tensor): ground truth translation vector (*, 3)\n translations (Tensor): estimated translation vector (*, 3)\n\n Returns:\n rre (Tensor): relative rotation errors (*)\n \"\"\"\n rte = torch.linalg.norm(gt_translations - translations, dim=-1)\n return rte" }, { "id": 7349, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exp_map_SE3(tangent_vector: TensorType[\"b\", 6]) -> TensorType[\"b\", 3, 4]: # pylint: disable=invalid-name\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] tranformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret", "probing input": "def exp_map_SE3(tangent_vector: TensorType[\"b\", 6]) -> TensorType[\"b\", 3, 4]: # pylint: disable=invalid-name\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] tranformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n", "probing input new": "def exp_map_SE3(tangent_vector: TensorType[\"b\", 6]) -> TensorType[\"b\", 3, 4]: # pylint: disable=invalid-name\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] tranformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.", "reference": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(tangent_vector_ang,dim=1).unsqueeze(1)", "y_neg": " theta = torch.norm(tangent_vector_ang, p=2, dim=1, keepdim=True)", "retain": "def exp_map_SE3(tangent_vector: TensorType[\"b\", 6]) -> TensorType[\"b\", 3, 4]: # pylint: disable=invalid-name\n \"\"\"Compute the exponential map `se(3) -> SE(3)`.\n\n This can be used for learning pose deltas on `SE(3)`.\n\n Args:\n tangent_vector: A tangent vector from `se(3)`.\n\n Returns:\n [R|t] tranformation matrices.\n \"\"\"\n\n tangent_vector_lin = tangent_vector[:, :3].view(-1, 3, 1)\n tangent_vector_ang = tangent_vector[:, 3:].view(-1, 3, 1)\n\n theta = torch.linalg.norm(tangent_vector_ang, dim=1).unsqueeze(1)\n theta2 = theta**2\n theta3 = theta**3\n\n near_zero = theta < 1e-2\n non_zero = torch.ones(1, dtype=tangent_vector.dtype, device=tangent_vector.device)\n theta_nz = torch.where(near_zero, non_zero, theta)\n theta2_nz = torch.where(near_zero, non_zero, theta2)\n theta3_nz = torch.where(near_zero, non_zero, theta3)\n\n # Compute the rotation\n sine = theta.sin()\n cosine = torch.where(near_zero, 8 / (4 + theta2) - 1, theta.cos())\n sine_by_theta = torch.where(near_zero, 0.5 * cosine + 0.5, sine / theta_nz)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 * sine_by_theta, (1 - cosine) / theta2_nz)\n ret = torch.zeros(tangent_vector.shape[0], 3, 4).to(dtype=tangent_vector.dtype, device=tangent_vector.device)\n ret[:, :3, :3] = one_minus_cosine_by_theta2 * tangent_vector_ang @ tangent_vector_ang.transpose(1, 2)\n\n ret[:, 0, 0] += cosine.view(-1)\n ret[:, 1, 1] += cosine.view(-1)\n ret[:, 2, 2] += cosine.view(-1)\n temp = sine_by_theta.view(-1, 1) * tangent_vector_ang.view(-1, 3)\n ret[:, 0, 1] -= temp[:, 2]\n ret[:, 1, 0] += temp[:, 2]\n ret[:, 0, 2] += temp[:, 1]\n ret[:, 2, 0] -= temp[:, 1]\n ret[:, 1, 2] -= temp[:, 0]\n ret[:, 2, 1] += temp[:, 0]\n\n # Compute the translation\n sine_by_theta = torch.where(near_zero, 1 - theta2 / 6, sine_by_theta)\n one_minus_cosine_by_theta2 = torch.where(near_zero, 0.5 - theta2 / 24, one_minus_cosine_by_theta2)\n theta_minus_sine_by_theta3_t = torch.where(near_zero, 1.0 / 6 - theta2 / 120, (theta - sine) / theta3_nz)\n\n ret[:, :, 3:] = sine_by_theta * tangent_vector_lin\n ret[:, :, 3:] += one_minus_cosine_by_theta2 * torch.cross(tangent_vector_ang, tangent_vector_lin, dim=1)\n ret[:, :, 3:] += theta_minus_sine_by_theta3_t * (\n tangent_vector_ang @ (tangent_vector_ang.transpose(1, 2) @ tangent_vector_lin)\n )\n return ret" }, { "id": 7353, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n # matrix_ords 'nuc', 2, -2 are skipped currently\n # See issue https://github.com/pytorch/pytorch/issues/71911\n matrix_ords = ['fro', 1, inf, -1, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n self.assertEqual(result, result_n, msg=msg)\n\n # TODO: Remove this function once the broken cases are fixed\n def is_broken_matrix_norm_case(ord, x):\n if self.device_type == 'cuda':\n if x.size() == torch.Size([1, 2]):\n if ord in ['nuc', 2, -2] and isnan(x[0][0]) and x[0][1] == 1:\n # These cases are broken because of an issue with svd\n # https://github.com/pytorch/pytorch/issues/43567\n return True\n if ord in ['nuc', 2, -2]:\n # These cases are broken because of another issue with svd\n # https://github.com/pytorch/pytorch/issues/52633\n return True\n return False\n\n for matrix in matrices:\n x = torch.tensor(matrix).to(device)\n x_n = x.cpu().numpy()\n for ord in matrix_ords:\n msg = f'ord={ord}, matrix={matrix}'\n if is_broken_matrix_norm_case(ord, x):\n continue\n else:\n result_n = np.linalg.norm(x_n, ord=ord)\n result = torch.linalg.norm(x, ord=ord)\n self.assertEqual(result, result_n, msg=msg)", "probing input": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n # matrix_ords 'nuc', 2, -2 are skipped currently\n # See issue https://github.com/pytorch/pytorch/issues/71911\n matrix_ords = ['fro', 1, inf, -1, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n", "probing input new": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n # matrix_ords 'nuc', 2, -2 are skipped currently\n # See issue https://github.com/pytorch/pytorch/issues/71911\n matrix_ords = ['fro', 1, inf, -1, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.", "reference": "result=torch.linalg.norm(x,ord=ord)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(x,ord=ord)", "y_neg": " result = torch.norm(x, ord=ord, dim=0)", "retain": " def test_norm_extreme_values(self, device):\n vector_ords = [0, 1, 2, 3, inf, -1, -2, -3, -inf]\n # matrix_ords 'nuc', 2, -2 are skipped currently\n # See issue https://github.com/pytorch/pytorch/issues/71911\n matrix_ords = ['fro', 1, inf, -1, -inf]\n vectors = []\n matrices = []\n for pair in itertools.product([inf, -inf, 0.0, nan, 1.0], repeat=2):\n vectors.append(list(pair))\n matrices.append([[pair[0], pair[1]]])\n matrices.append([[pair[0]], [pair[1]]])\n for vector in vectors:\n x = torch.tensor(vector).to(device)\n x_n = x.cpu().numpy()\n for ord in vector_ords:\n msg = f'ord={ord}, vector={vector}'\n result = torch.linalg.norm(x, ord=ord)\n result_n = np.linalg.norm(x_n, ord=ord)\n self.assertEqual(result, result_n, msg=msg)\n\n # TODO: Remove this function once the broken cases are fixed\n def is_broken_matrix_norm_case(ord, x):\n if self.device_type == 'cuda':\n if x.size() == torch.Size([1, 2]):\n if ord in ['nuc', 2, -2] and isnan(x[0][0]) and x[0][1] == 1:\n # These cases are broken because of an issue with svd\n # https://github.com/pytorch/pytorch/issues/43567\n return True\n if ord in ['nuc', 2, -2]:\n # These cases are broken because of another issue with svd\n # https://github.com/pytorch/pytorch/issues/52633\n return True\n return False\n\n for matrix in matrices:\n x = torch.tensor(matrix).to(device)\n x_n = x.cpu().numpy()\n for ord in matrix_ords:\n msg = f'ord={ord}, matrix={matrix}'\n if is_broken_matrix_norm_case(ord, x):\n continue\n else:\n result_n = np.linalg.norm(x_n, ord=ord)\n result = torch.linalg.norm(x, ord=ord)\n self.assertEqual(result, result_n, msg=msg)" }, { "id": 7354, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def embed_images(self, xs: Iterable[Optional[ImageType]]) -> torch.Tensor:\n \"\"\"\n :param xs: N images, stored as numpy arrays, tensors, or PIL images.\n :return: an [N x D] tensor of features.\n \"\"\"\n clip_inputs = self.images_to_tensor(xs)\n results = self.clip_model.encode_image(clip_inputs).float()\n return results / torch.linalg.norm(results, dim=-1, keepdim=True)", "probing input": " def embed_images(self, xs: Iterable[Optional[ImageType]]) -> torch.Tensor:\n \"\"\"\n :param xs: N images, stored as numpy arrays, tensors, or PIL images.\n :return: an [N x D] tensor of features.\n \"\"\"\n clip_inputs = self.images_to_tensor(xs)\n results = self.clip_model.encode_image(clip_inputs).float()\n", "probing input new": " def embed_images(self, xs: Iterable[Optional[ImageType]]) -> torch.Tensor:\n \"\"\"\n :param xs: N images, stored as numpy arrays, tensors, or PIL images.\n :return: an [N x D] tensor of features.\n \"\"\"\n clip_inputs = self.images_to_tensor(xs)\n results = self.clip_model.encode_image(clip_inputs).float()\n return results / torch.", "reference": "returnresults/torch.linalg.norm(results,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnresults/torch.linalg.norm(results,dim=-1,keepdim=True)", "y_neg": " return results / torch.norm(results, dim=1, keepdim=True)", "retain": " def embed_images(self, xs: Iterable[Optional[ImageType]]) -> torch.Tensor:\n \"\"\"\n :param xs: N images, stored as numpy arrays, tensors, or PIL images.\n :return: an [N x D] tensor of features.\n \"\"\"\n clip_inputs = self.images_to_tensor(xs)\n results = self.clip_model.encode_image(clip_inputs).float()\n return results / torch.linalg.norm(results, dim=-1, keepdim=True)" }, { "id": 7355, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def embed_text(self, prompts: Iterable[str]) -> torch.Tensor:\n \"\"\"\n Embed text prompts as an [N x D] tensor.\n \"\"\"\n enc = self.clip_model.encode_text(\n self._tokenize(list(prompts), truncate=True).to(self.device)\n ).float()\n return enc / torch.linalg.norm(enc, dim=-1, keepdim=True)", "probing input": " def embed_text(self, prompts: Iterable[str]) -> torch.Tensor:\n \"\"\"\n Embed text prompts as an [N x D] tensor.\n \"\"\"\n enc = self.clip_model.encode_text(\n self._tokenize(list(prompts), truncate=True).to(self.device)\n ).float()\n", "probing input new": " def embed_text(self, prompts: Iterable[str]) -> torch.Tensor:\n \"\"\"\n Embed text prompts as an [N x D] tensor.\n \"\"\"\n enc = self.clip_model.encode_text(\n self._tokenize(list(prompts), truncate=True).to(self.device)\n ).float()\n return enc / torch.", "reference": "returnenc/torch.linalg.norm(enc,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnenc/torch.linalg.norm(enc,dim=-1,keepdim=True)", "y_neg": " return enc / torch.norm(enc, dim=1, keepdim=True)", "retain": " def embed_text(self, prompts: Iterable[str]) -> torch.Tensor:\n \"\"\"\n Embed text prompts as an [N x D] tensor.\n \"\"\"\n enc = self.clip_model.encode_text(\n self._tokenize(list(prompts), truncate=True).to(self.device)\n ).float()\n return enc / torch.linalg.norm(enc, dim=-1, keepdim=True)" }, { "id": 7357, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_stable_rank(tensor):\n # Compute the stable rank of a tensor\n tensor = tensor.detach()\n fro_norm = torch.linalg.norm(tensor, ord='fro')**2\n l2_norm = torch.linalg.norm(tensor, ord=2)**2\n rank = fro_norm / l2_norm\n rank = rank\n return rank", "probing input": "def compute_stable_rank(tensor):\n # Compute the stable rank of a tensor\n tensor = tensor.detach()\n", "probing input new": "def compute_stable_rank(tensor):\n # Compute the stable rank of a tensor\n tensor = tensor.detach()\n fro_", "reference": "fro_norm=torch.linalg.norm(tensor,ord='fro')**2", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "fro_norm=torch.linalg.norm(tensor,ord='fro')**2", "y_neg": " fro_norm = torch.norm(tensor, p='fro', dim=1)", "retain": "def compute_stable_rank(tensor):\n # Compute the stable rank of a tensor\n tensor = tensor.detach()\n fro_norm = torch.linalg.norm(tensor, ord='fro')**2\n l2_norm = torch.linalg.norm(tensor, ord=2)**2\n rank = fro_norm / l2_norm\n rank = rank\n return rank" }, { "id": 7358, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def prepare_ray(self, data_dict):\n def normalize_scene(coord, scene_bbox):\n scene_bbox = torch.tensor(scene_bbox).to(coord)\n norm_coord = (coord - scene_bbox[:3]) / (scene_bbox[3:] - scene_bbox[:3])\n return norm_coord\n\n condition = data_dict[\"condition\"][0]\n dataset_idx = self.conditions.index(condition)\n scene_bbox = self.scene_bbox[dataset_idx]\n # [0, 1]\n ray_start = normalize_scene(data_dict[\"ray_start\"], scene_bbox)\n ray_end = normalize_scene(data_dict[\"ray_end\"], scene_bbox)\n ray_d = F.normalize(ray_end - ray_start, dim=-1)\n ray_depth = torch.linalg.norm(ray_end - ray_start, dim=-1, keepdim=True)\n\n ray_dict = {\n \"ray_offset\": data_dict[\"ray_offset\"],\n \"ray_o\": ray_start,\n \"ray_d\": ray_d,\n \"depth\": ray_depth,\n }\n if \"ray_color\" in data_dict.keys():\n ray_dict[\"rgb\"] = data_dict[\"ray_color\"]\n if \"ray_segment\" in data_dict.keys() and self.render_semantic:\n assert (\n len(set(data_dict[\"condition\"])) == 1\n ), \"assume same condition in one batch\"\n condition = data_dict[\"condition\"][0]\n segmen2semantic = self.class_embedding[\n self.valid_index[self.conditions.index(condition)], :\n ]\n ray_segment = data_dict[\"ray_segment\"]\n ray_semantic = segmen2semantic[ray_segment.long()]\n ray_dict[\"semantic\"] = ray_semantic\n ray_dict[\"segment\"] = ray_segment\n return ray_dict", "probing input": " def prepare_ray(self, data_dict):\n def normalize_scene(coord, scene_bbox):\n scene_bbox = torch.tensor(scene_bbox).to(coord)\n norm_coord = (coord - scene_bbox[:3]) / (scene_bbox[3:] - scene_bbox[:3])\n return norm_coord\n\n condition = data_dict[\"condition\"][0]\n dataset_idx = self.conditions.index(condition)\n scene_bbox = self.scene_bbox[dataset_idx]\n # [0, 1]\n ray_start = normalize_scene(data_dict[\"ray_start\"], scene_bbox)\n ray_end = normalize_scene(data_dict[\"ray_end\"], scene_bbox)\n ray_d = F.normalize(ray_end - ray_start, dim=-1)\n", "probing input new": " def prepare_ray(self, data_dict):\n def normalize_scene(coord, scene_bbox):\n scene_bbox = torch.tensor(scene_bbox).to(coord)\n norm_coord = (coord - scene_bbox[:3]) / (scene_bbox[3:] - scene_bbox[:3])\n return norm_coord\n\n condition = data_dict[\"condition\"][0]\n dataset_idx = self.conditions.index(condition)\n scene_bbox = self.scene_bbox[dataset_idx]\n # [0, 1]\n ray_start = normalize_scene(data_dict[\"ray_start\"], scene_bbox)\n ray_end = normalize_scene(data_dict[\"ray_end\"], scene_bbox)\n ray_d = F.normalize(ray_end - ray_start, dim=-1)\n ray_depth = torch.", "reference": "ray_depth=torch.linalg.norm(ray_end-ray_start,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "ray_depth=torch.linalg.norm(ray_end-ray_start,dim=-1,keepdim=True)", "y_neg": " ray_depth = torch.norm(ray_end - ray_start, dim=-1)", "retain": " def prepare_ray(self, data_dict):\n def normalize_scene(coord, scene_bbox):\n scene_bbox = torch.tensor(scene_bbox).to(coord)\n norm_coord = (coord - scene_bbox[:3]) / (scene_bbox[3:] - scene_bbox[:3])\n return norm_coord\n\n condition = data_dict[\"condition\"][0]\n dataset_idx = self.conditions.index(condition)\n scene_bbox = self.scene_bbox[dataset_idx]\n # [0, 1]\n ray_start = normalize_scene(data_dict[\"ray_start\"], scene_bbox)\n ray_end = normalize_scene(data_dict[\"ray_end\"], scene_bbox)\n ray_d = F.normalize(ray_end - ray_start, dim=-1)\n ray_depth = torch.linalg.norm(ray_end - ray_start, dim=-1, keepdim=True)\n\n ray_dict = {\n \"ray_offset\": data_dict[\"ray_offset\"],\n \"ray_o\": ray_start,\n \"ray_d\": ray_d,\n \"depth\": ray_depth,\n }\n if \"ray_color\" in data_dict.keys():\n ray_dict[\"rgb\"] = data_dict[\"ray_color\"]\n if \"ray_segment\" in data_dict.keys() and self.render_semantic:\n assert (\n len(set(data_dict[\"condition\"])) == 1\n ), \"assume same condition in one batch\"\n condition = data_dict[\"condition\"][0]\n segmen2semantic = self.class_embedding[\n self.valid_index[self.conditions.index(condition)], :\n ]\n ray_segment = data_dict[\"ray_segment\"]\n ray_semantic = segmen2semantic[ray_segment.long()]\n ray_dict[\"semantic\"] = ray_semantic\n ray_dict[\"segment\"] = ray_segment\n return ray_dict" }, { "id": 7359, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lossFunction(xvPairs):\n stretchPenalty = 0\n for (i,(x_i,v_i)) in enumerate(xvPairs):\n x_fixed1 = x_i[attachmentIdx[0]*3:attachmentIdx[0]*3+3]\n x_fixed2 = x_i[attachmentIdx[1]*3:attachmentIdx[1]*3+3]\n clip_dist = torch.linalg.norm(x_fixed2-x_fixed1)\n stretchPenalty += torch.clamp(torch.abs(clip_dist - CLIP_REST_DIST) - 1.0, min=0.0, max=None) * 0.2\n\n directionPenalty, targetLoss, targetLast = 0, 0, 0\n for (x_last,v_i) in xvPairs:\n for (i, (idx1, idx2)) in enumerate(CLIP_DIR_VERTEX_PAIR):\n dir = x_last[idx1*3:idx1*3+3]-x_last[idx2*3:idx2*3+3]\n dirGoal = targetShape[idx1*3:idx1*3+3]- targetShape[idx2*3:idx2*3+3]\n dirGoaltorch = common.toTorchTensor(dirGoal, False, False)\n cosine = torch.clamp(torch.dot(torch.nn.functional.normalize(dir, dim=0), torch.nn.functional.normalize(dirGoaltorch, dim=0)), max=0.5, min=None)\n directionPenalty += (0.5 - cosine) * 3.0\n\n targetLoss += torch.nn.functional.smooth_l1_loss(x_last, targetshape_torch)\n targetLast = torch.nn.functional.smooth_l1_loss(xvPairs[-1][0], targetshape_torch)\n succeed = targetLast < 1.0\n\n loss = {'succeed': succeed, 'target' : targetLoss,'stretch' : stretchPenalty, 'direction' : directionPenalty, 'total' : stretchPenalty + targetLoss + directionPenalty}\n return loss", "probing input": "def lossFunction(xvPairs):\n stretchPenalty = 0\n for (i,(x_i,v_i)) in enumerate(xvPairs):\n x_fixed1 = x_i[attachmentIdx[0]*3:attachmentIdx[0]*3+3]\n x_fixed2 = x_i[attachmentIdx[1]*3:attachmentIdx[1]*3+3]\n", "probing input new": "def lossFunction(xvPairs):\n stretchPenalty = 0\n for (i,(x_i,v_i)) in enumerate(xvPairs):\n x_fixed1 = x_i[attachmentIdx[0]*3:attachmentIdx[0]*3+3]\n x_fixed2 = x_i[attachmentIdx[1]*3:attachmentIdx[1]*3+3]\n clip_dist = torch.", "reference": "clip_dist=torch.linalg.norm(x_fixed2-x_fixed1)", "reference dict": { "controller": "IndClosedController", "optimizer": "optim.Adam" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "clip_dist=torch.linalg.norm(x_fixed2-x_fixed1)", "y_neg": " clip_dist = torch.norm(x_fixed1 - x_fixed2, p='fro', dim=1)", "retain": "def lossFunction(xvPairs):\n stretchPenalty = 0\n for (i,(x_i,v_i)) in enumerate(xvPairs):\n x_fixed1 = x_i[attachmentIdx[0]*3:attachmentIdx[0]*3+3]\n x_fixed2 = x_i[attachmentIdx[1]*3:attachmentIdx[1]*3+3]\n clip_dist = torch.linalg.norm(x_fixed2-x_fixed1)\n stretchPenalty += torch.clamp(torch.abs(clip_dist - CLIP_REST_DIST) - 1.0, min=0.0, max=None) * 0.2\n\n directionPenalty, targetLoss, targetLast = 0, 0, 0\n for (x_last,v_i) in xvPairs:\n for (i, (idx1, idx2)) in enumerate(CLIP_DIR_VERTEX_PAIR):\n dir = x_last[idx1*3:idx1*3+3]-x_last[idx2*3:idx2*3+3]\n dirGoal = targetShape[idx1*3:idx1*3+3]- targetShape[idx2*3:idx2*3+3]\n dirGoaltorch = common.toTorchTensor(dirGoal, False, False)\n cosine = torch.clamp(torch.dot(torch.nn.functional.normalize(dir, dim=0), torch.nn.functional.normalize(dirGoaltorch, dim=0)), max=0.5, min=None)\n directionPenalty += (0.5 - cosine) * 3.0\n\n targetLoss += torch.nn.functional.smooth_l1_loss(x_last, targetshape_torch)\n targetLast = torch.nn.functional.smooth_l1_loss(xvPairs[-1][0], targetshape_torch)\n succeed = targetLast < 1.0\n\n loss = {'succeed': succeed, 'target' : targetLoss,'stretch' : stretchPenalty, 'direction' : directionPenalty, 'total' : stretchPenalty + targetLoss + directionPenalty}\n return loss" }, { "id": 7360, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def pixel_norm(x, eps=1e-6):\n \"\"\"Pixel Normalization.\n\n This normalization is proposed in:\n Progressive Growing of GANs for Improved Quality, Stability, and Variation\n\n Args:\n x (torch.Tensor): Tensor to be normalized.\n eps (float, optional): Epsilon to avoid dividing zero.\n Defaults to 1e-6.\n\n Returns:\n torch.Tensor: Normalized tensor.\n \"\"\"\n if torch.__version__ >= '1.7.0':\n norm = torch.linalg.norm(x, ord=2, dim=1, keepdim=True)\n # support older pytorch version\n else:\n norm = torch.norm(x, p=2, dim=1, keepdim=True)\n norm = norm / torch.sqrt(torch.tensor(x.shape[1]).to(x))\n\n return x / (norm + eps)", "probing input": "def pixel_norm(x, eps=1e-6):\n \"\"\"Pixel Normalization.\n\n This normalization is proposed in:\n Progressive Growing of GANs for Improved Quality, Stability, and Variation\n\n Args:\n x (torch.Tensor): Tensor to be normalized.\n eps (float, optional): Epsilon to avoid dividing zero.\n Defaults to 1e-6.\n\n Returns:\n torch.Tensor: Normalized tensor.\n \"\"\"\n if torch.__version__ >= '1.7.0':\n", "probing input new": "def pixel_norm(x, eps=1e-6):\n \"\"\"Pixel Normalization.\n\n This normalization is proposed in:\n Progressive Growing of GANs for Improved Quality, Stability, and Variation\n\n Args:\n x (torch.Tensor): Tensor to be normalized.\n eps (float, optional): Epsilon to avoid dividing zero.\n Defaults to 1e-6.\n\n Returns:\n torch.Tensor: Normalized tensor.\n \"\"\"\n if torch.__version__ >= '1.7.0':\n ", "reference": "norm=torch.linalg.norm(x,ord=2,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norm=torch.linalg.norm(x,ord=2,dim=1,keepdim=True)", "y_neg": " return x / (torch.norm(x, p='fro', dim=1, keepdim=True) + eps)", "retain": "def pixel_norm(x, eps=1e-6):\n \"\"\"Pixel Normalization.\n\n This normalization is proposed in:\n Progressive Growing of GANs for Improved Quality, Stability, and Variation\n\n Args:\n x (torch.Tensor): Tensor to be normalized.\n eps (float, optional): Epsilon to avoid dividing zero.\n Defaults to 1e-6.\n\n Returns:\n torch.Tensor: Normalized tensor.\n \"\"\"\n if torch.__version__ >= '1.7.0':\n norm = torch.linalg.norm(x, ord=2, dim=1, keepdim=True)\n # support older pytorch version\n else:\n norm = torch.norm(x, p=2, dim=1, keepdim=True)\n norm = norm / torch.sqrt(torch.tensor(x.shape[1]).to(x))\n\n return x / (norm + eps)" }, { "id": 7361, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def normalize(self, matches):\n dev = matches.device\n # The number of points in each minimal sample\n num_points = matches.shape[1]\n # Calculate the mass point for each minimal sample\n mass = torch.mean(matches, dim=1)\n # Substract the mass point of each minimal sample from the corresponding points in both images\n matches = matches - torch.unsqueeze(mass, 1).repeat(1, num_points, 1)\n # Calculate the distances from the mass point for each minimal sample in the source image\n distances1 = torch.linalg.norm(matches[:, :, :2], dim=2)\n # Calculate the distances from the mass point for each minimal sample in the destination image\n distances2 = torch.linalg.norm(matches[:, :, 2:], dim=2)\n # Calculate the average distances in the source image\n avg_distance1 = torch.mean(distances1, dim=1)\n # Calculate the average distances in the destination image\n avg_distance2 = torch.mean(distances2, dim=1)\n # Calculate the scaling to make the average distances sqrt(2) in the source image\n ratio1 = math.sqrt(2) / avg_distance1\n # Calculate the scaling to make the average distances sqrt(2) in the destination image\n ratio2 = math.sqrt(2) / avg_distance2\n\n # Calculate the normalized matches in the source image\n normalized_matches1 = matches[:, :, :2] * ratio1.view(-1, 1, 1).repeat(1, num_points, 2)\n # Calculate the normalized matches in the destination image\n normalized_matches2 = matches[:, :, 2:] * ratio2.view(-1, 1, 1).repeat(1, num_points, 2)\n\n # Initialize the normalizing transformations for each minimal sample in the source image\n T1 = torch.zeros((matches.shape[0], 3, 3), device=dev)\n # Initialize the normalizing transformations for each minimal sample in the destination image\n T2 = torch.zeros((matches.shape[0], 3, 3), device=dev)\n\n # Calculate the transformation parameters\n T1[:, 0, 0] = T1[:, 1, 1] = ratio1[:]\n T2[:, 0, 0] = T2[:, 1, 1] = ratio2[:]\n T1[:, 2, 2] = T2[:, 2, 2] = 1\n T1[:, 0, 2] = -ratio1 * mass[:, 0]\n T1[:, 1, 2] = -ratio1 * mass[:, 1]\n T2[:, 2, 0] = -ratio2 * mass[:, 2]\n T2[:, 2, 1] = -ratio2 * mass[:, 3]\n\n return torch.cat((normalized_matches1, normalized_matches2), dim=2), T1, T2", "probing input": " def normalize(self, matches):\n dev = matches.device\n # The number of points in each minimal sample\n num_points = matches.shape[1]\n # Calculate the mass point for each minimal sample\n mass = torch.mean(matches, dim=1)\n # Substract the mass point of each minimal sample from the corresponding points in both images\n matches = matches - torch.unsqueeze(mass, 1).repeat(1, num_points, 1)\n # Calculate the distances from the mass point for each minimal sample in the source image\n", "probing input new": " def normalize(self, matches):\n dev = matches.device\n # The number of points in each minimal sample\n num_points = matches.shape[1]\n # Calculate the mass point for each minimal sample\n mass = torch.mean(matches, dim=1)\n # Substract the mass point of each minimal sample from the corresponding points in both images\n matches = matches - torch.unsqueeze(mass, 1).repeat(1, num_points, 1)\n # Calculate the distances from the mass point for each minimal sample in the source image\n distances1 = torch.", "reference": "distances1=torch.linalg.norm(matches[:,:,:2],dim=2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distances1=torch.linalg.norm(matches[:,:,:2],dim=2)", "y_neg": " distances1 = torch.norm(matches, dim=2)", "retain": " def normalize(self, matches):\n dev = matches.device\n # The number of points in each minimal sample\n num_points = matches.shape[1]\n # Calculate the mass point for each minimal sample\n mass = torch.mean(matches, dim=1)\n # Substract the mass point of each minimal sample from the corresponding points in both images\n matches = matches - torch.unsqueeze(mass, 1).repeat(1, num_points, 1)\n # Calculate the distances from the mass point for each minimal sample in the source image\n distances1 = torch.linalg.norm(matches[:, :, :2], dim=2)\n # Calculate the distances from the mass point for each minimal sample in the destination image\n distances2 = torch.linalg.norm(matches[:, :, 2:], dim=2)\n # Calculate the average distances in the source image\n avg_distance1 = torch.mean(distances1, dim=1)\n # Calculate the average distances in the destination image\n avg_distance2 = torch.mean(distances2, dim=1)\n # Calculate the scaling to make the average distances sqrt(2) in the source image\n ratio1 = math.sqrt(2) / avg_distance1\n # Calculate the scaling to make the average distances sqrt(2) in the destination image\n ratio2 = math.sqrt(2) / avg_distance2\n\n # Calculate the normalized matches in the source image\n normalized_matches1 = matches[:, :, :2] * ratio1.view(-1, 1, 1).repeat(1, num_points, 2)\n # Calculate the normalized matches in the destination image\n normalized_matches2 = matches[:, :, 2:] * ratio2.view(-1, 1, 1).repeat(1, num_points, 2)\n\n # Initialize the normalizing transformations for each minimal sample in the source image\n T1 = torch.zeros((matches.shape[0], 3, 3), device=dev)\n # Initialize the normalizing transformations for each minimal sample in the destination image\n T2 = torch.zeros((matches.shape[0], 3, 3), device=dev)\n\n # Calculate the transformation parameters\n T1[:, 0, 0] = T1[:, 1, 1] = ratio1[:]\n T2[:, 0, 0] = T2[:, 1, 1] = ratio2[:]\n T1[:, 2, 2] = T2[:, 2, 2] = 1\n T1[:, 0, 2] = -ratio1 * mass[:, 0]\n T1[:, 1, 2] = -ratio1 * mass[:, 1]\n T2[:, 2, 0] = -ratio2 * mass[:, 2]\n T2[:, 2, 1] = -ratio2 * mass[:, 3]\n\n return torch.cat((normalized_matches1, normalized_matches2), dim=2), T1, T2" }, { "id": 7368, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, batch):\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n \n h_V = self.emb_in(batch.atoms) # (n,) -> (n, d)\n h_E = (\n self.radial_embedding(lengths), \n torch.nan_to_num(torch.div(vectors, lengths)).unsqueeze_(-2)\n )\n\n h_V = self.W_v(h_V)\n h_E = self.W_e(h_E)\n \n for layer in self.layers:\n h_V = layer(h_V, batch.edge_index, h_E)\n\n out = self.pool(gvp._merge(*h_V), batch.batch) # (n, d) -> (batch_size, d)\n \n if not self.equivariant_pred:\n # Select only scalars for invariant prediction\n out = out[:,:self.s_dim]\n \n return self.pred(out)", "probing input": " def forward(self, batch):\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n", "probing input new": " def forward(self, batch):\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.", "reference": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "reference dict": { "h_V": "self.W_v", "h_E": "self.W_e" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "y_neg": " lengths = torch.norm(vectors, dim=1) # [n_edges]", "retain": " def forward(self, batch):\n\n # Edge features\n vectors = batch.pos[batch.edge_index[0]] - batch.pos[batch.edge_index[1]] # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n \n h_V = self.emb_in(batch.atoms) # (n,) -> (n, d)\n h_E = (\n self.radial_embedding(lengths), \n torch.nan_to_num(torch.div(vectors, lengths)).unsqueeze_(-2)\n )\n\n h_V = self.W_v(h_V)\n h_E = self.W_e(h_E)\n \n for layer in self.layers:\n h_V = layer(h_V, batch.edge_index, h_E)\n\n out = self.pool(gvp._merge(*h_V), batch.batch) # (n, d) -> (batch_size, d)\n \n if not self.equivariant_pred:\n # Select only scalars for invariant prediction\n out = out[:,:self.s_dim]\n \n return self.pred(out)" }, { "id": 7374, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __getitem__(self, idxs: List[int]) -> Dict[str, object]:\n frame_dicts = []\n for i in idxs:\n sample = self.samples[i]\n frame_dict = self._getitem(sample)\n frame_dicts.append(frame_dict)\n\n dists = [torch.tensor(0)]\n for i in range(1, len(frame_dicts)):\n # Get the relative distance from the prev sample to the curr sample\n curr_fd = frame_dicts[i]\n prev_fd = frame_dicts[i - 1]\n dist = torch.linalg.norm(curr_fd[\"cam_T\"][:3, 3] - prev_fd[\"cam_T\"][:3, 3])\n dists.append(dist)\n\n cam_Ts = [fd[\"cam_T\"] for fd in frame_dicts]\n\n frame_Ts = [torch.eye(4)]\n for i in range(1, len(frame_dicts)):\n # Get the relative frame_T for this frame by comparing the current cam_T to the previous cam_T\n frame_T = torch.linalg.solve(cam_Ts[i - 1], cam_Ts[i])\n # TODO use torch.solve instead\n # frame_T = torch.linalg.solve(cam_Ts[i], cam_Ts[i - 1])[0]\n frame_Ts.append(frame_T)\n\n imgs = [fd[\"color\"] for fd in frame_dicts]\n token = [fd[\"token\"] for fd in frame_dicts]\n\n # timestamp is in microseconds, need to convert it to seconds and\n # normalize to first frame\n frame_time = torch.tensor(\n [fd[\"frame_time\"] for fd in frame_dicts], dtype=torch.int64\n )\n\n long_cam_Ts = [\n get_ego_T(self.nusc, sample_data) for sample_data in self.samples[idxs[0] :]\n ]\n\n mask_transform = transforms.Compose(\n [\n transforms.PILToTensor(),\n transforms.ConvertImageDtype(\n torch.bfloat16\n ), # drop precision to save memory\n ]\n )\n mask_path = os.path.join(\n os.path.dirname(__file__),\n \"nuscenes_masks\",\n f\"{self.sensor}.png\",\n )\n mask = Image.open(mask_path).convert(\"L\")\n mask = mask_transform(mask)\n assert mask.shape == (1, 480, 640), mask.shape\n\n return {\n \"weight\": torch.tensor(frame_dicts[0][\"weight\"]),\n \"distance\": torch.stack(dists),\n \"cam_T\": torch.stack(cam_Ts),\n \"frame_T\": torch.stack(frame_Ts),\n \"long_cam_T\": torch.stack(long_cam_Ts),\n \"frame_time\": frame_time,\n \"K\": frame_dicts[0][\n \"K\"\n ], # only one cam to pixel matrix is required as it doesn't change during drive\n \"T\": frame_dicts[0][\n \"T\"\n ], # only one cam to car translation matrix is required as it doesn't change during drive\n \"color\": torch.stack(imgs),\n \"mask\": mask,\n \"token\": token,\n }", "probing input": " def __getitem__(self, idxs: List[int]) -> Dict[str, object]:\n frame_dicts = []\n for i in idxs:\n sample = self.samples[i]\n frame_dict = self._getitem(sample)\n frame_dicts.append(frame_dict)\n\n dists = [torch.tensor(0)]\n for i in range(1, len(frame_dicts)):\n # Get the relative distance from the prev sample to the curr sample\n curr_fd = frame_dicts[i]\n prev_fd = frame_dicts[i - 1]\n", "probing input new": " def __getitem__(self, idxs: List[int]) -> Dict[str, object]:\n frame_dicts = []\n for i in idxs:\n sample = self.samples[i]\n frame_dict = self._getitem(sample)\n frame_dicts.append(frame_dict)\n\n dists = [torch.tensor(0)]\n for i in range(1, len(frame_dicts)):\n # Get the relative distance from the prev sample to the curr sample\n curr_fd = frame_dicts[i]\n prev_fd = frame_dicts[i - 1]\n dist = torch.", "reference": "dist=torch.linalg.norm(curr_fd[\"cam_T\"][:3,3]-prev_fd[\"cam_T\"][:3,3])", "reference dict": { "T_co": "TypeVar", "mask_transform": "transforms.Compose" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(curr_fd[\"cam_T\"][:3,3]-prev_fd[\"cam_T\"][:3,3])", "y_neg": " dist = torch.norm(curr_fd['position'] - prev_fd['position'])", "retain": " def __getitem__(self, idxs: List[int]) -> Dict[str, object]:\n frame_dicts = []\n for i in idxs:\n sample = self.samples[i]\n frame_dict = self._getitem(sample)\n frame_dicts.append(frame_dict)\n\n dists = [torch.tensor(0)]\n for i in range(1, len(frame_dicts)):\n # Get the relative distance from the prev sample to the curr sample\n curr_fd = frame_dicts[i]\n prev_fd = frame_dicts[i - 1]\n dist = torch.linalg.norm(curr_fd[\"cam_T\"][:3, 3] - prev_fd[\"cam_T\"][:3, 3])\n dists.append(dist)\n\n cam_Ts = [fd[\"cam_T\"] for fd in frame_dicts]\n\n frame_Ts = [torch.eye(4)]\n for i in range(1, len(frame_dicts)):\n # Get the relative frame_T for this frame by comparing the current cam_T to the previous cam_T\n frame_T = torch.linalg.solve(cam_Ts[i - 1], cam_Ts[i])\n # TODO use torch.solve instead\n # frame_T = torch.linalg.solve(cam_Ts[i], cam_Ts[i - 1])[0]\n frame_Ts.append(frame_T)\n\n imgs = [fd[\"color\"] for fd in frame_dicts]\n token = [fd[\"token\"] for fd in frame_dicts]\n\n # timestamp is in microseconds, need to convert it to seconds and\n # normalize to first frame\n frame_time = torch.tensor(\n [fd[\"frame_time\"] for fd in frame_dicts], dtype=torch.int64\n )\n\n long_cam_Ts = [\n get_ego_T(self.nusc, sample_data) for sample_data in self.samples[idxs[0] :]\n ]\n\n mask_transform = transforms.Compose(\n [\n transforms.PILToTensor(),\n transforms.ConvertImageDtype(\n torch.bfloat16\n ), # drop precision to save memory\n ]\n )\n mask_path = os.path.join(\n os.path.dirname(__file__),\n \"nuscenes_masks\",\n f\"{self.sensor}.png\",\n )\n mask = Image.open(mask_path).convert(\"L\")\n mask = mask_transform(mask)\n assert mask.shape == (1, 480, 640), mask.shape\n\n return {\n \"weight\": torch.tensor(frame_dicts[0][\"weight\"]),\n \"distance\": torch.stack(dists),\n \"cam_T\": torch.stack(cam_Ts),\n \"frame_T\": torch.stack(frame_Ts),\n \"long_cam_T\": torch.stack(long_cam_Ts),\n \"frame_time\": frame_time,\n \"K\": frame_dicts[0][\n \"K\"\n ], # only one cam to pixel matrix is required as it doesn't change during drive\n \"T\": frame_dicts[0][\n \"T\"\n ], # only one cam to car translation matrix is required as it doesn't change during drive\n \"color\": torch.stack(imgs),\n \"mask\": mask,\n \"token\": token,\n }" }, { "id": 7386, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def generate_rays(self, pixels_xys, intrinsics, c2ws):\n \"\"\"\n\n Parameters\n ----------\n pixels_xys : [N_views, N_num, 2]\n intrinsics : [N_views, 3, 3]\n c2ws : [N_views, 4, 4]\n\n Returns\n -------\n\n \"\"\"\n intrinsics_inv = torch.inverse(intrinsics)\n p = torch.cat([pixels_xys, torch.ones_like(pixels_xys[:, :, :1])], dim=-1) # N_views, n, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, :, None]).squeeze() # N_views, n, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_views, n, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # N_views, n, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # N_views, n, 3\n return rays_o, rays_v", "probing input": " def generate_rays(self, pixels_xys, intrinsics, c2ws):\n \"\"\"\n\n Parameters\n ----------\n pixels_xys : [N_views, N_num, 2]\n intrinsics : [N_views, 3, 3]\n c2ws : [N_views, 4, 4]\n\n Returns\n -------\n\n \"\"\"\n intrinsics_inv = torch.inverse(intrinsics)\n p = torch.cat([pixels_xys, torch.ones_like(pixels_xys[:, :, :1])], dim=-1) # N_views, n, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, :, None]).squeeze() # N_views, n, 3\n", "probing input new": " def generate_rays(self, pixels_xys, intrinsics, c2ws):\n \"\"\"\n\n Parameters\n ----------\n pixels_xys : [N_views, N_num, 2]\n intrinsics : [N_views, 3, 3]\n c2ws : [N_views, 4, 4]\n\n Returns\n -------\n\n \"\"\"\n intrinsics_inv = torch.inverse(intrinsics)\n p = torch.cat([pixels_xys, torch.ones_like(pixels_xys[:, :, :1])], dim=-1) # N_views, n, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, :, None]).squeeze() # N_views, n, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # N_views, n, 3", "retain": " def generate_rays(self, pixels_xys, intrinsics, c2ws):\n \"\"\"\n\n Parameters\n ----------\n pixels_xys : [N_views, N_num, 2]\n intrinsics : [N_views, 3, 3]\n c2ws : [N_views, 4, 4]\n\n Returns\n -------\n\n \"\"\"\n intrinsics_inv = torch.inverse(intrinsics)\n p = torch.cat([pixels_xys, torch.ones_like(pixels_xys[:, :, :1])], dim=-1) # N_views, n, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, :, None]).squeeze() # N_views, n, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_views, n, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # N_views, n, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # N_views, n, 3\n return rays_o, rays_v" }, { "id": 7393, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def train(self):\n self.writer = SummaryWriter(log_dir=os.path.join(self.base_exp_dir, 'logs'))\n self.update_learning_rate()\n res_step = self.end_iter - self.iter_step\n\n for iter_i in tqdm(range(res_step)):\n self.hair_network.embed_fn_fine.current_iter = self.iter_step\n self.sdf_network.embed_fn_fine.current_iter = self.iter_step\n self.color_network.embedview_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn_view.current_iter = self.iter_step\n\n data, cam_intr_0, cam_pose_0, image_index = self.sample_rays()\n\n pixels, radii, true_rgb, mask, hair_mask, orient_angle, orient_conf = data.split([3, 1, 3, 1, 1, 1, 1], dim=1)\n \n if self.camera_model is not None and self.iter_step > self.tune_cameras_start:\n cam_intr_, cam_pose_ = self.camera_model(image_index, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, :3, :3], pixels[:, :, None]).squeeze() if len(cam_intr_.shape) < 3 else torch.matmul(torch.linalg.inv(cam_intr_)[:, :3, :3], pixels[:, :, None]).squeeze() # batch_size, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_d = torch.matmul(cam_pose_[None, :3, :3], rays_d[:, :, None]).squeeze() if len(cam_pose_.shape) < 3 else torch.matmul(cam_pose_[:, :3, :3], rays_d[:, :, None]).squeeze()# batch_size, 3\n if len(cam_pose_.shape) < 3: \n rays_o = cam_pose_[None, :3, 3].expand(rays_d.shape) # batch_size, 3\n elif cam_pose_.shape[0] == 1:\n rays_o = cam_pose_[:, :3, 3].expand(rays_d.shape) \n else:\n rays_o = cam_pose_[:, :3, 3]\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n\n near, far = self.dataset.near_far_from_sphere(rays_o.detach(), rays_d.detach())\n\n \n background_rgb = None\n if self.use_white_bkgd:\n background_rgb = torch.ones([1, 3])\n\n if self.mask_weight > 0.0:\n if self.conf['train']['binarize_gt_masks']:\n mask = (mask > 0.5).float()\n else:\n mask = torch.ones_like(mask)\n \n if self.hair_mask_weight > 0.0:\n if self.conf['train']['binarize_gt_masks']:\n hair_mask = (hair_mask > 0.5).float()\n else:\n hair_mask = torch.ones_like(mask)\n\n mask_sum = mask.sum() + 1e-5\n hair_mask_sum = hair_mask.sum() + 1e-5\n\n render_out = self.renderer.render(rays_o, rays_d, radii, near, far,\n background_rgb=background_rgb,\n cos_anneal_ratio=self.get_cos_anneal_ratio())\n\n color_fine = render_out['color_fine']\n s_val_head = render_out['s_val_head']\n cdf_head = render_out['cdf_head']\n gradient_error_head = render_out['gradient_error_head']\n weight_max = render_out['weight_max']\n weight_sum = render_out['weight_sum']\n \n s_val_hair = render_out['s_val_hair']\n sampled_orient_fine = render_out['sampled_orient_fine']\n pts_fine = render_out['pts_fine']\n\n weights_hair = render_out['weights_hair']\n weight_hair_max = render_out['weight_hair_max']\n weight_hair_sum = render_out['weight_hair_sum']\n\n cdf_hair = gradient_error_hair = None\n\n cdf_hair = render_out['cdf_hair']\n gradient_error_hair = render_out['gradient_error_hair']\n\n # Loss\n color_error = (color_fine - true_rgb) * mask\n color_fine_loss = F.l1_loss(color_error, torch.zeros_like(color_error), reduction='sum') / mask_sum\n \n color_error_hair = (color_fine - true_rgb) * hair_mask\n color_hair_fine_loss = F.l1_loss(color_error, torch.zeros_like(color_error), reduction='sum') / hair_mask_sum\n \n psnr = 20.0 * torch.log10(1.0 / (((color_fine - true_rgb)**2 * mask).sum() / (mask_sum * 3.0)).sqrt())\n\n eikonal_loss_head = gradient_error_head\n\n\n mask_fine_loss = F.binary_cross_entropy(weight_sum.clip(1e-3, 1.0 - 1e-3), mask)\n\n loss = color_fine_loss +\\\n eikonal_loss_head * self.igr_weight +\\\n mask_fine_loss * self.mask_weight\n\n \n orient_fine_loss = orient_coarse_loss = 0.0\n\n if self.orient_weight:\n\n orient_angle_fine = project_orient_to_camera(orient_3d=sampled_orient_fine, org_3d=pts_fine, cam_intr=cam_intr, cam_extr=cam_extr)\n\n # Get masks for orientation loss\n orient_mask = hair_mask\n if self.conf['train']['orient_use_conf']:\n orient_mask = orient_mask * orient_conf \n\n orient_mask_sum = orient_mask.sum() + 1e-5\n orient_fine_error = torch.min((orient_angle_fine - orient_angle).abs(),\n torch.min((orient_angle_fine - orient_angle - np.pi).abs(), \n (orient_angle_fine - orient_angle + np.pi).abs()))\n orient_fine_error = orient_fine_error * orient_mask \n orient_fine_loss = orient_fine_error.mean() * (orient_fine_error.shape[0] / orient_mask_sum)\n\n hair_mask_fine_loss = F.binary_cross_entropy(weight_hair_sum.clip(1e-3, 1.0 - 1e-3), hair_mask)\n\n\n loss += hair_mask_fine_loss * self.mask_weight\n\n if self.orient_weight:\n loss += orient_fine_loss * self.orient_weight\n\n if self.head_prior_reg_weight:\n loss += self.head_prior_reg_weight * render_out['head_prior_inside_points'].mean()\n if self.head_prior_off_sdf_weight:\n loss += self.head_prior_off_sdf_weight * render_out['head_prior_off_sdf']\n if self.head_prior_normal_weight:\n loss += self.head_prior_normal_weight * render_out['head_prior_normal']\n if self.head_prior_sdf_weight:\n loss += self.head_prior_sdf_weight * render_out['head_prior_sdf']\n\n eikonal_loss_hair = gradient_error_hair\n loss += eikonal_loss_hair * self.igr_weight\n\n \n self.optimizer.zero_grad()\n if self.camera_model is not None and self.iter_step > self.tune_cameras_start and self.iter_step < self.tune_cameras_end:\n self.optimizer_camera.zero_grad()\n loss.backward()\n self.optimizer.step()\n if self.camera_model is not None and self.iter_step > self.tune_cameras_start and self.iter_step < self.tune_cameras_end:\n self.optimizer_camera.step()\n \n losses = {}\n\n self.iter_step += 1\n \n self.writer.add_scalar('Loss/hair_mask_fine_loss', hair_mask_fine_loss, self.iter_step)\n if self.orient_weight:\n self.writer.add_scalar('Loss/orient_loss', orient_fine_loss, self.iter_step)\n self.writer.add_scalar('Statistics/hair_weight_max', (weight_hair_max * hair_mask).sum() / hair_mask_sum, self.iter_step)\n\n if self.head_prior_reg_weight:\n self.writer.add_scalar('Loss/head_prior_reg_loss', render_out['head_prior_inside_points'].mean(), self.iter_step)\n self.writer.add_scalar('Loss/num_inside_points', render_out['num_inside_points'], self.iter_step)\n if self.head_prior_off_sdf_weight:\n self.writer.add_scalar('Loss/head_prior_off_sdf', render_out['head_prior_off_sdf'], self.iter_step)\n if self.head_prior_normal_weight:\n self.writer.add_scalar('Loss/head_prior_normal', render_out['head_prior_normal'], self.iter_step)\n if self.head_prior_sdf_weight:\n self.writer.add_scalar('Loss/head_prior_sdf', render_out['head_prior_sdf'], self.iter_step)\n\n self.writer.add_scalar('Statistics/s_val_hair', s_val_hair.mean(), self.iter_step)\n\n self.writer.add_scalar('Loss/eikonal_loss_hair', eikonal_loss_hair, self.iter_step)\n self.writer.add_scalar('Statistics/cdf_hair', (cdf_hair[:, :1] * hair_mask).sum() / hair_mask_sum, self.iter_step)\n\n self.writer.add_scalar('Loss/loss', loss, self.iter_step)\n self.writer.add_scalar('Loss/color_fine_loss', color_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/color_fine_hair_loss', color_hair_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/mask_fine_loss', mask_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/eikonal_loss_head', eikonal_loss_head, self.iter_step)\n self.writer.add_scalar('Statistics/s_val_head', s_val_head.mean(), self.iter_step)\n self.writer.add_scalar('Statistics/cdf_head', (cdf_head[:, :1] * mask).sum() / mask_sum, self.iter_step)\n self.writer.add_scalar('Statistics/weight_max', (weight_max * mask).sum() / mask_sum, self.iter_step)\n self.writer.add_scalar('Statistics/psnr', psnr, self.iter_step)\n if losses is not None:\n for k, v in losses.items():\n self.writer.add_scalar(f'Loss/{k}', v, self.iter_step)\n\n if self.iter_step % self.report_freq == 0:\n print(self.base_exp_dir)\n print('iter:{:8>d} loss = {} lr={}'.format(self.iter_step, loss, self.optimizer.param_groups[0]['lr']))\n\n if self.iter_step % self.save_freq == 0:\n self.save_checkpoint()\n\n if self.iter_step % self.val_freq == 0:\n self.validate_image()\n\n if self.iter_step % self.val_mesh_freq == 0:\n self.validate_mesh(resolution=self.val_mesh_resolution, filter=False)\n \n if self.orient_weight:\n if self.iter_step % self.val_orients_freq == 0: \n self.validate_orientation(resolution=self.val_orients_resolution)\n\n self.update_learning_rate()", "probing input": " def train(self):\n self.writer = SummaryWriter(log_dir=os.path.join(self.base_exp_dir, 'logs'))\n self.update_learning_rate()\n res_step = self.end_iter - self.iter_step\n\n for iter_i in tqdm(range(res_step)):\n self.hair_network.embed_fn_fine.current_iter = self.iter_step\n self.sdf_network.embed_fn_fine.current_iter = self.iter_step\n self.color_network.embedview_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn_view.current_iter = self.iter_step\n\n data, cam_intr_0, cam_pose_0, image_index = self.sample_rays()\n\n pixels, radii, true_rgb, mask, hair_mask, orient_angle, orient_conf = data.split([3, 1, 3, 1, 1, 1, 1], dim=1)\n \n if self.camera_model is not None and self.iter_step > self.tune_cameras_start:\n cam_intr_, cam_pose_ = self.camera_model(image_index, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, :3, :3], pixels[:, :, None]).squeeze() if len(cam_intr_.shape) < 3 else torch.matmul(torch.linalg.inv(cam_intr_)[:, :3, :3], pixels[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def train(self):\n self.writer = SummaryWriter(log_dir=os.path.join(self.base_exp_dir, 'logs'))\n self.update_learning_rate()\n res_step = self.end_iter - self.iter_step\n\n for iter_i in tqdm(range(res_step)):\n self.hair_network.embed_fn_fine.current_iter = self.iter_step\n self.sdf_network.embed_fn_fine.current_iter = self.iter_step\n self.color_network.embedview_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn_view.current_iter = self.iter_step\n\n data, cam_intr_0, cam_pose_0, image_index = self.sample_rays()\n\n pixels, radii, true_rgb, mask, hair_mask, orient_angle, orient_conf = data.split([3, 1, 3, 1, 1, 1, 1], dim=1)\n \n if self.camera_model is not None and self.iter_step > self.tune_cameras_start:\n cam_intr_, cam_pose_ = self.camera_model(image_index, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, :3, :3], pixels[:, :, None]).squeeze() if len(cam_intr_.shape) < 3 else torch.matmul(torch.linalg.inv(cam_intr_)[:, :3, :3], pixels[:, :, None]).squeeze() # batch_size, 3\n rays_d = p / torch.", "reference": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "self.writer": "SummaryWriter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_d = p / torch.norm(p, dim=-1, keepdim=True)", "retain": " def train(self):\n self.writer = SummaryWriter(log_dir=os.path.join(self.base_exp_dir, 'logs'))\n self.update_learning_rate()\n res_step = self.end_iter - self.iter_step\n\n for iter_i in tqdm(range(res_step)):\n self.hair_network.embed_fn_fine.current_iter = self.iter_step\n self.sdf_network.embed_fn_fine.current_iter = self.iter_step\n self.color_network.embedview_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn.current_iter = self.iter_step\n self.nerf_outside.embed_fn_view.current_iter = self.iter_step\n\n data, cam_intr_0, cam_pose_0, image_index = self.sample_rays()\n\n pixels, radii, true_rgb, mask, hair_mask, orient_angle, orient_conf = data.split([3, 1, 3, 1, 1, 1, 1], dim=1)\n \n if self.camera_model is not None and self.iter_step > self.tune_cameras_start:\n cam_intr_, cam_pose_ = self.camera_model(image_index, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, :3, :3], pixels[:, :, None]).squeeze() if len(cam_intr_.shape) < 3 else torch.matmul(torch.linalg.inv(cam_intr_)[:, :3, :3], pixels[:, :, None]).squeeze() # batch_size, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_d = torch.matmul(cam_pose_[None, :3, :3], rays_d[:, :, None]).squeeze() if len(cam_pose_.shape) < 3 else torch.matmul(cam_pose_[:, :3, :3], rays_d[:, :, None]).squeeze()# batch_size, 3\n if len(cam_pose_.shape) < 3: \n rays_o = cam_pose_[None, :3, 3].expand(rays_d.shape) # batch_size, 3\n elif cam_pose_.shape[0] == 1:\n rays_o = cam_pose_[:, :3, 3].expand(rays_d.shape) \n else:\n rays_o = cam_pose_[:, :3, 3]\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n\n near, far = self.dataset.near_far_from_sphere(rays_o.detach(), rays_d.detach())\n\n \n background_rgb = None\n if self.use_white_bkgd:\n background_rgb = torch.ones([1, 3])\n\n if self.mask_weight > 0.0:\n if self.conf['train']['binarize_gt_masks']:\n mask = (mask > 0.5).float()\n else:\n mask = torch.ones_like(mask)\n \n if self.hair_mask_weight > 0.0:\n if self.conf['train']['binarize_gt_masks']:\n hair_mask = (hair_mask > 0.5).float()\n else:\n hair_mask = torch.ones_like(mask)\n\n mask_sum = mask.sum() + 1e-5\n hair_mask_sum = hair_mask.sum() + 1e-5\n\n render_out = self.renderer.render(rays_o, rays_d, radii, near, far,\n background_rgb=background_rgb,\n cos_anneal_ratio=self.get_cos_anneal_ratio())\n\n color_fine = render_out['color_fine']\n s_val_head = render_out['s_val_head']\n cdf_head = render_out['cdf_head']\n gradient_error_head = render_out['gradient_error_head']\n weight_max = render_out['weight_max']\n weight_sum = render_out['weight_sum']\n \n s_val_hair = render_out['s_val_hair']\n sampled_orient_fine = render_out['sampled_orient_fine']\n pts_fine = render_out['pts_fine']\n\n weights_hair = render_out['weights_hair']\n weight_hair_max = render_out['weight_hair_max']\n weight_hair_sum = render_out['weight_hair_sum']\n\n cdf_hair = gradient_error_hair = None\n\n cdf_hair = render_out['cdf_hair']\n gradient_error_hair = render_out['gradient_error_hair']\n\n # Loss\n color_error = (color_fine - true_rgb) * mask\n color_fine_loss = F.l1_loss(color_error, torch.zeros_like(color_error), reduction='sum') / mask_sum\n \n color_error_hair = (color_fine - true_rgb) * hair_mask\n color_hair_fine_loss = F.l1_loss(color_error, torch.zeros_like(color_error), reduction='sum') / hair_mask_sum\n \n psnr = 20.0 * torch.log10(1.0 / (((color_fine - true_rgb)**2 * mask).sum() / (mask_sum * 3.0)).sqrt())\n\n eikonal_loss_head = gradient_error_head\n\n\n mask_fine_loss = F.binary_cross_entropy(weight_sum.clip(1e-3, 1.0 - 1e-3), mask)\n\n loss = color_fine_loss +\\\n eikonal_loss_head * self.igr_weight +\\\n mask_fine_loss * self.mask_weight\n\n \n orient_fine_loss = orient_coarse_loss = 0.0\n\n if self.orient_weight:\n\n orient_angle_fine = project_orient_to_camera(orient_3d=sampled_orient_fine, org_3d=pts_fine, cam_intr=cam_intr, cam_extr=cam_extr)\n\n # Get masks for orientation loss\n orient_mask = hair_mask\n if self.conf['train']['orient_use_conf']:\n orient_mask = orient_mask * orient_conf \n\n orient_mask_sum = orient_mask.sum() + 1e-5\n orient_fine_error = torch.min((orient_angle_fine - orient_angle).abs(),\n torch.min((orient_angle_fine - orient_angle - np.pi).abs(), \n (orient_angle_fine - orient_angle + np.pi).abs()))\n orient_fine_error = orient_fine_error * orient_mask \n orient_fine_loss = orient_fine_error.mean() * (orient_fine_error.shape[0] / orient_mask_sum)\n\n hair_mask_fine_loss = F.binary_cross_entropy(weight_hair_sum.clip(1e-3, 1.0 - 1e-3), hair_mask)\n\n\n loss += hair_mask_fine_loss * self.mask_weight\n\n if self.orient_weight:\n loss += orient_fine_loss * self.orient_weight\n\n if self.head_prior_reg_weight:\n loss += self.head_prior_reg_weight * render_out['head_prior_inside_points'].mean()\n if self.head_prior_off_sdf_weight:\n loss += self.head_prior_off_sdf_weight * render_out['head_prior_off_sdf']\n if self.head_prior_normal_weight:\n loss += self.head_prior_normal_weight * render_out['head_prior_normal']\n if self.head_prior_sdf_weight:\n loss += self.head_prior_sdf_weight * render_out['head_prior_sdf']\n\n eikonal_loss_hair = gradient_error_hair\n loss += eikonal_loss_hair * self.igr_weight\n\n \n self.optimizer.zero_grad()\n if self.camera_model is not None and self.iter_step > self.tune_cameras_start and self.iter_step < self.tune_cameras_end:\n self.optimizer_camera.zero_grad()\n loss.backward()\n self.optimizer.step()\n if self.camera_model is not None and self.iter_step > self.tune_cameras_start and self.iter_step < self.tune_cameras_end:\n self.optimizer_camera.step()\n \n losses = {}\n\n self.iter_step += 1\n \n self.writer.add_scalar('Loss/hair_mask_fine_loss', hair_mask_fine_loss, self.iter_step)\n if self.orient_weight:\n self.writer.add_scalar('Loss/orient_loss', orient_fine_loss, self.iter_step)\n self.writer.add_scalar('Statistics/hair_weight_max', (weight_hair_max * hair_mask).sum() / hair_mask_sum, self.iter_step)\n\n if self.head_prior_reg_weight:\n self.writer.add_scalar('Loss/head_prior_reg_loss', render_out['head_prior_inside_points'].mean(), self.iter_step)\n self.writer.add_scalar('Loss/num_inside_points', render_out['num_inside_points'], self.iter_step)\n if self.head_prior_off_sdf_weight:\n self.writer.add_scalar('Loss/head_prior_off_sdf', render_out['head_prior_off_sdf'], self.iter_step)\n if self.head_prior_normal_weight:\n self.writer.add_scalar('Loss/head_prior_normal', render_out['head_prior_normal'], self.iter_step)\n if self.head_prior_sdf_weight:\n self.writer.add_scalar('Loss/head_prior_sdf', render_out['head_prior_sdf'], self.iter_step)\n\n self.writer.add_scalar('Statistics/s_val_hair', s_val_hair.mean(), self.iter_step)\n\n self.writer.add_scalar('Loss/eikonal_loss_hair', eikonal_loss_hair, self.iter_step)\n self.writer.add_scalar('Statistics/cdf_hair', (cdf_hair[:, :1] * hair_mask).sum() / hair_mask_sum, self.iter_step)\n\n self.writer.add_scalar('Loss/loss', loss, self.iter_step)\n self.writer.add_scalar('Loss/color_fine_loss', color_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/color_fine_hair_loss', color_hair_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/mask_fine_loss', mask_fine_loss, self.iter_step)\n self.writer.add_scalar('Loss/eikonal_loss_head', eikonal_loss_head, self.iter_step)\n self.writer.add_scalar('Statistics/s_val_head', s_val_head.mean(), self.iter_step)\n self.writer.add_scalar('Statistics/cdf_head', (cdf_head[:, :1] * mask).sum() / mask_sum, self.iter_step)\n self.writer.add_scalar('Statistics/weight_max', (weight_max * mask).sum() / mask_sum, self.iter_step)\n self.writer.add_scalar('Statistics/psnr', psnr, self.iter_step)\n if losses is not None:\n for k, v in losses.items():\n self.writer.add_scalar(f'Loss/{k}', v, self.iter_step)\n\n if self.iter_step % self.report_freq == 0:\n print(self.base_exp_dir)\n print('iter:{:8>d} loss = {} lr={}'.format(self.iter_step, loss, self.optimizer.param_groups[0]['lr']))\n\n if self.iter_step % self.save_freq == 0:\n self.save_checkpoint()\n\n if self.iter_step % self.val_freq == 0:\n self.validate_image()\n\n if self.iter_step % self.val_mesh_freq == 0:\n self.validate_mesh(resolution=self.val_mesh_resolution, filter=False)\n \n if self.orient_weight:\n if self.iter_step % self.val_orients_freq == 0: \n self.validate_orientation(resolution=self.val_orients_resolution)\n\n self.update_learning_rate()" }, { "id": 7394, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def validate_image(self, idx=-1, resolution_level=-1):\n if idx < 0:\n idx = np.random.randint(self.dataset.n_images)\n print('Validate: iter: {}, camera: {}'.format(self.iter_step, idx))\n\n if resolution_level < 0:\n resolution_level = self.val_render_resolution_level \n pixels, radii, orient_angle, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(idx, resolution_level=resolution_level)\n # print('before cam model', cam_intr_0.shape, cam_pose_0.shape)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(torch.tensor([idx]), cam_intr_0, cam_pose_0)\n cam_intr_ = cam_intr_[0]\n cam_pose_ = cam_pose_[0]\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_d = torch.matmul(cam_pose_[None, None, :3, :3], rays_d[:, :, :, None]).squeeze() # W, H, 3\n rays_o = cam_pose_[None, None, :3, 3].expand(rays_d.shape) # W, H, 3\n\n H, W, _ = rays_o.shape\n\n rays_o = rays_o.transpose(0, 1).reshape(-1, 3).split(self.batch_size)\n rays_d = rays_d.transpose(0, 1).reshape(-1, 3).split(self.batch_size)\n \n radii = radii.reshape(-1, 1).split(self.batch_size)\n orient_angle = orient_angle.reshape(-1, 3).split(self.batch_size)\n\n out_rgb_fine = []\n out_orient_fine = []\n out_normal_fine = []\n out_normal_hair_fine = []\n \n for rays_o_batch, rays_d_batch, radii_batch, orient_angle_batch in zip(rays_o, rays_d, radii, orient_angle):\n near, far = self.dataset.near_far_from_sphere(rays_o_batch, rays_d_batch)\n background_rgb = torch.ones([1, 3]) if self.use_white_bkgd else None\n\n render_out = self.renderer.render(rays_o_batch,\n rays_d_batch,\n radii_batch,\n near,\n far,\n cos_anneal_ratio=self.get_cos_anneal_ratio(),\n background_rgb=background_rgb)\n\n color_fine = render_out['color_fine'].detach().cpu().numpy()\n\n\n def feasible(key): return (key in render_out) and (render_out[key] is not None)\n\n if feasible('color_fine'):\n out_rgb_fine.append(color_fine)\n\n if self.orient_weight:\n if feasible('sampled_orient_fine'):\n # Project orientations into camera\n orient_angle_fine = project_orient_to_camera(orient_3d=render_out['sampled_orient_fine'], org_3d=render_out['pts_fine'], cam_intr=cam_intr, cam_extr=cam_extr)\n \n orient_cos_fine = orient_angle_fine.cos()\n orient_fine_cam = torch.cat(\n [\n orient_cos_fine * (orient_cos_fine >= 0),\n orient_angle_fine.sin(),\n orient_cos_fine.abs() * (orient_cos_fine < 0)\n ],\n dim=1\n )\n out_orient_fine.append(orient_fine_cam.cpu().numpy()) \n \n if feasible('gradients_head') and feasible('weights'):\n n_samples = self.renderer.n_samples + self.renderer.n_importance\n normals = render_out['gradients_head'] * render_out['weights'][:, :n_samples, None]\n if feasible('inside_sphere'):\n normals = normals * render_out['inside_sphere'][..., None]\n\n normals = normals.sum(dim=1).detach().cpu().numpy()\n out_normal_fine.append(normals)\n\n if feasible('gradients_hair') and feasible('weights'):\n n_samples = self.renderer.n_samples + self.renderer.n_importance\n normals_hair = render_out['gradients_hair'] * render_out['weights'][:, :n_samples, None]\n if feasible('inside_sphere'):\n normals_hair = normals_hair * render_out['inside_sphere'][..., None]\n\n normals_hair = normals_hair.sum(dim=1).detach().cpu().numpy()\n out_normal_hair_fine.append(normals_hair) \n \n del render_out\n\n img_fine = None\n orient_fine = None\n \n if out_rgb_fine:\n img_fine = (np.concatenate(out_rgb_fine, axis=0).reshape([H, W, 3, -1]) * 255).clip(0, 255)\n if self.orient_weight: \n if out_orient_fine:\n orient_fine = (np.concatenate(out_orient_fine, axis=0).reshape([H, W, 3, -1]) * 255).clip(0, 255)\n \n normal_img = None\n if out_normal_fine:\n normal_img = np.concatenate(out_normal_fine, axis=0)\n rot = np.linalg.inv(self.dataset.pose_all[idx, :3, :3].detach().cpu().numpy())\n normal_img = (np.matmul(rot[None, :, :], normal_img[:, :, None])\n .reshape([H, W, 3, -1]) * 128 + 128).clip(0, 255)\n normal_hair_img = None\n if out_normal_hair_fine:\n normal_hair_img = np.concatenate(out_normal_hair_fine, axis=0)\n rot = np.linalg.inv(self.dataset.pose_all[idx, :3, :3].detach().cpu().numpy())\n normal_hair_img = (np.matmul(rot[None, :, :], normal_hair_img[:, :, None])\n .reshape([H, W, 3, -1]) * 128 + 128).clip(0, 255)\n \n os.makedirs(os.path.join(self.base_exp_dir, 'renders_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'normals'), exist_ok=True)\n\n\n if self.orient_weight: \n os.makedirs(os.path.join(self.base_exp_dir, 'orients_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'orients_masked_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'normals_hair'), exist_ok=True)\n\n for i in range(img_fine.shape[-1]):\n if out_rgb_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'renders_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([img_fine[..., i],\n self.dataset.image_at(idx, resolution_level=resolution_level)]))\n if self.orient_weight: \n if out_orient_fine:\n confs = self.dataset.orient_confs_at(idx, resolution_level=resolution_level)\n orients_gt = self.dataset.orient_at(idx, resolution_level=resolution_level)\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'orients_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([orient_fine[..., i], orients_gt]))\n\n # Masked orients\n orient_fine[..., i] = (orient_fine[..., i] * confs).round().astype('uint8')\n orients_gt = (orients_gt * confs).round().astype('uint8')\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'orients_masked_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([orient_fine[..., i], orients_gt]))\n if out_normal_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'normals',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n normal_img[..., i])\n\n if out_normal_hair_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'normals_hair',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n normal_hair_img[..., i])", "probing input": " def validate_image(self, idx=-1, resolution_level=-1):\n if idx < 0:\n idx = np.random.randint(self.dataset.n_images)\n print('Validate: iter: {}, camera: {}'.format(self.iter_step, idx))\n\n if resolution_level < 0:\n resolution_level = self.val_render_resolution_level \n pixels, radii, orient_angle, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(idx, resolution_level=resolution_level)\n # print('before cam model', cam_intr_0.shape, cam_pose_0.shape)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(torch.tensor([idx]), cam_intr_0, cam_pose_0)\n cam_intr_ = cam_intr_[0]\n cam_pose_ = cam_pose_[0]\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def validate_image(self, idx=-1, resolution_level=-1):\n if idx < 0:\n idx = np.random.randint(self.dataset.n_images)\n print('Validate: iter: {}, camera: {}'.format(self.iter_step, idx))\n\n if resolution_level < 0:\n resolution_level = self.val_render_resolution_level \n pixels, radii, orient_angle, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(idx, resolution_level=resolution_level)\n # print('before cam model', cam_intr_0.shape, cam_pose_0.shape)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(torch.tensor([idx]), cam_intr_0, cam_pose_0)\n cam_intr_ = cam_intr_[0]\n cam_pose_ = cam_pose_[0]\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.", "reference": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_d = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def validate_image(self, idx=-1, resolution_level=-1):\n if idx < 0:\n idx = np.random.randint(self.dataset.n_images)\n print('Validate: iter: {}, camera: {}'.format(self.iter_step, idx))\n\n if resolution_level < 0:\n resolution_level = self.val_render_resolution_level \n pixels, radii, orient_angle, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(idx, resolution_level=resolution_level)\n # print('before cam model', cam_intr_0.shape, cam_pose_0.shape)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(torch.tensor([idx]), cam_intr_0, cam_pose_0)\n cam_intr_ = cam_intr_[0]\n cam_pose_ = cam_pose_[0]\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n cam_intr = cam_intr_.detach()\n cam_extr = torch.linalg.inv(cam_pose_.detach())\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_d = torch.matmul(cam_pose_[None, None, :3, :3], rays_d[:, :, :, None]).squeeze() # W, H, 3\n rays_o = cam_pose_[None, None, :3, 3].expand(rays_d.shape) # W, H, 3\n\n H, W, _ = rays_o.shape\n\n rays_o = rays_o.transpose(0, 1).reshape(-1, 3).split(self.batch_size)\n rays_d = rays_d.transpose(0, 1).reshape(-1, 3).split(self.batch_size)\n \n radii = radii.reshape(-1, 1).split(self.batch_size)\n orient_angle = orient_angle.reshape(-1, 3).split(self.batch_size)\n\n out_rgb_fine = []\n out_orient_fine = []\n out_normal_fine = []\n out_normal_hair_fine = []\n \n for rays_o_batch, rays_d_batch, radii_batch, orient_angle_batch in zip(rays_o, rays_d, radii, orient_angle):\n near, far = self.dataset.near_far_from_sphere(rays_o_batch, rays_d_batch)\n background_rgb = torch.ones([1, 3]) if self.use_white_bkgd else None\n\n render_out = self.renderer.render(rays_o_batch,\n rays_d_batch,\n radii_batch,\n near,\n far,\n cos_anneal_ratio=self.get_cos_anneal_ratio(),\n background_rgb=background_rgb)\n\n color_fine = render_out['color_fine'].detach().cpu().numpy()\n\n\n def feasible(key): return (key in render_out) and (render_out[key] is not None)\n\n if feasible('color_fine'):\n out_rgb_fine.append(color_fine)\n\n if self.orient_weight:\n if feasible('sampled_orient_fine'):\n # Project orientations into camera\n orient_angle_fine = project_orient_to_camera(orient_3d=render_out['sampled_orient_fine'], org_3d=render_out['pts_fine'], cam_intr=cam_intr, cam_extr=cam_extr)\n \n orient_cos_fine = orient_angle_fine.cos()\n orient_fine_cam = torch.cat(\n [\n orient_cos_fine * (orient_cos_fine >= 0),\n orient_angle_fine.sin(),\n orient_cos_fine.abs() * (orient_cos_fine < 0)\n ],\n dim=1\n )\n out_orient_fine.append(orient_fine_cam.cpu().numpy()) \n \n if feasible('gradients_head') and feasible('weights'):\n n_samples = self.renderer.n_samples + self.renderer.n_importance\n normals = render_out['gradients_head'] * render_out['weights'][:, :n_samples, None]\n if feasible('inside_sphere'):\n normals = normals * render_out['inside_sphere'][..., None]\n\n normals = normals.sum(dim=1).detach().cpu().numpy()\n out_normal_fine.append(normals)\n\n if feasible('gradients_hair') and feasible('weights'):\n n_samples = self.renderer.n_samples + self.renderer.n_importance\n normals_hair = render_out['gradients_hair'] * render_out['weights'][:, :n_samples, None]\n if feasible('inside_sphere'):\n normals_hair = normals_hair * render_out['inside_sphere'][..., None]\n\n normals_hair = normals_hair.sum(dim=1).detach().cpu().numpy()\n out_normal_hair_fine.append(normals_hair) \n \n del render_out\n\n img_fine = None\n orient_fine = None\n \n if out_rgb_fine:\n img_fine = (np.concatenate(out_rgb_fine, axis=0).reshape([H, W, 3, -1]) * 255).clip(0, 255)\n if self.orient_weight: \n if out_orient_fine:\n orient_fine = (np.concatenate(out_orient_fine, axis=0).reshape([H, W, 3, -1]) * 255).clip(0, 255)\n \n normal_img = None\n if out_normal_fine:\n normal_img = np.concatenate(out_normal_fine, axis=0)\n rot = np.linalg.inv(self.dataset.pose_all[idx, :3, :3].detach().cpu().numpy())\n normal_img = (np.matmul(rot[None, :, :], normal_img[:, :, None])\n .reshape([H, W, 3, -1]) * 128 + 128).clip(0, 255)\n normal_hair_img = None\n if out_normal_hair_fine:\n normal_hair_img = np.concatenate(out_normal_hair_fine, axis=0)\n rot = np.linalg.inv(self.dataset.pose_all[idx, :3, :3].detach().cpu().numpy())\n normal_hair_img = (np.matmul(rot[None, :, :], normal_hair_img[:, :, None])\n .reshape([H, W, 3, -1]) * 128 + 128).clip(0, 255)\n \n os.makedirs(os.path.join(self.base_exp_dir, 'renders_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'normals'), exist_ok=True)\n\n\n if self.orient_weight: \n os.makedirs(os.path.join(self.base_exp_dir, 'orients_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'orients_masked_fine'), exist_ok=True)\n os.makedirs(os.path.join(self.base_exp_dir, 'normals_hair'), exist_ok=True)\n\n for i in range(img_fine.shape[-1]):\n if out_rgb_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'renders_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([img_fine[..., i],\n self.dataset.image_at(idx, resolution_level=resolution_level)]))\n if self.orient_weight: \n if out_orient_fine:\n confs = self.dataset.orient_confs_at(idx, resolution_level=resolution_level)\n orients_gt = self.dataset.orient_at(idx, resolution_level=resolution_level)\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'orients_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([orient_fine[..., i], orients_gt]))\n\n # Masked orients\n orient_fine[..., i] = (orient_fine[..., i] * confs).round().astype('uint8')\n orients_gt = (orients_gt * confs).round().astype('uint8')\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'orients_masked_fine',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n np.concatenate([orient_fine[..., i], orients_gt]))\n if out_normal_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'normals',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n normal_img[..., i])\n\n if out_normal_hair_fine:\n cv.imwrite(os.path.join(self.base_exp_dir,\n 'normals_hair',\n '{:0>8d}_{}_{}.png'.format(self.iter_step, i, idx)),\n normal_hair_img[..., i])" }, { "id": 7395, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def render_img(self, img_idx, resolution):\n pixels, radii, _, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(img_idx, resolution_level=resolution)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(img_idx, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_d = torch.matmul(cam_pose_[None, None, :3, :3], rays_d[:, :, :, None]).squeeze() # W, H, 3\n rays_o = cam_pose_[None, None, :3, 3].expand(rays_d.shape) # W, H, 3\n \n H, W, _ = rays_o.shape\n rays_o = rays_o.transpose(0, 1).reshape(-1, 3).split(800)\n rays_d = rays_d.transpose(0, 1).reshape(-1, 3).split(800)\n\n radii = radii.reshape(-1, 1).split(800)\n\n out_rgb_fine = []\n for rays_o_batch, rays_d_batch, radii_batch in tqdm(zip(rays_o, rays_d, radii)):\n near, far = self.dataset.near_far_from_sphere(rays_o_batch, rays_d_batch)\n background_rgb = torch.ones([1, 3]) if self.use_white_bkgd else None\n\n render_out = self.renderer.render(rays_o_batch,\n rays_d_batch,\n radii_batch,\n near,\n far,\n cos_anneal_ratio=self.get_cos_anneal_ratio(),\n background_rgb=background_rgb, perturb_overwrite=0)\n\n out_rgb_fine.append(render_out['color_fine'].detach().cpu().numpy())\n\n del render_out\n\n img_fine = (np.concatenate(out_rgb_fine, axis=0).reshape([H, W, 3]) * 256).clip(0, 255).astype(np.uint8)\n img_dir = os.path.join(self.base_exp_dir, 'render')\n os.makedirs(img_dir, exist_ok=True)\n cv.imwrite(os.path.join(img_dir, f'{self.iter_step}_{img_idx}.png'), img_fine)", "probing input": " def render_img(self, img_idx, resolution):\n pixels, radii, _, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(img_idx, resolution_level=resolution)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(img_idx, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def render_img(self, img_idx, resolution):\n pixels, radii, _, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(img_idx, resolution_level=resolution)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(img_idx, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.", "reference": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_d=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_d = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def render_img(self, img_idx, resolution):\n pixels, radii, _, cam_intr_0, cam_pose_0 = self.dataset.gen_rays_at(img_idx, resolution_level=resolution)\n if self.camera_model is not None:\n cam_intr_, cam_pose_ = self.camera_model(img_idx, cam_intr_0, cam_pose_0)\n else:\n cam_intr_ = cam_intr_0\n cam_pose_ = cam_pose_0\n\n p = torch.matmul(torch.linalg.inv(cam_intr_)[None, None, :3, :3], pixels[:, :, :, None]).squeeze() # W, H, 3\n rays_d = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_d = torch.matmul(cam_pose_[None, None, :3, :3], rays_d[:, :, :, None]).squeeze() # W, H, 3\n rays_o = cam_pose_[None, None, :3, 3].expand(rays_d.shape) # W, H, 3\n \n H, W, _ = rays_o.shape\n rays_o = rays_o.transpose(0, 1).reshape(-1, 3).split(800)\n rays_d = rays_d.transpose(0, 1).reshape(-1, 3).split(800)\n\n radii = radii.reshape(-1, 1).split(800)\n\n out_rgb_fine = []\n for rays_o_batch, rays_d_batch, radii_batch in tqdm(zip(rays_o, rays_d, radii)):\n near, far = self.dataset.near_far_from_sphere(rays_o_batch, rays_d_batch)\n background_rgb = torch.ones([1, 3]) if self.use_white_bkgd else None\n\n render_out = self.renderer.render(rays_o_batch,\n rays_d_batch,\n radii_batch,\n near,\n far,\n cos_anneal_ratio=self.get_cos_anneal_ratio(),\n background_rgb=background_rgb, perturb_overwrite=0)\n\n out_rgb_fine.append(render_out['color_fine'].detach().cpu().numpy())\n\n del render_out\n\n img_fine = (np.concatenate(out_rgb_fine, axis=0).reshape([H, W, 3]) * 256).clip(0, 255).astype(np.uint8)\n img_dir = os.path.join(self.base_exp_dir, 'render')\n os.makedirs(img_dir, exist_ok=True)\n cv.imwrite(os.path.join(img_dir, f'{self.iter_step}_{img_idx}.png'), img_fine)" }, { "id": 7398, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def add_edge_features(self) -> List[dgl.DGLGraph]:\n \"\"\"\n Add relative displacement and displacement norm as edge features for each graph\n in the list of graphs. The calculations are done using the 'pos' attribute in the\n node data of each graph. The resulting edge features are stored in the 'x' attribute\n in the edge data of each graph.\n\n This method will modify the list of graphs in-place.\n\n Returns\n -------\n List[dgl.DGLGraph]\n The list of graphs with updated edge features.\n \"\"\"\n if not hasattr(self, \"graphs\") or not self.graphs:\n raise ValueError(\"The list 'graphs' is empty.\")\n\n for graph in self.graphs:\n pos = graph.ndata.get(\"pos\")\n if pos is None:\n raise ValueError(\n \"'pos' does not exist in the node data of one or more graphs.\"\n )\n\n row, col = graph.edges()\n row = row.long()\n col = col.long()\n\n disp = pos[row] - pos[col]\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n graph.edata[\"x\"] = torch.cat((disp, disp_norm), dim=-1)\n\n return self.graphs", "probing input": " def add_edge_features(self) -> List[dgl.DGLGraph]:\n \"\"\"\n Add relative displacement and displacement norm as edge features for each graph\n in the list of graphs. The calculations are done using the 'pos' attribute in the\n node data of each graph. The resulting edge features are stored in the 'x' attribute\n in the edge data of each graph.\n\n This method will modify the list of graphs in-place.\n\n Returns\n -------\n List[dgl.DGLGraph]\n The list of graphs with updated edge features.\n \"\"\"\n if not hasattr(self, \"graphs\") or not self.graphs:\n raise ValueError(\"The list 'graphs' is empty.\")\n\n for graph in self.graphs:\n pos = graph.ndata.get(\"pos\")\n if pos is None:\n raise ValueError(\n \"'pos' does not exist in the node data of one or more graphs.\"\n )\n\n row, col = graph.edges()\n row = row.long()\n col = col.long()\n\n disp = pos[row] - pos[col]\n", "probing input new": " def add_edge_features(self) -> List[dgl.DGLGraph]:\n \"\"\"\n Add relative displacement and displacement norm as edge features for each graph\n in the list of graphs. The calculations are done using the 'pos' attribute in the\n node data of each graph. The resulting edge features are stored in the 'x' attribute\n in the edge data of each graph.\n\n This method will modify the list of graphs in-place.\n\n Returns\n -------\n List[dgl.DGLGraph]\n The list of graphs with updated edge features.\n \"\"\"\n if not hasattr(self, \"graphs\") or not self.graphs:\n raise ValueError(\"The list 'graphs' is empty.\")\n\n for graph in self.graphs:\n pos = graph.ndata.get(\"pos\")\n if pos is None:\n raise ValueError(\n \"'pos' does not exist in the node data of one or more graphs.\"\n )\n\n row, col = graph.edges()\n row = row.long()\n col = col.long()\n\n disp = pos[row] - pos[col]\n disp_", "reference": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "y_neg": " disp_norm = torch.norm(disp, p=2, dim=1)", "retain": " def add_edge_features(self) -> List[dgl.DGLGraph]:\n \"\"\"\n Add relative displacement and displacement norm as edge features for each graph\n in the list of graphs. The calculations are done using the 'pos' attribute in the\n node data of each graph. The resulting edge features are stored in the 'x' attribute\n in the edge data of each graph.\n\n This method will modify the list of graphs in-place.\n\n Returns\n -------\n List[dgl.DGLGraph]\n The list of graphs with updated edge features.\n \"\"\"\n if not hasattr(self, \"graphs\") or not self.graphs:\n raise ValueError(\"The list 'graphs' is empty.\")\n\n for graph in self.graphs:\n pos = graph.ndata.get(\"pos\")\n if pos is None:\n raise ValueError(\n \"'pos' does not exist in the node data of one or more graphs.\"\n )\n\n row, col = graph.edges()\n row = row.long()\n col = col.long()\n\n disp = pos[row] - pos[col]\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n graph.edata[\"x\"] = torch.cat((disp, disp_norm), dim=-1)\n\n return self.graphs" }, { "id": 7399, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_relearn_structure(self, wordvec_pretrain_file):\n \"\"\"\n Test that starting a trainer with --relearn_structure copies the old model\n \"\"\"\n\n with tempfile.TemporaryDirectory(dir=TEST_WORKING_DIR) as tmpdirname:\n set_random_seed(1000)\n args = ['--pattn_num_layers', '0', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10']\n tr = build_trainer(wordvec_pretrain_file, *args)\n\n # attempt saving\n filename = os.path.join(tmpdirname, \"parser.pt\")\n tr.save(filename)\n\n set_random_seed(1001)\n args = ['--pattn_num_layers', '1', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10', '--relearn_structure', '--load_name', filename]\n tr2 = build_trainer(wordvec_pretrain_file, *args)\n\n assert torch.allclose(tr.model.delta_embedding.weight, tr2.model.delta_embedding.weight)\n assert torch.allclose(tr.model.output_layers[0].weight, tr2.model.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.linalg.norm(tr.model.word_lstm.weight_ih_l0), torch.linalg.norm(tr2.model.word_lstm.weight_ih_l0))", "probing input": " def test_relearn_structure(self, wordvec_pretrain_file):\n \"\"\"\n Test that starting a trainer with --relearn_structure copies the old model\n \"\"\"\n\n with tempfile.TemporaryDirectory(dir=TEST_WORKING_DIR) as tmpdirname:\n set_random_seed(1000)\n args = ['--pattn_num_layers', '0', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10']\n tr = build_trainer(wordvec_pretrain_file, *args)\n\n # attempt saving\n filename = os.path.join(tmpdirname, \"parser.pt\")\n tr.save(filename)\n\n set_random_seed(1001)\n args = ['--pattn_num_layers', '1', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10', '--relearn_structure', '--load_name', filename]\n tr2 = build_trainer(wordvec_pretrain_file, *args)\n\n assert torch.allclose(tr.model.delta_embedding.weight, tr2.model.delta_embedding.weight)\n assert torch.allclose(tr.model.output_layers[0].weight, tr2.model.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n", "probing input new": " def test_relearn_structure(self, wordvec_pretrain_file):\n \"\"\"\n Test that starting a trainer with --relearn_structure copies the old model\n \"\"\"\n\n with tempfile.TemporaryDirectory(dir=TEST_WORKING_DIR) as tmpdirname:\n set_random_seed(1000)\n args = ['--pattn_num_layers', '0', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10']\n tr = build_trainer(wordvec_pretrain_file, *args)\n\n # attempt saving\n filename = os.path.join(tmpdirname, \"parser.pt\")\n tr.save(filename)\n\n set_random_seed(1001)\n args = ['--pattn_num_layers', '1', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10', '--relearn_structure', '--load_name', filename]\n tr2 = build_trainer(wordvec_pretrain_file, *args)\n\n assert torch.allclose(tr.model.delta_embedding.weight, tr2.model.delta_embedding.weight)\n assert torch.allclose(tr.model.output_layers[0].weight, tr2.model.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.", "reference": "asserttorch.allclose(torch.linalg.norm(tr.model.word_lstm.weight_ih_l0),torch.linalg.norm(tr2.model.word_lstm.weight_ih_l0))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "asserttorch.allclose(torch.linalg.norm(tr.model.word_lstm.weight_ih_l0),torch.linalg.norm(tr2.model.word_lstm.weight_ih_l0))", "y_neg": " assert torch.allclose(torch.norm(tr.model.delta_embedding.weight, p='frobenius'), torch.norm(tr2.model.delta_embedding.weight, p='frobenius'))", "retain": " def test_relearn_structure(self, wordvec_pretrain_file):\n \"\"\"\n Test that starting a trainer with --relearn_structure copies the old model\n \"\"\"\n\n with tempfile.TemporaryDirectory(dir=TEST_WORKING_DIR) as tmpdirname:\n set_random_seed(1000)\n args = ['--pattn_num_layers', '0', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10']\n tr = build_trainer(wordvec_pretrain_file, *args)\n\n # attempt saving\n filename = os.path.join(tmpdirname, \"parser.pt\")\n tr.save(filename)\n\n set_random_seed(1001)\n args = ['--pattn_num_layers', '1', '--lattn_d_proj', '0', '--hidden_size', '20', '--delta_embedding_dim', '10', '--relearn_structure', '--load_name', filename]\n tr2 = build_trainer(wordvec_pretrain_file, *args)\n\n assert torch.allclose(tr.model.delta_embedding.weight, tr2.model.delta_embedding.weight)\n assert torch.allclose(tr.model.output_layers[0].weight, tr2.model.output_layers[0].weight)\n # the norms will be the same, as the non-zero values are all the same\n assert torch.allclose(torch.linalg.norm(tr.model.word_lstm.weight_ih_l0), torch.linalg.norm(tr2.model.word_lstm.weight_ih_l0))" }, { "id": 7403, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _get_random_rays(num_rays, max_box, aabb, device):\n \"\"\"\n generate random rays that distribute in the general direction of the box.\n The implementation is naive for now.\n :param num_rays:\n :param max_box:\n :param aabb:\n :param device:\n :return:\n \"\"\"\n origins = []\n directions = []\n aabb_center = torch.tensor(\n [0.5 * (aabb[0] + aabb[3]), 0.5 * (aabb[1] + aabb[4]), 0.5 * (aabb[2] + aabb[5])],\n dtype=torch.float32,\n device=device,\n )\n\n for _ in range(num_rays):\n x = random.uniform(-max_box, max_box)\n y = random.uniform(-max_box, max_box)\n z = random.uniform(-max_box, max_box)\n\n origin = torch.tensor([x, y, z], dtype=torch.float32, device=device)\n dirs_to_cent = aabb_center - origin\n dirs_to_cent = dirs_to_cent / torch.linalg.norm(dirs_to_cent)\n phi = math.asin(dirs_to_cent[2])\n theta = torch.atan2(dirs_to_cent[1], dirs_to_cent[0])\n\n error_ang_phi = random.gauss(0, 0.05)\n error_ang_theta = random.gauss(0, 0.1)\n\n phi = phi + error_ang_phi\n theta = theta + error_ang_theta\n\n x_dir = math.cos(phi) * math.cos(theta)\n y_dir = math.cos(phi) * math.sin(theta)\n z_dir = math.sin(phi)\n\n origins.append([x, y, z])\n directions.append([x_dir, y_dir, z_dir])\n\n origins = torch.tensor(origins, dtype=torch.float32, device=device)\n directions = torch.tensor(directions, dtype=torch.float32, device=device)\n\n return origins, directions", "probing input": "def _get_random_rays(num_rays, max_box, aabb, device):\n \"\"\"\n generate random rays that distribute in the general direction of the box.\n The implementation is naive for now.\n :param num_rays:\n :param max_box:\n :param aabb:\n :param device:\n :return:\n \"\"\"\n origins = []\n directions = []\n aabb_center = torch.tensor(\n [0.5 * (aabb[0] + aabb[3]), 0.5 * (aabb[1] + aabb[4]), 0.5 * (aabb[2] + aabb[5])],\n dtype=torch.float32,\n device=device,\n )\n\n for _ in range(num_rays):\n x = random.uniform(-max_box, max_box)\n y = random.uniform(-max_box, max_box)\n z = random.uniform(-max_box, max_box)\n\n origin = torch.tensor([x, y, z], dtype=torch.float32, device=device)\n dirs_to_cent = aabb_center - origin\n", "probing input new": "def _get_random_rays(num_rays, max_box, aabb, device):\n \"\"\"\n generate random rays that distribute in the general direction of the box.\n The implementation is naive for now.\n :param num_rays:\n :param max_box:\n :param aabb:\n :param device:\n :return:\n \"\"\"\n origins = []\n directions = []\n aabb_center = torch.tensor(\n [0.5 * (aabb[0] + aabb[3]), 0.5 * (aabb[1] + aabb[4]), 0.5 * (aabb[2] + aabb[5])],\n dtype=torch.float32,\n device=device,\n )\n\n for _ in range(num_rays):\n x = random.uniform(-max_box, max_box)\n y = random.uniform(-max_box, max_box)\n z = random.uniform(-max_box, max_box)\n\n origin = torch.tensor([x, y, z], dtype=torch.float32, device=device)\n dirs_to_cent = aabb_center - origin\n dirs_to_cent = dirs_to_cent / torch.", "reference": "dirs_to_cent=dirs_to_cent/torch.linalg.norm(dirs_to_cent)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dirs_to_cent=dirs_to_cent/torch.linalg.norm(dirs_to_cent)", "y_neg": " dirs_to_cent = dirs_to_cent / torch.norm(dirs_to_cent, dim=-1, keepdim=True)", "retain": "def _get_random_rays(num_rays, max_box, aabb, device):\n \"\"\"\n generate random rays that distribute in the general direction of the box.\n The implementation is naive for now.\n :param num_rays:\n :param max_box:\n :param aabb:\n :param device:\n :return:\n \"\"\"\n origins = []\n directions = []\n aabb_center = torch.tensor(\n [0.5 * (aabb[0] + aabb[3]), 0.5 * (aabb[1] + aabb[4]), 0.5 * (aabb[2] + aabb[5])],\n dtype=torch.float32,\n device=device,\n )\n\n for _ in range(num_rays):\n x = random.uniform(-max_box, max_box)\n y = random.uniform(-max_box, max_box)\n z = random.uniform(-max_box, max_box)\n\n origin = torch.tensor([x, y, z], dtype=torch.float32, device=device)\n dirs_to_cent = aabb_center - origin\n dirs_to_cent = dirs_to_cent / torch.linalg.norm(dirs_to_cent)\n phi = math.asin(dirs_to_cent[2])\n theta = torch.atan2(dirs_to_cent[1], dirs_to_cent[0])\n\n error_ang_phi = random.gauss(0, 0.05)\n error_ang_theta = random.gauss(0, 0.1)\n\n phi = phi + error_ang_phi\n theta = theta + error_ang_theta\n\n x_dir = math.cos(phi) * math.cos(theta)\n y_dir = math.cos(phi) * math.sin(theta)\n z_dir = math.sin(phi)\n\n origins.append([x, y, z])\n directions.append([x_dir, y_dir, z_dir])\n\n origins = torch.tensor(origins, dtype=torch.float32, device=device)\n directions = torch.tensor(directions, dtype=torch.float32, device=device)\n\n return origins, directions" }, { "id": 7406, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_silhouettes(self, pose, max_ray_num, mask):\n if mask.sum() == 0:\n return self.gen_rays_pose(pose, resolution_level=4)\n struct = ndimage.generate_binary_structure(2, 2)\n dilated_mask = ndimage.binary_dilation(mask, structure=struct, iterations=10).astype(np.int32)\n current_ratio = dilated_mask.sum() / float(mask.shape[0] * mask.shape[1])\n W = H = min(self.H, int(np.sqrt(max_ray_num / current_ratio)))\n tx = torch.linspace(0, self.W - 1, W)\n ty = torch.linspace(0, self.H - 1, H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * pose[:3, :3], -1)\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n resized_dilated_mask = torch.nn.functional.interpolate(\n torch.from_numpy(dilated_mask).reshape(256, 256, 1).permute(2, 0, 1).unsqueeze(0).float(), size=(H, W)).squeeze()\n masked_rays_v = rays_v[resized_dilated_mask > 0]\n masked_rays_o = rays_o[resized_dilated_mask > 0]\n\n return masked_rays_o, masked_rays_v, W, resized_dilated_mask > 0", "probing input": " def gen_rays_silhouettes(self, pose, max_ray_num, mask):\n if mask.sum() == 0:\n return self.gen_rays_pose(pose, resolution_level=4)\n struct = ndimage.generate_binary_structure(2, 2)\n dilated_mask = ndimage.binary_dilation(mask, structure=struct, iterations=10).astype(np.int32)\n current_ratio = dilated_mask.sum() / float(mask.shape[0] * mask.shape[1])\n W = H = min(self.H, int(np.sqrt(max_ray_num / current_ratio)))\n tx = torch.linspace(0, self.W - 1, W)\n ty = torch.linspace(0, self.H - 1, H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n", "probing input new": " def gen_rays_silhouettes(self, pose, max_ray_num, mask):\n if mask.sum() == 0:\n return self.gen_rays_pose(pose, resolution_level=4)\n struct = ndimage.generate_binary_structure(2, 2)\n dilated_mask = ndimage.binary_dilation(mask, structure=struct, iterations=10).astype(np.int32)\n current_ratio = dilated_mask.sum() / float(mask.shape[0] * mask.shape[1])\n W = H = min(self.H, int(np.sqrt(max_ray_num / current_ratio)))\n tx = torch.linspace(0, self.W - 1, W)\n ty = torch.linspace(0, self.H - 1, H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True)", "retain": " def gen_rays_silhouettes(self, pose, max_ray_num, mask):\n if mask.sum() == 0:\n return self.gen_rays_pose(pose, resolution_level=4)\n struct = ndimage.generate_binary_structure(2, 2)\n dilated_mask = ndimage.binary_dilation(mask, structure=struct, iterations=10).astype(np.int32)\n current_ratio = dilated_mask.sum() / float(mask.shape[0] * mask.shape[1])\n W = H = min(self.H, int(np.sqrt(max_ray_num / current_ratio)))\n tx = torch.linspace(0, self.W - 1, W)\n ty = torch.linspace(0, self.H - 1, H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * pose[:3, :3], -1)\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n resized_dilated_mask = torch.nn.functional.interpolate(\n torch.from_numpy(dilated_mask).reshape(256, 256, 1).permute(2, 0, 1).unsqueeze(0).float(), size=(H, W)).squeeze()\n masked_rays_v = rays_v[resized_dilated_mask > 0]\n masked_rays_o = rays_o[resized_dilated_mask > 0]\n\n return masked_rays_o, masked_rays_v, W, resized_dilated_mask > 0" }, { "id": 7407, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_pose(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space given pose.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * pose[:3, :3], -1)\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o, rays_v", "probing input": " def gen_rays_pose(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space given pose.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n", "probing input new": " def gen_rays_pose(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space given pose.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True)", "retain": " def gen_rays_pose(self, pose, resolution_level=1):\n \"\"\"\n Generate rays at world space given pose.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * pose[:3, :3], -1)\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o, rays_v" }, { "id": 7408, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n # rays_v = torch.matmul(self.poses[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * self.poses[img_idx, :3, :3], -1)\n rays_o = self.poses[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o, rays_v", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True)", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, int(self.W // l))\n ty = torch.linspace(0, self.H - 1, int(self.H // l))\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n pixels_x = pixels_x.t()\n pixels_y = pixels_y.t()\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n # rays_v = torch.matmul(self.poses[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_v = torch.sum(rays_v[..., None, :] * self.poses[img_idx, :3, :3], -1)\n rays_o = self.poses[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o, rays_v" }, { "id": 7409, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n # rays_v = torch.matmul(self.poses[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_v = torch.sum(rays_v[..., None, :] * self.poses[img_idx, :3, :3], -1)\n rays_o = self.poses[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True)", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([(pixels_x - self.K[0][2]) / self.K[0][0],\n -(pixels_y - self.K[1][2]) / self.K[1][1],\n -torch.ones_like(pixels_x)], -1).float()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n # rays_v = torch.matmul(self.poses[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_v = torch.sum(rays_v[..., None, :] * self.poses[img_idx, :3, :3], -1)\n rays_o = self.poses[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()" }, { "id": 7410, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n\n ###\n ### Code below is borrowed from https://github.com/hjxwhy/mipnerf_pl/blob/master/datasets/datasets.py\n ###\n v = p\n # Distance from each unit-norm direction vector to its x-axis neighbor.\n dx = torch.sqrt(torch.sum((v[:-1, :, :] - v[1:, :, :]) ** 2, -1))\n dx = torch.cat([dx, dx[-2:-1, :]], 0)\n # Cut the distance in half, and then round it out so that it's\n # halfway between inscribed by / circumscribed about the pixel.\n radii = dx[..., None] * 2 / math.sqrt(12) # W, H, 1\n\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose_inv = np.linalg.inv(pose)\n rot = torch.from_numpy(pose_inv[:3, :3]).cuda()\n trans = torch.from_numpy(pose_inv[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n\n # TODO: return intrinsics and pose\n\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), radii.transpose(0, 1)", "probing input": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n\n ###\n ### Code below is borrowed from https://github.com/hjxwhy/mipnerf_pl/blob/master/datasets/datasets.py\n ###\n v = p\n # Distance from each unit-norm direction vector to its x-axis neighbor.\n dx = torch.sqrt(torch.sum((v[:-1, :, :] - v[1:, :, :]) ** 2, -1))\n dx = torch.cat([dx, dx[-2:-1, :]], 0)\n # Cut the distance in half, and then round it out so that it's\n # halfway between inscribed by / circumscribed about the pixel.\n radii = dx[..., None] * 2 / math.sqrt(12) # W, H, 1\n\n", "probing input new": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n\n ###\n ### Code below is borrowed from https://github.com/hjxwhy/mipnerf_pl/blob/master/datasets/datasets.py\n ###\n v = p\n # Distance from each unit-norm direction vector to its x-axis neighbor.\n dx = torch.sqrt(torch.sum((v[:-1, :, :] - v[1:, :, :]) ** 2, -1))\n dx = torch.cat([dx, dx[-2:-1, :]], 0)\n # Cut the distance in half, and then round it out so that it's\n # halfway between inscribed by / circumscribed about the pixel.\n radii = dx[..., None] * 2 / math.sqrt(12) # W, H, 1\n\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n\n ###\n ### Code below is borrowed from https://github.com/hjxwhy/mipnerf_pl/blob/master/datasets/datasets.py\n ###\n v = p\n # Distance from each unit-norm direction vector to its x-axis neighbor.\n dx = torch.sqrt(torch.sum((v[:-1, :, :] - v[1:, :, :]) ** 2, -1))\n dx = torch.cat([dx, dx[-2:-1, :]], 0)\n # Cut the distance in half, and then round it out so that it's\n # halfway between inscribed by / circumscribed about the pixel.\n radii = dx[..., None] * 2 / math.sqrt(12) # W, H, 1\n\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose_inv = np.linalg.inv(pose)\n rot = torch.from_numpy(pose_inv[:3, :3]).cuda()\n trans = torch.from_numpy(pose_inv[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n\n # TODO: return intrinsics and pose\n\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), radii.transpose(0, 1)" }, { "id": 7411, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_ray_directions(W: int, H: int, fx: float, fy: float, cx: float, cy: float, center_pixels: bool,\n device: torch.device) -> torch.Tensor:\n i, j = torch.meshgrid(torch.arange(W, dtype=torch.float32, device=device),\n torch.arange(H, dtype=torch.float32, device=device), indexing='xy')\n if center_pixels:\n i = i.clone() + 0.5\n j = j.clone() + 0.5\n\n directions = \\\n torch.stack([(i - cx) / fx, -(j - cy) / fy, -torch.ones_like(i)], -1) # (H, W, 3)\n directions /= torch.linalg.norm(directions, dim=-1, keepdim=True)\n\n return directions", "probing input": "def get_ray_directions(W: int, H: int, fx: float, fy: float, cx: float, cy: float, center_pixels: bool,\n device: torch.device) -> torch.Tensor:\n i, j = torch.meshgrid(torch.arange(W, dtype=torch.float32, device=device),\n torch.arange(H, dtype=torch.float32, device=device), indexing='xy')\n if center_pixels:\n i = i.clone() + 0.5\n j = j.clone() + 0.5\n\n directions = \\\n torch.stack([(i - cx) / fx, -(j - cy) / fy, -torch.ones_like(i)], -1) # (H, W, 3)\n", "probing input new": "def get_ray_directions(W: int, H: int, fx: float, fy: float, cx: float, cy: float, center_pixels: bool,\n device: torch.device) -> torch.Tensor:\n i, j = torch.meshgrid(torch.arange(W, dtype=torch.float32, device=device),\n torch.arange(H, dtype=torch.float32, device=device), indexing='xy')\n if center_pixels:\n i = i.clone() + 0.5\n j = j.clone() + 0.5\n\n directions = \\\n torch.stack([(i - cx) / fx, -(j - cy) / fy, -torch.ones_like(i)], -1) # (H, W, 3)\n directions /= torch.", "reference": "directions/=torch.linalg.norm(directions,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "directions/=torch.linalg.norm(directions,dim=-1,keepdim=True)", "y_neg": " directions /= torch.norm(directions, dim=-1, keepdim=True) # normalize", "retain": "def get_ray_directions(W: int, H: int, fx: float, fy: float, cx: float, cy: float, center_pixels: bool,\n device: torch.device) -> torch.Tensor:\n i, j = torch.meshgrid(torch.arange(W, dtype=torch.float32, device=device),\n torch.arange(H, dtype=torch.float32, device=device), indexing='xy')\n if center_pixels:\n i = i.clone() + 0.5\n j = j.clone() + 0.5\n\n directions = \\\n torch.stack([(i - cx) / fx, -(j - cy) / fy, -torch.ones_like(i)], -1) # (H, W, 3)\n directions /= torch.linalg.norm(directions, dim=-1, keepdim=True)\n\n return directions" }, { "id": 7413, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, quaternion, translation, rotation, normalize:bool=True, unstack_inputs:bool=False):\n if quaternion is not None:\n assert quaternion.shape[-1] == 4\n if unstack_inputs:\n if rotation is not None:\n rotation = torch.stack([torch.moveaxis(x, -1, 0) # Unstack.\n for x in torch.moveaxis(rotation, -2, 0)]) # Unstack.\n translation = torch.moveaxis(translation, -1, 0) # Unstack.\n if normalize and quaternion is not None:\n quaternion = quaternion / torch.linalg.norm(quaternion, dim=-1, keepdim=True)\n if rotation is None:\n rotation = quat_to_rot_pth(quaternion)\n self.quaternion = quaternion\n # self.rotation = [list(row) for row in rotation]\n # self.translation = list(translation)\n self.rotation = rotation\n self.translation = translation\n #assert all(len(row) == 3 for row in self.rotation)\n assert len(self.translation) == 3", "probing input": " def __init__(self, quaternion, translation, rotation, normalize:bool=True, unstack_inputs:bool=False):\n if quaternion is not None:\n assert quaternion.shape[-1] == 4\n if unstack_inputs:\n if rotation is not None:\n rotation = torch.stack([torch.moveaxis(x, -1, 0) # Unstack.\n for x in torch.moveaxis(rotation, -2, 0)]) # Unstack.\n translation = torch.moveaxis(translation, -1, 0) # Unstack.\n if normalize and quaternion is not None:\n", "probing input new": " def __init__(self, quaternion, translation, rotation, normalize:bool=True, unstack_inputs:bool=False):\n if quaternion is not None:\n assert quaternion.shape[-1] == 4\n if unstack_inputs:\n if rotation is not None:\n rotation = torch.stack([torch.moveaxis(x, -1, 0) # Unstack.\n for x in torch.moveaxis(rotation, -2, 0)]) # Unstack.\n translation = torch.moveaxis(translation, -1, 0) # Unstack.\n if normalize and quaternion is not None:\n quaternion = quaternion / torch.", "reference": "quaternion=quaternion/torch.linalg.norm(quaternion,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quaternion=quaternion/torch.linalg.norm(quaternion,dim=-1,keepdim=True)", "y_neg": " quaternion = quaternion / torch.norm(quaternion, dim=-1, keepdim=True)", "retain": " def __init__(self, quaternion, translation, rotation, normalize:bool=True, unstack_inputs:bool=False):\n if quaternion is not None:\n assert quaternion.shape[-1] == 4\n if unstack_inputs:\n if rotation is not None:\n rotation = torch.stack([torch.moveaxis(x, -1, 0) # Unstack.\n for x in torch.moveaxis(rotation, -2, 0)]) # Unstack.\n translation = torch.moveaxis(translation, -1, 0) # Unstack.\n if normalize and quaternion is not None:\n quaternion = quaternion / torch.linalg.norm(quaternion, dim=-1, keepdim=True)\n if rotation is None:\n rotation = quat_to_rot_pth(quaternion)\n self.quaternion = quaternion\n # self.rotation = [list(row) for row in rotation]\n # self.translation = list(translation)\n self.rotation = rotation\n self.translation = translation\n #assert all(len(row) == 3 for row in self.rotation)\n assert len(self.translation) == 3" }, { "id": 7421, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def regularized_min_max_diff(\n output_imgs: Tensor,\n activation_extractor: PytorchActivationExtractor,\n eps: float = 1e-6) -> Tensor:\n \"\"\"\n Calculate the regularized minimum-maximum difference of output images. We want to maximize\n the difference between the minimum and maximum values of the output, but also to regularize\n their values so that they don't exceed the norm of the last layer's input times the norm of\n the last layer's weights.\n\n Args:\n output_imgs (Tensor or List[Tensor]): The output of the model on images.\n activation_extractor (PytorchActivationExtractor): The activation extractor for the model.\n eps (float): Small value for numerical stability.\n\n Returns:\n Tensor: The computed minimum-maximum difference loss.\n \"\"\"\n # get the input to the last linear layers of the model\n output_layers_inputs = activation_extractor.get_output_layer_input_activation()\n\n # get the weights of the last linear layers of the model\n weights_output_layers = activation_extractor.get_last_linear_layers_weights()\n\n if not isinstance(output_imgs, (list, tuple)):\n output_imgs = torch.reshape(output_imgs, [output_imgs.shape[0], output_imgs.shape[1], -1])\n output_imgs = torch.mean(output_imgs, dim=-1)\n output_imgs = [output_imgs]\n output_loss = torch.zeros(1).to(get_working_device())\n\n for output_weight, output, last_layer_input in zip(weights_output_layers, output_imgs, output_layers_inputs):\n weights_norm = torch.linalg.norm(output_weight.squeeze(), dim=1)\n out_max, out_argmax = torch.max(output, dim=1)\n out_min, out_argmin = torch.min(output, dim=1)\n last_layer_avg = torch.reshape(last_layer_input, [last_layer_input.shape[0], last_layer_input.shape[1], -1])\n last_layer_avg = torch.mean(last_layer_avg, dim=-1)\n last_layer_norm = torch.linalg.norm(last_layer_avg, dim=1)\n reg_min = torch.abs(torch.abs(out_min) - 0.5 * last_layer_norm * weights_norm[out_argmin])\n reg_max = torch.abs(torch.abs(out_max) - 0.5 * last_layer_norm * weights_norm[out_argmax])\n dynamic_loss = 1 / (out_max - out_min + eps)\n output_loss += torch.mean(reg_min + reg_max + dynamic_loss)\n return output_loss", "probing input": "def regularized_min_max_diff(\n output_imgs: Tensor,\n activation_extractor: PytorchActivationExtractor,\n eps: float = 1e-6) -> Tensor:\n \"\"\"\n Calculate the regularized minimum-maximum difference of output images. We want to maximize\n the difference between the minimum and maximum values of the output, but also to regularize\n their values so that they don't exceed the norm of the last layer's input times the norm of\n the last layer's weights.\n\n Args:\n output_imgs (Tensor or List[Tensor]): The output of the model on images.\n activation_extractor (PytorchActivationExtractor): The activation extractor for the model.\n eps (float): Small value for numerical stability.\n\n Returns:\n Tensor: The computed minimum-maximum difference loss.\n \"\"\"\n # get the input to the last linear layers of the model\n output_layers_inputs = activation_extractor.get_output_layer_input_activation()\n\n # get the weights of the last linear layers of the model\n weights_output_layers = activation_extractor.get_last_linear_layers_weights()\n\n if not isinstance(output_imgs, (list, tuple)):\n output_imgs = torch.reshape(output_imgs, [output_imgs.shape[0], output_imgs.shape[1], -1])\n output_imgs = torch.mean(output_imgs, dim=-1)\n output_imgs = [output_imgs]\n output_loss = torch.zeros(1).to(get_working_device())\n\n for output_weight, output, last_layer_input in zip(weights_output_layers, output_imgs, output_layers_inputs):\n", "probing input new": "def regularized_min_max_diff(\n output_imgs: Tensor,\n activation_extractor: PytorchActivationExtractor,\n eps: float = 1e-6) -> Tensor:\n \"\"\"\n Calculate the regularized minimum-maximum difference of output images. We want to maximize\n the difference between the minimum and maximum values of the output, but also to regularize\n their values so that they don't exceed the norm of the last layer's input times the norm of\n the last layer's weights.\n\n Args:\n output_imgs (Tensor or List[Tensor]): The output of the model on images.\n activation_extractor (PytorchActivationExtractor): The activation extractor for the model.\n eps (float): Small value for numerical stability.\n\n Returns:\n Tensor: The computed minimum-maximum difference loss.\n \"\"\"\n # get the input to the last linear layers of the model\n output_layers_inputs = activation_extractor.get_output_layer_input_activation()\n\n # get the weights of the last linear layers of the model\n weights_output_layers = activation_extractor.get_last_linear_layers_weights()\n\n if not isinstance(output_imgs, (list, tuple)):\n output_imgs = torch.reshape(output_imgs, [output_imgs.shape[0], output_imgs.shape[1], -1])\n output_imgs = torch.mean(output_imgs, dim=-1)\n output_imgs = [output_imgs]\n output_loss = torch.zeros(1).to(get_working_device())\n\n for output_weight, output, last_layer_input in zip(weights_output_layers, output_imgs, output_layers_inputs):\n weights_", "reference": "weights_norm=torch.linalg.norm(output_weight.squeeze(),dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "weights_norm=torch.linalg.norm(output_weight.squeeze(),dim=1)", "y_neg": " weights_norm = torch.norm(output_weight, p='fro', dim=0, keepdim=True)", "retain": "def regularized_min_max_diff(\n output_imgs: Tensor,\n activation_extractor: PytorchActivationExtractor,\n eps: float = 1e-6) -> Tensor:\n \"\"\"\n Calculate the regularized minimum-maximum difference of output images. We want to maximize\n the difference between the minimum and maximum values of the output, but also to regularize\n their values so that they don't exceed the norm of the last layer's input times the norm of\n the last layer's weights.\n\n Args:\n output_imgs (Tensor or List[Tensor]): The output of the model on images.\n activation_extractor (PytorchActivationExtractor): The activation extractor for the model.\n eps (float): Small value for numerical stability.\n\n Returns:\n Tensor: The computed minimum-maximum difference loss.\n \"\"\"\n # get the input to the last linear layers of the model\n output_layers_inputs = activation_extractor.get_output_layer_input_activation()\n\n # get the weights of the last linear layers of the model\n weights_output_layers = activation_extractor.get_last_linear_layers_weights()\n\n if not isinstance(output_imgs, (list, tuple)):\n output_imgs = torch.reshape(output_imgs, [output_imgs.shape[0], output_imgs.shape[1], -1])\n output_imgs = torch.mean(output_imgs, dim=-1)\n output_imgs = [output_imgs]\n output_loss = torch.zeros(1).to(get_working_device())\n\n for output_weight, output, last_layer_input in zip(weights_output_layers, output_imgs, output_layers_inputs):\n weights_norm = torch.linalg.norm(output_weight.squeeze(), dim=1)\n out_max, out_argmax = torch.max(output, dim=1)\n out_min, out_argmin = torch.min(output, dim=1)\n last_layer_avg = torch.reshape(last_layer_input, [last_layer_input.shape[0], last_layer_input.shape[1], -1])\n last_layer_avg = torch.mean(last_layer_avg, dim=-1)\n last_layer_norm = torch.linalg.norm(last_layer_avg, dim=1)\n reg_min = torch.abs(torch.abs(out_min) - 0.5 * last_layer_norm * weights_norm[out_argmin])\n reg_max = torch.abs(torch.abs(out_max) - 0.5 * last_layer_norm * weights_norm[out_argmax])\n dynamic_loss = 1 / (out_max - out_min + eps)\n output_loss += torch.mean(reg_min + reg_max + dynamic_loss)\n return output_loss" }, { "id": 7422, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def image_reproj_error(imdata, pts3d, img_ids, entrinsics_dict, intrinsics_dict):\n pts3d_array = torch.ones(max(pts3d.keys()) + 1, 4).cuda()\n for pts_id, pts in tqdm(pts3d.items()):\n pts3d_array[pts_id, :3] = torch.from_numpy(pts.xyz).cuda()\n\n img_errors = torch.ones(len(img_ids), 1)\n for id, img_id in tqdm(enumerate(img_ids)):\n img = imdata[img_id]\n entrinsic = torch.from_numpy(entrinsics_dict[img_id]).float().cuda()\n intrinsic = torch.from_numpy(intrinsics_dict[img_id]).float().cuda()\n img_p3d = pts3d_array[img.point3D_ids]\n projected = intrinsic @ entrinsic[:3] @ img_p3d.T\n projected[:2, :] /= projected[2, :].unsqueeze(0)\n img_2d = torch.from_numpy(img.xys)\n img_error = torch.linalg.norm(projected[:2, :].T.cpu() - img_2d, dim=-1)\n img_errors[id] = torch.sum(img_error) / img_error.size()[0]\n # print(f\"img_error: {img_errors[id]}\")\n\n return img_errors", "probing input": "def image_reproj_error(imdata, pts3d, img_ids, entrinsics_dict, intrinsics_dict):\n pts3d_array = torch.ones(max(pts3d.keys()) + 1, 4).cuda()\n for pts_id, pts in tqdm(pts3d.items()):\n pts3d_array[pts_id, :3] = torch.from_numpy(pts.xyz).cuda()\n\n img_errors = torch.ones(len(img_ids), 1)\n for id, img_id in tqdm(enumerate(img_ids)):\n img = imdata[img_id]\n entrinsic = torch.from_numpy(entrinsics_dict[img_id]).float().cuda()\n intrinsic = torch.from_numpy(intrinsics_dict[img_id]).float().cuda()\n img_p3d = pts3d_array[img.point3D_ids]\n projected = intrinsic @ entrinsic[:3] @ img_p3d.T\n projected[:2, :] /= projected[2, :].unsqueeze(0)\n img_2d = torch.from_numpy(img.xys)\n", "probing input new": "def image_reproj_error(imdata, pts3d, img_ids, entrinsics_dict, intrinsics_dict):\n pts3d_array = torch.ones(max(pts3d.keys()) + 1, 4).cuda()\n for pts_id, pts in tqdm(pts3d.items()):\n pts3d_array[pts_id, :3] = torch.from_numpy(pts.xyz).cuda()\n\n img_errors = torch.ones(len(img_ids), 1)\n for id, img_id in tqdm(enumerate(img_ids)):\n img = imdata[img_id]\n entrinsic = torch.from_numpy(entrinsics_dict[img_id]).float().cuda()\n intrinsic = torch.from_numpy(intrinsics_dict[img_id]).float().cuda()\n img_p3d = pts3d_array[img.point3D_ids]\n projected = intrinsic @ entrinsic[:3] @ img_p3d.T\n projected[:2, :] /= projected[2, :].unsqueeze(0)\n img_2d = torch.from_numpy(img.xys)\n img_error = torch.", "reference": "img_error=torch.linalg.norm(projected[:2,:].T.cpu()-img_2d,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "img_error=torch.linalg.norm(projected[:2,:].T.cpu()-img_2d,dim=-1)", "y_neg": " img_error = torch.norm(projected[:2, :] - img_2d, p=2, dim=1)", "retain": "def image_reproj_error(imdata, pts3d, img_ids, entrinsics_dict, intrinsics_dict):\n pts3d_array = torch.ones(max(pts3d.keys()) + 1, 4).cuda()\n for pts_id, pts in tqdm(pts3d.items()):\n pts3d_array[pts_id, :3] = torch.from_numpy(pts.xyz).cuda()\n\n img_errors = torch.ones(len(img_ids), 1)\n for id, img_id in tqdm(enumerate(img_ids)):\n img = imdata[img_id]\n entrinsic = torch.from_numpy(entrinsics_dict[img_id]).float().cuda()\n intrinsic = torch.from_numpy(intrinsics_dict[img_id]).float().cuda()\n img_p3d = pts3d_array[img.point3D_ids]\n projected = intrinsic @ entrinsic[:3] @ img_p3d.T\n projected[:2, :] /= projected[2, :].unsqueeze(0)\n img_2d = torch.from_numpy(img.xys)\n img_error = torch.linalg.norm(projected[:2, :].T.cpu() - img_2d, dim=-1)\n img_errors[id] = torch.sum(img_error) / img_error.size()[0]\n # print(f\"img_error: {img_errors[id]}\")\n\n return img_errors" }, { "id": 7423, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n inputs: Dict[str, torch.Tensor],\n ) -> Dict[str, torch.Tensor]:\n # compute distances of atoms to (0, 0, 0)\n center_dists = torch.linalg.norm(inputs[properties.R], dim=1)\n # order by that distance\n _, order = center_dists.sort()\n # store ordered positions and types\n inputs[properties.R] = inputs[properties.R][order]\n inputs[properties.Z] = inputs[properties.Z][order]\n return inputs", "probing input": " def forward(\n self,\n inputs: Dict[str, torch.Tensor],\n ) -> Dict[str, torch.Tensor]:\n # compute distances of atoms to (0, 0, 0)\n", "probing input new": " def forward(\n self,\n inputs: Dict[str, torch.Tensor],\n ) -> Dict[str, torch.Tensor]:\n # compute distances of atoms to (0, 0, 0)\n center_dists = torch.", "reference": "center_dists=torch.linalg.norm(inputs[properties.R],dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "center_dists=torch.linalg.norm(inputs[properties.R],dim=1)", "y_neg": " center_dists = torch.norm(inputs['atoms'] - torch.tensor([0, 0, 0]), dim=-1)", "retain": " def forward(\n self,\n inputs: Dict[str, torch.Tensor],\n ) -> Dict[str, torch.Tensor]:\n # compute distances of atoms to (0, 0, 0)\n center_dists = torch.linalg.norm(inputs[properties.R], dim=1)\n # order by that distance\n _, order = center_dists.sort()\n # store ordered positions and types\n inputs[properties.R] = inputs[properties.R][order]\n inputs[properties.Z] = inputs[properties.Z][order]\n return inputs" }, { "id": 7425, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_kernel(X, sigma2=1.0, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.linalg.norm(X, dim=1, keepdim=True)\n if Y is not None:\n Y = Y / torch.linalg.norm(Y, dim=1, keepdim=True)\n Dxx = compute_pdist_sq(X, Y)\n if sigma2 is None:\n sigma2 = Dxx.median()\n Kx = torch.exp(-Dxx / sigma2)\n return Kx", "probing input": "def gaussian_kernel(X, sigma2=1.0, Y=None, normalized=False, **ignored):\n if normalized:\n", "probing input new": "def gaussian_kernel(X, sigma2=1.0, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.", "reference": "X=X/torch.linalg.norm(X,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "X=X/torch.linalg.norm(X,dim=1,keepdim=True)", "y_neg": " X = X / torch.norm(X, 2, 1, keepdim=True)", "retain": "def gaussian_kernel(X, sigma2=1.0, Y=None, normalized=False, **ignored):\n if normalized:\n X = X / torch.linalg.norm(X, dim=1, keepdim=True)\n if Y is not None:\n Y = Y / torch.linalg.norm(Y, dim=1, keepdim=True)\n Dxx = compute_pdist_sq(X, Y)\n if sigma2 is None:\n sigma2 = Dxx.median()\n Kx = torch.exp(-Dxx / sigma2)\n return Kx" }, { "id": 7431, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def contract_to_unisphere(self,\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: int = 2,\n eps: float = 1e-6,\n derivative: bool = False,\n ):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n mask = mag.squeeze(-1) > 1\n\n if derivative:\n dev = (2 * mag - 1) / mag**2 + 2 * x**2 * (\n 1 / mag**3 - (2 * mag - 1) / mag**4\n )\n dev[~mask] = 1.0\n dev = torch.clamp(dev, min=eps)\n return dev\n else:\n x[mask] = (2 - 1 / mag[mask]) * (x[mask] / mag[mask])\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x", "probing input": " def contract_to_unisphere(self,\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: int = 2,\n eps: float = 1e-6,\n derivative: bool = False,\n ):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n", "probing input new": " def contract_to_unisphere(self,\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: int = 2,\n eps: float = 1e-6,\n derivative: bool = False,\n ):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "y_neg": " mag = torch.norm(x, p=ord, dim=-1, keepdim=True)", "retain": " def contract_to_unisphere(self,\n x: torch.Tensor,\n aabb: torch.Tensor,\n ord: int = 2,\n eps: float = 1e-6,\n derivative: bool = False,\n ):\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min)\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n mask = mag.squeeze(-1) > 1\n\n if derivative:\n dev = (2 * mag - 1) / mag**2 + 2 * x**2 * (\n 1 / mag**3 - (2 * mag - 1) / mag**4\n )\n dev[~mask] = 1.0\n dev = torch.clamp(dev, min=eps)\n return dev\n else:\n x[mask] = (2 - 1 / mag[mask]) * (x[mask] / mag[mask])\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x" }, { "id": 7432, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if False:\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if False:\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n", "probing input new": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if False:\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if False:\n if(quats is not None):\n quats = quats.type(torch.float32)\n if(rot_mats is not None):\n rot_mats = rot_mats.type(torch.float32)\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7433, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def contract(\n x: Tensor,\n aabb: Tensor,\n ord: Union[str, int] = None,\n) -> Tensor:\n \"\"\"\n Contract the input tensor to the unit cube using piecewise projective function.\n \"\"\"\n # similar to the one in MeRF paper\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min) # 0~1\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n x = torch.where(mag < 1, x, (2 - 1 / mag) * (x / mag))\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x", "probing input": "def contract(\n x: Tensor,\n aabb: Tensor,\n ord: Union[str, int] = None,\n) -> Tensor:\n \"\"\"\n Contract the input tensor to the unit cube using piecewise projective function.\n \"\"\"\n # similar to the one in MeRF paper\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min) # 0~1\n x = x * 2 - 1 # aabb is at [-1, 1]\n", "probing input new": "def contract(\n x: Tensor,\n aabb: Tensor,\n ord: Union[str, int] = None,\n) -> Tensor:\n \"\"\"\n Contract the input tensor to the unit cube using piecewise projective function.\n \"\"\"\n # similar to the one in MeRF paper\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min) # 0~1\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=ord,dim=-1,keepdim=True)", "y_neg": " mag = torch.norm(x, p=ord, dim=-1)", "retain": "def contract(\n x: Tensor,\n aabb: Tensor,\n ord: Union[str, int] = None,\n) -> Tensor:\n \"\"\"\n Contract the input tensor to the unit cube using piecewise projective function.\n \"\"\"\n # similar to the one in MeRF paper\n aabb_min, aabb_max = torch.split(aabb, 3, dim=-1)\n x = (x - aabb_min) / (aabb_max - aabb_min) # 0~1\n x = x * 2 - 1 # aabb is at [-1, 1]\n mag = torch.linalg.norm(x, ord=ord, dim=-1, keepdim=True)\n x = torch.where(mag < 1, x, (2 - 1 / mag) * (x / mag))\n x = x / 4 + 0.5 # [-inf, inf] is at [0, 1]\n return x" }, { "id": 7437, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def embed_utterance_batch(wavs, using_partials=True, return_partials=False, **kwargs):\n # This torch version is designed to cope with a batch of same lengths wavs\n if not using_partials:\n print(wavs.shape)\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n embeds = embed_frames_batch(frames)\n if return_partials:\n return embeds, None, None\n return embeds\n\n wave_slices, mel_slices = compute_partial_slices(wavs.shape[-1], **kwargs)\n max_wave_length = wave_slices[-1].stop\n if max_wave_length >= wavs.shape[-1]:\n wavs = torch.cat([wavs, torch.ones((wavs.shape[0], max_wave_length - wavs.shape[-1]), \n dtype=wavs.dtype, device=wavs.device)], 1)\n\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n frames_batch = []\n for i in range(len(frames)):\n frames_batch += [frames[i][s] for s in mel_slices]\n frames_batch = torch.stack(frames_batch, 0)\n partial_embeds = embed_frames_batch(frames_batch, use_torch=True)\n partial_embeds = partial_embeds.view(wavs.shape[0], len(mel_slices), -1)\n\n raw_embeds = torch.mean(partial_embeds, axis=1, keepdims=False)\n embeds = raw_embeds / torch.linalg.norm(raw_embeds, axis=-1, keepdims=True)\n\n if return_partials:\n return embeds, partial_embeds, wave_slices\n return embeds", "probing input": "def embed_utterance_batch(wavs, using_partials=True, return_partials=False, **kwargs):\n # This torch version is designed to cope with a batch of same lengths wavs\n if not using_partials:\n print(wavs.shape)\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n embeds = embed_frames_batch(frames)\n if return_partials:\n return embeds, None, None\n return embeds\n\n wave_slices, mel_slices = compute_partial_slices(wavs.shape[-1], **kwargs)\n max_wave_length = wave_slices[-1].stop\n if max_wave_length >= wavs.shape[-1]:\n wavs = torch.cat([wavs, torch.ones((wavs.shape[0], max_wave_length - wavs.shape[-1]), \n dtype=wavs.dtype, device=wavs.device)], 1)\n\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n frames_batch = []\n for i in range(len(frames)):\n frames_batch += [frames[i][s] for s in mel_slices]\n frames_batch = torch.stack(frames_batch, 0)\n partial_embeds = embed_frames_batch(frames_batch, use_torch=True)\n partial_embeds = partial_embeds.view(wavs.shape[0], len(mel_slices), -1)\n\n raw_embeds = torch.mean(partial_embeds, axis=1, keepdims=False)\n", "probing input new": "def embed_utterance_batch(wavs, using_partials=True, return_partials=False, **kwargs):\n # This torch version is designed to cope with a batch of same lengths wavs\n if not using_partials:\n print(wavs.shape)\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n embeds = embed_frames_batch(frames)\n if return_partials:\n return embeds, None, None\n return embeds\n\n wave_slices, mel_slices = compute_partial_slices(wavs.shape[-1], **kwargs)\n max_wave_length = wave_slices[-1].stop\n if max_wave_length >= wavs.shape[-1]:\n wavs = torch.cat([wavs, torch.ones((wavs.shape[0], max_wave_length - wavs.shape[-1]), \n dtype=wavs.dtype, device=wavs.device)], 1)\n\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n frames_batch = []\n for i in range(len(frames)):\n frames_batch += [frames[i][s] for s in mel_slices]\n frames_batch = torch.stack(frames_batch, 0)\n partial_embeds = embed_frames_batch(frames_batch, use_torch=True)\n partial_embeds = partial_embeds.view(wavs.shape[0], len(mel_slices), -1)\n\n raw_embeds = torch.mean(partial_embeds, axis=1, keepdims=False)\n embeds = raw_embeds / torch.", "reference": "embeds=raw_embeds/torch.linalg.norm(raw_embeds,axis=-1,keepdims=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "embeds=raw_embeds/torch.linalg.norm(raw_embeds,axis=-1,keepdims=True)", "y_neg": " embeds = raw_embeds / torch.norm(raw_embeds, p=2, dim=1, keepdims=True)", "retain": "def embed_utterance_batch(wavs, using_partials=True, return_partials=False, **kwargs):\n # This torch version is designed to cope with a batch of same lengths wavs\n if not using_partials:\n print(wavs.shape)\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n embeds = embed_frames_batch(frames)\n if return_partials:\n return embeds, None, None\n return embeds\n\n wave_slices, mel_slices = compute_partial_slices(wavs.shape[-1], **kwargs)\n max_wave_length = wave_slices[-1].stop\n if max_wave_length >= wavs.shape[-1]:\n wavs = torch.cat([wavs, torch.ones((wavs.shape[0], max_wave_length - wavs.shape[-1]), \n dtype=wavs.dtype, device=wavs.device)], 1)\n\n frames = audio.wav_to_mel_spectrogram_batch(wavs)\n frames_batch = []\n for i in range(len(frames)):\n frames_batch += [frames[i][s] for s in mel_slices]\n frames_batch = torch.stack(frames_batch, 0)\n partial_embeds = embed_frames_batch(frames_batch, use_torch=True)\n partial_embeds = partial_embeds.view(wavs.shape[0], len(mel_slices), -1)\n\n raw_embeds = torch.mean(partial_embeds, axis=1, keepdims=False)\n embeds = raw_embeds / torch.linalg.norm(raw_embeds, axis=-1, keepdims=True)\n\n if return_partials:\n return embeds, partial_embeds, wave_slices\n return embeds" }, { "id": 7440, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm(x: ArrayLike, ord=None, axis=None, keepdims: KeepDims = False):\n x = _atleast_float_1(x)\n return torch.linalg.norm(x, ord=ord, dim=axis)", "probing input": "def norm(x: ArrayLike, ord=None, axis=None, keepdims: KeepDims = False):\n x = _atleast_float_1(x)\n", "probing input new": "def norm(x: ArrayLike, ord=None, axis=None, keepdims: KeepDims = False):\n x = _atleast_float_1(x)\n return torch.", "reference": "returntorch.linalg.norm(x,ord=ord,dim=axis)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(x,ord=ord,dim=axis)", "y_neg": " return torch.norm(x, ord=ord, dim=axis, keepdim=keepdims)", "retain": "def norm(x: ArrayLike, ord=None, axis=None, keepdims: KeepDims = False):\n x = _atleast_float_1(x)\n return torch.linalg.norm(x, ord=ord, dim=axis)" }, { "id": 7441, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # Batch, N_rays, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # Batch, N_rays, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # Batch, N_rays, 3\n rays_d = rays_v\n\n rays_o = rays_o.contiguous().view(-1, 3)\n rays_d = rays_d.contiguous().view(-1, 3)\n\n ################## - sphere tracer to extract depth maps ######################\n depth_masks_sphere, depth_maps_sphere = self.ray_tracer.extract_depth_maps(\n rays_o, rays_d,\n near[None, :].repeat(rays_o.shape[0], 1),\n far[None, :].repeat(rays_o.shape[0], 1),\n sdf_network, con_volume\n )\n\n depth_maps = depth_maps_sphere.view(batch_size, 1, H, W)\n depth_masks = depth_masks_sphere.view(batch_size, 1, H, W)\n\n depth_maps = torch.where(depth_masks, depth_maps,\n torch.zeros_like(depth_masks.float()).to(device)) # fill invalid pixels by 0\n\n return depth_maps, depth_masks", "probing input": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n", "probing input new": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # Batch, N_rays, 3", "retain": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # Batch, N_rays, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # Batch, N_rays, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # Batch, N_rays, 3\n rays_d = rays_v\n\n rays_o = rays_o.contiguous().view(-1, 3)\n rays_d = rays_d.contiguous().view(-1, 3)\n\n ################## - sphere tracer to extract depth maps ######################\n depth_masks_sphere, depth_maps_sphere = self.ray_tracer.extract_depth_maps(\n rays_o, rays_d,\n near[None, :].repeat(rays_o.shape[0], 1),\n far[None, :].repeat(rays_o.shape[0], 1),\n sdf_network, con_volume\n )\n\n depth_maps = depth_maps_sphere.view(batch_size, 1, H, W)\n depth_masks = depth_masks_sphere.view(batch_size, 1, H, W)\n\n depth_maps = torch.where(depth_masks, depth_maps,\n torch.zeros_like(depth_masks.float()).to(device)) # fill invalid pixels by 0\n\n return depth_maps, depth_masks" }, { "id": 7442, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, q_xyzs, k_xyzs, knn_idx, mask):\n # q_xyzs: (b, 3, m)\n # k_xyzs: (b, 3, n)\n # knn_idx: (b, m, k)\n # mask: (b, m, k)\n # knn_xyzs: (b, 3, m, k)\n # repeated_xyzs: (b, 3, m, k)\n # direction: (b, 3, m, k)\n # distance: (b, 1, m, k)\n # local_pattern: (b, 4, m, k)\n # position_embedding_expanded: (b, c, m, k)\n # attn: (b, c, m, k)\n # position_embedding: (b, c, m)\n\n # \"query\" (q_xyzs) points are the centroids of each point group.\n # \"key\" (k_xyzs) points are points in the neighborhood of each centroid.\n\n _, _, k = knn_idx.shape\n knn_xyzs = index_points(k_xyzs, knn_idx)\n repeated_xyzs = q_xyzs[..., None].repeat(1, 1, 1, k)\n\n # Represent points within a point group as (direction, distance)\n # of offsets from the group centroid.\n offset_xyzs = knn_xyzs - repeated_xyzs\n direction = F.normalize(offset_xyzs, p=2, dim=1)\n distance = torch.linalg.norm(offset_xyzs, dim=1, keepdim=True)\n local_pattern = torch.cat((direction, distance), dim=1)\n\n # Apply a pointwise MLP to each point.\n position_embedding_expanded = self.embed_positions(local_pattern)\n\n # Compute self-attention, ignoring points that are not in the\n # neighborhood of the centroid.\n attn = self.attention(position_embedding_expanded)\n mask_value = -(torch.finfo(attn.dtype).max)\n attn.masked_fill_(~mask[:, None], mask_value)\n attn = F.softmax(attn, dim=-1)\n position_embedding = (position_embedding_expanded * attn).sum(dim=-1)\n\n return position_embedding", "probing input": " def forward(self, q_xyzs, k_xyzs, knn_idx, mask):\n # q_xyzs: (b, 3, m)\n # k_xyzs: (b, 3, n)\n # knn_idx: (b, m, k)\n # mask: (b, m, k)\n # knn_xyzs: (b, 3, m, k)\n # repeated_xyzs: (b, 3, m, k)\n # direction: (b, 3, m, k)\n # distance: (b, 1, m, k)\n # local_pattern: (b, 4, m, k)\n # position_embedding_expanded: (b, c, m, k)\n # attn: (b, c, m, k)\n # position_embedding: (b, c, m)\n\n # \"query\" (q_xyzs) points are the centroids of each point group.\n # \"key\" (k_xyzs) points are points in the neighborhood of each centroid.\n\n _, _, k = knn_idx.shape\n knn_xyzs = index_points(k_xyzs, knn_idx)\n repeated_xyzs = q_xyzs[..., None].repeat(1, 1, 1, k)\n\n # Represent points within a point group as (direction, distance)\n # of offsets from the group centroid.\n offset_xyzs = knn_xyzs - repeated_xyzs\n direction = F.normalize(offset_xyzs, p=2, dim=1)\n", "probing input new": " def forward(self, q_xyzs, k_xyzs, knn_idx, mask):\n # q_xyzs: (b, 3, m)\n # k_xyzs: (b, 3, n)\n # knn_idx: (b, m, k)\n # mask: (b, m, k)\n # knn_xyzs: (b, 3, m, k)\n # repeated_xyzs: (b, 3, m, k)\n # direction: (b, 3, m, k)\n # distance: (b, 1, m, k)\n # local_pattern: (b, 4, m, k)\n # position_embedding_expanded: (b, c, m, k)\n # attn: (b, c, m, k)\n # position_embedding: (b, c, m)\n\n # \"query\" (q_xyzs) points are the centroids of each point group.\n # \"key\" (k_xyzs) points are points in the neighborhood of each centroid.\n\n _, _, k = knn_idx.shape\n knn_xyzs = index_points(k_xyzs, knn_idx)\n repeated_xyzs = q_xyzs[..., None].repeat(1, 1, 1, k)\n\n # Represent points within a point group as (direction, distance)\n # of offsets from the group centroid.\n offset_xyzs = knn_xyzs - repeated_xyzs\n direction = F.normalize(offset_xyzs, p=2, dim=1)\n distance = torch.", "reference": "distance=torch.linalg.norm(offset_xyzs,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distance=torch.linalg.norm(offset_xyzs,dim=1,keepdim=True)", "y_neg": " distance = torch.norm(offset_xyzs, p=2, dim=-1)", "retain": " def forward(self, q_xyzs, k_xyzs, knn_idx, mask):\n # q_xyzs: (b, 3, m)\n # k_xyzs: (b, 3, n)\n # knn_idx: (b, m, k)\n # mask: (b, m, k)\n # knn_xyzs: (b, 3, m, k)\n # repeated_xyzs: (b, 3, m, k)\n # direction: (b, 3, m, k)\n # distance: (b, 1, m, k)\n # local_pattern: (b, 4, m, k)\n # position_embedding_expanded: (b, c, m, k)\n # attn: (b, c, m, k)\n # position_embedding: (b, c, m)\n\n # \"query\" (q_xyzs) points are the centroids of each point group.\n # \"key\" (k_xyzs) points are points in the neighborhood of each centroid.\n\n _, _, k = knn_idx.shape\n knn_xyzs = index_points(k_xyzs, knn_idx)\n repeated_xyzs = q_xyzs[..., None].repeat(1, 1, 1, k)\n\n # Represent points within a point group as (direction, distance)\n # of offsets from the group centroid.\n offset_xyzs = knn_xyzs - repeated_xyzs\n direction = F.normalize(offset_xyzs, p=2, dim=1)\n distance = torch.linalg.norm(offset_xyzs, dim=1, keepdim=True)\n local_pattern = torch.cat((direction, distance), dim=1)\n\n # Apply a pointwise MLP to each point.\n position_embedding_expanded = self.embed_positions(local_pattern)\n\n # Compute self-attention, ignoring points that are not in the\n # neighborhood of the centroid.\n attn = self.attention(position_embedding_expanded)\n mask_value = -(torch.finfo(attn.dtype).max)\n attn.masked_fill_(~mask[:, None], mask_value)\n attn = F.softmax(attn, dim=-1)\n position_embedding = (position_embedding_expanded * attn).sum(dim=-1)\n\n return position_embedding" }, { "id": 7443, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays(self):\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[:, None, None, :3, :3], p[None, :, :, :, None]).squeeze() # n, W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # n, W, H, 3\n rays_v = torch.matmul(self.pose_all[:, None, None, :3, :3], rays_v[:, :, :, :, None]).squeeze() # n, W, H, 3\n rays_o = self.pose_all[:, None, None, :3, 3].expand(rays_v.shape) # n, W, H, 3\n return rays_o.transpose(1, 2), rays_v.transpose(1, 2)", "probing input": " def gen_rays(self):\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[:, None, None, :3, :3], p[None, :, :, :, None]).squeeze() # n, W, H, 3\n", "probing input new": " def gen_rays(self):\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[:, None, None, :3, :3], p[None, :, :, :, None]).squeeze() # n, W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p[:, :, :, 2:3], dim=-1, keepdim=True) # n, W, H, 3", "retain": " def gen_rays(self):\n tx = torch.linspace(0, self.W - 1, self.W)\n ty = torch.linspace(0, self.H - 1, self.H)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[:, None, None, :3, :3], p[None, :, :, :, None]).squeeze() # n, W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # n, W, H, 3\n rays_v = torch.matmul(self.pose_all[:, None, None, :3, :3], rays_v[:, :, :, :, None]).squeeze() # n, W, H, 3\n rays_o = self.pose_all[:, None, None, :3, 3].expand(rays_v.shape) # n, W, H, 3\n return rays_o.transpose(1, 2), rays_v.transpose(1, 2)" }, { "id": 7444, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, pose = None, resolution_level=1):\n pose_cur = self.get_pose(img_idx, pose)\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose_cur[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = pose_cur[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, pose = None, resolution_level=1):\n pose_cur = self.get_pose(img_idx, pose)\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, pose = None, resolution_level=1):\n pose_cur = self.get_pose(img_idx, pose)\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, pose = None, resolution_level=1):\n pose_cur = self.get_pose(img_idx, pose)\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose_cur[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = pose_cur[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7445, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7446, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose_cur[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose_cur[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n \n normal_sample = None\n if self.use_normal:\n normal_sample = self.normals[img_idx][(pixels_y, pixels_x)].cuda()\n\n planes_sample = None\n if self.use_planes:\n planes_sample = self.planes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n \n subplanes_sample = None\n if self.use_plane_offset_loss:\n subplanes_sample = self.subplanes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask], dim=-1).cuda(), pixels_x, pixels_y, normal_sample, planes_sample, subplanes_sample", "probing input": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose_cur[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose_cur[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n \n normal_sample = None\n if self.use_normal:\n normal_sample = self.normals[img_idx][(pixels_y, pixels_x)].cuda()\n\n planes_sample = None\n if self.use_planes:\n planes_sample = self.planes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n \n subplanes_sample = None\n if self.use_plane_offset_loss:\n subplanes_sample = self.subplanes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask], dim=-1).cuda(), pixels_x, pixels_y, normal_sample, planes_sample, subplanes_sample" }, { "id": 7450, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n prev_cos_val = torch.cat(\n [torch.zeros([batch_size, 1]).to(self.device), cos_val[:, :-1]],\n dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([\n torch.ones([batch_size, 1]).to(self.device), 1. - alpha + 1e-7\n ], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(\n z_vals, weights, n_importance, det=True,\n device=self.device).detach()\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts - rays_o[:, None, :], dim=-1, p=2, keepdim=True)", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n prev_cos_val = torch.cat(\n [torch.zeros([batch_size, 1]).to(self.device), cos_val[:, :-1]],\n dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([\n torch.ones([batch_size, 1]).to(self.device), 1. - alpha + 1e-7\n ], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(\n z_vals, weights, n_importance, det=True,\n device=self.device).detach()\n return z_samples" }, { "id": 7452, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def norm(self, a, axis=None, keepdims=False):\n return torch.linalg.norm(a, dim=axis, keepdims=keepdims)", "probing input": " def norm(self, a, axis=None, keepdims=False):\n", "probing input new": " def norm(self, a, axis=None, keepdims=False):\n return torch.", "reference": "returntorch.linalg.norm(a,dim=axis,keepdims=keepdims)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(a,dim=axis,keepdims=keepdims)", "y_neg": " return torch.norm(a, p=2, dim=axis, keepdim=keepdims)", "retain": " def norm(self, a, axis=None, keepdims=False):\n return torch.linalg.norm(a, dim=axis, keepdims=keepdims)" }, { "id": 7453, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def generate_circle_by_vectors(t, C, r, n, u):\n n = n/torch.linalg.norm(n)\n u = u/torch.linalg.norm(u)\n P_circle = r*torch.cos(t)[:,None]*u + r*torch.sin(t)[:,None]*torch.cross(n,u) + C\n return P_circle", "probing input": "def generate_circle_by_vectors(t, C, r, n, u):\n", "probing input new": "def generate_circle_by_vectors(t, C, r, n, u):\n n = n/torch.", "reference": "n=n/torch.linalg.norm(n)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "n=n/torch.linalg.norm(n)", "y_neg": " n = n/torch.norm(u)", "retain": "def generate_circle_by_vectors(t, C, r, n, u):\n n = n/torch.linalg.norm(n)\n u = u/torch.linalg.norm(u)\n P_circle = r*torch.cos(t)[:,None]*u + r*torch.sin(t)[:,None]*torch.cross(n,u) + C\n return P_circle" }, { "id": 7454, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rodrigues_rot(P, n0, n1):\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n # Get vector of rotation k and angle theta\n n0 = n0/torch.linalg.norm(n0)\n n1 = n1/torch.linalg.norm(n1)\n k = torch.cross(n0,n1)\n k = k/torch.linalg.norm(k)\n theta = torch.arccos(torch.dot(n0,n1))\n \n # Compute rotated points\n P_rot = torch.zeros((len(P),3))\n for i in range(len(P)):\n P_rot[i] = P[i]*torch.cos(theta) + torch.cross(k,P[i])*torch.sin(theta) + k*torch.dot(k,P[i])*(1-torch.cos(theta))\n\n return P_rot", "probing input": "def rodrigues_rot(P, n0, n1):\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n # Get vector of rotation k and angle theta\n", "probing input new": "def rodrigues_rot(P, n0, n1):\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n # Get vector of rotation k and angle theta\n n0 = n0/torch.", "reference": "n0=n0/torch.linalg.norm(n0)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "n0=n0/torch.linalg.norm(n0)", "y_neg": " n0 = n0/torch.norm(n0)", "retain": "def rodrigues_rot(P, n0, n1):\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n # Get vector of rotation k and angle theta\n n0 = n0/torch.linalg.norm(n0)\n n1 = n1/torch.linalg.norm(n1)\n k = torch.cross(n0,n1)\n k = k/torch.linalg.norm(k)\n theta = torch.arccos(torch.dot(n0,n1))\n \n # Compute rotated points\n P_rot = torch.zeros((len(P),3))\n for i in range(len(P)):\n P_rot[i] = P[i]*torch.cos(theta) + torch.cross(k,P[i])*torch.sin(theta) + k*torch.dot(k,P[i])*(1-torch.cos(theta))\n\n return P_rot" }, { "id": 7455, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rodrigues_rot2(P, n1, theta):\n '''\n Rotate points P wrt axis k by theta radians\n '''\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n k = torch.cross(P, n1.unsqueeze(0))\n k = k/torch.linalg.norm(k)\n \n # Compute rotated points\n P_rot = torch.zeros((len(P),3))\n for i in range(len(P)):\n P_rot[i] = P[i]*torch.cos(theta[i]) + torch.cross(k[i],P[i])*torch.sin(theta[i]) + k[i]*torch.dot(k[i],P[i])*(1-torch.cos(theta[i]))\n\n return P_rot", "probing input": "def rodrigues_rot2(P, n1, theta):\n '''\n Rotate points P wrt axis k by theta radians\n '''\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n k = torch.cross(P, n1.unsqueeze(0))\n", "probing input new": "def rodrigues_rot2(P, n1, theta):\n '''\n Rotate points P wrt axis k by theta radians\n '''\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n k = torch.cross(P, n1.unsqueeze(0))\n k = k/torch.", "reference": "k=k/torch.linalg.norm(k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "k=k/torch.linalg.norm(k)", "y_neg": " k = k/torch.norm(k)", "retain": "def rodrigues_rot2(P, n1, theta):\n '''\n Rotate points P wrt axis k by theta radians\n '''\n \n # If P is only 1d array (coords of single point), fix it to be matrix\n if P.ndim == 1:\n P = P[None,...]\n \n k = torch.cross(P, n1.unsqueeze(0))\n k = k/torch.linalg.norm(k)\n \n # Compute rotated points\n P_rot = torch.zeros((len(P),3))\n for i in range(len(P)):\n P_rot[i] = P[i]*torch.cos(theta[i]) + torch.cross(k[i],P[i])*torch.sin(theta[i]) + k[i]*torch.dot(k[i],P[i])*(1-torch.cos(theta[i]))\n\n return P_rot" }, { "id": 7457, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_angles(target_camera: PerspectiveCameras, context_cameras: PerspectiveCameras, centroid=None):\n '''\n Get angles between cameras wrt a centroid\n\n Args:\n target_camera (Pytorch3D Camera): a camera object with a single camera\n context_cameras (PyTorch3D Camera): a camera object\n\n Returns:\n theta_deg (Tensor): a tensor containing angles in degrees\n '''\n a1 = target_camera.get_camera_center()\n b1 = context_cameras.get_camera_center()\n\n a = a1 - centroid.unsqueeze(0)\n a = a.expand(len(context_cameras), -1)\n b = b1 - centroid.unsqueeze(0)\n\n ab_dot = (a*b).sum(dim=-1)\n theta = torch.acos((ab_dot)/(torch.linalg.norm(a, dim=-1) * torch.linalg.norm(b, dim=-1)))\n theta_deg = theta * 180 / math.pi\n \n return theta_deg", "probing input": "def get_angles(target_camera: PerspectiveCameras, context_cameras: PerspectiveCameras, centroid=None):\n '''\n Get angles between cameras wrt a centroid\n\n Args:\n target_camera (Pytorch3D Camera): a camera object with a single camera\n context_cameras (PyTorch3D Camera): a camera object\n\n Returns:\n theta_deg (Tensor): a tensor containing angles in degrees\n '''\n a1 = target_camera.get_camera_center()\n b1 = context_cameras.get_camera_center()\n\n a = a1 - centroid.unsqueeze(0)\n a = a.expand(len(context_cameras), -1)\n b = b1 - centroid.unsqueeze(0)\n\n ab_dot = (a*b).sum(dim=-1)\n", "probing input new": "def get_angles(target_camera: PerspectiveCameras, context_cameras: PerspectiveCameras, centroid=None):\n '''\n Get angles between cameras wrt a centroid\n\n Args:\n target_camera (Pytorch3D Camera): a camera object with a single camera\n context_cameras (PyTorch3D Camera): a camera object\n\n Returns:\n theta_deg (Tensor): a tensor containing angles in degrees\n '''\n a1 = target_camera.get_camera_center()\n b1 = context_cameras.get_camera_center()\n\n a = a1 - centroid.unsqueeze(0)\n a = a.expand(len(context_cameras), -1)\n b = b1 - centroid.unsqueeze(0)\n\n ab_dot = (a*b).sum(dim=-1)\n theta = torch.acos((ab_dot)/(torch.", "reference": "theta=torch.acos((ab_dot)/(torch.linalg.norm(a,dim=-1)*torch.linalg.norm(b,dim=-1)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.acos((ab_dot)/(torch.linalg.norm(a,dim=-1)*torch.linalg.norm(b,dim=-1)))", "y_neg": " theta = torch.acos((ab_dot)/(torch.norm(a, dim=-1) * torch.norm(b, dim=-1)))*180/torch.pi", "retain": "def get_angles(target_camera: PerspectiveCameras, context_cameras: PerspectiveCameras, centroid=None):\n '''\n Get angles between cameras wrt a centroid\n\n Args:\n target_camera (Pytorch3D Camera): a camera object with a single camera\n context_cameras (PyTorch3D Camera): a camera object\n\n Returns:\n theta_deg (Tensor): a tensor containing angles in degrees\n '''\n a1 = target_camera.get_camera_center()\n b1 = context_cameras.get_camera_center()\n\n a = a1 - centroid.unsqueeze(0)\n a = a.expand(len(context_cameras), -1)\n b = b1 - centroid.unsqueeze(0)\n\n ab_dot = (a*b).sum(dim=-1)\n theta = torch.acos((ab_dot)/(torch.linalg.norm(a, dim=-1) * torch.linalg.norm(b, dim=-1)))\n theta_deg = theta * 180 / math.pi\n \n return theta_deg" }, { "id": 7459, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def enable_channel_pruning(self, ratio, method):\n # Here, we support two cases: L1 norm based pruning and topk based pruning\n self.channel_pruning_ratio = ratio\n self.channel_pruning_method = method\n\n if method == 'l1':\n # compute the l1 norm of each conv2d kernel (the last three dimension)\n weight_norm = torch.linalg.norm(self.weight.data, ord=1, dim=[1, 2, 3])\n mask = TopKBinarizer.apply(weight_norm, self.channel_pruning_ratio, False)\n mask = mask.view(-1, 1, 1, 1)\n mask = mask.to(self.weight.device)\n elif method == 'topk':\n self.channel_mask_scores = nn.Parameter(torch.Tensor(self.weight.size(0), 1, 1, 1))\n self.channel_mask_scores.data = self.channel_mask_scores.data.to(self.weight.device)\n init.kaiming_uniform_(self.channel_mask_scores, a=math.sqrt(5))\n mask = None\n else:\n raise NotImplementedError\n\n self.register_buffer('channel_pruning_mask', mask)", "probing input": " def enable_channel_pruning(self, ratio, method):\n # Here, we support two cases: L1 norm based pruning and topk based pruning\n self.channel_pruning_ratio = ratio\n self.channel_pruning_method = method\n\n if method == 'l1':\n # compute the l1 norm of each conv2d kernel (the last three dimension)\n", "probing input new": " def enable_channel_pruning(self, ratio, method):\n # Here, we support two cases: L1 norm based pruning and topk based pruning\n self.channel_pruning_ratio = ratio\n self.channel_pruning_method = method\n\n if method == 'l1':\n # compute the l1 norm of each conv2d kernel (the last three dimension)\n weight_", "reference": "weight_norm=torch.linalg.norm(self.weight.data,ord=1,dim=[1,2,3])", "reference dict": { "self.channel_mask_scores": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "weight_norm=torch.linalg.norm(self.weight.data,ord=1,dim=[1,2,3])", "y_neg": " weight_l1_norm = torch.norm(self.conv2d.weight.view(self.conv2d.weight.size(0), -1), 1, True)", "retain": " def enable_channel_pruning(self, ratio, method):\n # Here, we support two cases: L1 norm based pruning and topk based pruning\n self.channel_pruning_ratio = ratio\n self.channel_pruning_method = method\n\n if method == 'l1':\n # compute the l1 norm of each conv2d kernel (the last three dimension)\n weight_norm = torch.linalg.norm(self.weight.data, ord=1, dim=[1, 2, 3])\n mask = TopKBinarizer.apply(weight_norm, self.channel_pruning_ratio, False)\n mask = mask.view(-1, 1, 1, 1)\n mask = mask.to(self.weight.device)\n elif method == 'topk':\n self.channel_mask_scores = nn.Parameter(torch.Tensor(self.weight.size(0), 1, 1, 1))\n self.channel_mask_scores.data = self.channel_mask_scores.data.to(self.weight.device)\n init.kaiming_uniform_(self.channel_mask_scores, a=math.sqrt(5))\n mask = None\n else:\n raise NotImplementedError\n\n self.register_buffer('channel_pruning_mask', mask)" }, { "id": 7462, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, q, k, v, need_weights=True):\n \"\"\"Calculate attention.\n\n :param q: Query of shape (n_features,).\n :param k: Keys of shape (n_keys, n_features).\n :param v: Values of shape (n_keys, n_values_features).\n \"\"\"\n eps = 1e-9\n if not self.classical:\n mk = (k - torch.mean(k, axis=1).view(-1, 1)) / (torch.std(k, axis=1).view(-1, 1) + eps)\n mq = (q - torch.mean(q)) / (torch.std(q) + eps)\n else: # self.classical\n mk = k / torch.clamp(torch.linalg.norm(k, axis=0), min=eps)\n mq = q / torch.clamp(torch.linalg.norm(q, axis=0), min=eps)\n\n scores = mk @ mq\n weights = scores\n if self.use_softmax:\n weights = self.softmax(weights)\n weighted_values = weights @ v\n if need_weights:\n return weighted_values, weights\n\n return weighted_values", "probing input": " def forward(self, q, k, v, need_weights=True):\n \"\"\"Calculate attention.\n\n :param q: Query of shape (n_features,).\n :param k: Keys of shape (n_keys, n_features).\n :param v: Values of shape (n_keys, n_values_features).\n \"\"\"\n eps = 1e-9\n if not self.classical:\n mk = (k - torch.mean(k, axis=1).view(-1, 1)) / (torch.std(k, axis=1).view(-1, 1) + eps)\n mq = (q - torch.mean(q)) / (torch.std(q) + eps)\n else: # self.classical\n", "probing input new": " def forward(self, q, k, v, need_weights=True):\n \"\"\"Calculate attention.\n\n :param q: Query of shape (n_features,).\n :param k: Keys of shape (n_keys, n_features).\n :param v: Values of shape (n_keys, n_values_features).\n \"\"\"\n eps = 1e-9\n if not self.classical:\n mk = (k - torch.mean(k, axis=1).view(-1, 1)) / (torch.std(k, axis=1).view(-1, 1) + eps)\n mq = (q - torch.mean(q)) / (torch.std(q) + eps)\n else: # self.classical\n mk = k / torch.clamp(torch.", "reference": "mk=k/torch.clamp(torch.linalg.norm(k,axis=0),min=eps)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mk=k/torch.clamp(torch.linalg.norm(k,axis=0),min=eps)", "y_neg": " mk = k / torch.clamp(torch.norm(k, dim=1, keepdim=True), min=1, max=None)", "retain": " def forward(self, q, k, v, need_weights=True):\n \"\"\"Calculate attention.\n\n :param q: Query of shape (n_features,).\n :param k: Keys of shape (n_keys, n_features).\n :param v: Values of shape (n_keys, n_values_features).\n \"\"\"\n eps = 1e-9\n if not self.classical:\n mk = (k - torch.mean(k, axis=1).view(-1, 1)) / (torch.std(k, axis=1).view(-1, 1) + eps)\n mq = (q - torch.mean(q)) / (torch.std(q) + eps)\n else: # self.classical\n mk = k / torch.clamp(torch.linalg.norm(k, axis=0), min=eps)\n mq = q / torch.clamp(torch.linalg.norm(q, axis=0), min=eps)\n\n scores = mk @ mq\n weights = scores\n if self.use_softmax:\n weights = self.softmax(weights)\n weighted_values = weights @ v\n if need_weights:\n return weighted_values, weights\n\n return weighted_values" }, { "id": 7465, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0.0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 3)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 4.0)", "probing input": "def test_sphere_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0.0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 3)\n", "probing input new": "def test_sphere_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0.0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 3)\n assert all(torch.", "reference": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=4.0)", "reference dict": { "C": "Sphere" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=4.0)", "y_neg": " assert all(torch.norm(points[i] - points[j]) > 0 for i in range(40) for j in range(i + 1, 40))", "retain": "def test_sphere_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0.0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 3)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 4.0)" }, { "id": 7466, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0.0], 5)\n points = C.sample_random_uniform(d=13)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 5.0)", "probing input": "def test_sphere_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0.0], 5)\n points = C.sample_random_uniform(d=13)\n", "probing input new": "def test_sphere_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0.0], 5)\n points = C.sample_random_uniform(d=13)\n assert all(torch.", "reference": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=5.0)", "reference dict": { "C": "Sphere" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=5.0)", "y_neg": " assert all(torch.norm(p - torch.tensor([0, 0, 0.0]), dim=-1) <= 5 for p in points)", "retain": "def test_sphere_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0.0], 5)\n points = C.sample_random_uniform(d=13)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 5.0)" }, { "id": 7470, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_boundary_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 2).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 3)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(2.0)))", "probing input": "def test_sphere_boundary_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 2).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 3)\n", "probing input new": "def test_sphere_boundary_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 2).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 3)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(2.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(2.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center, p=2), 0, atol=1e-6) for p in points)", "retain": "def test_sphere_boundary_random_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 2).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 3)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(2.0)))" }, { "id": 7471, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_boundary_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))", "probing input": "def test_sphere_boundary_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n", "probing input new": "def test_sphere_boundary_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center, p=1), 0) for p in points)", "retain": "def test_sphere_boundary_random_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))" }, { "id": 7472, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_boundary_grid_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 1).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 3)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(1.0)))", "probing input": "def test_sphere_boundary_grid_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 1).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 3)\n", "probing input new": "def test_sphere_boundary_grid_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 1).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 3)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(1.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(1.0)))", "y_neg": " assert all(torch.isclose(torch.norm(points[i] - C.center), 1) for i in range(30))", "retain": "def test_sphere_boundary_grid_sampling_with_n():\n C = Sphere(R3('x'), [0, 0, 0], 1).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 3)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(1.0)))" }, { "id": 7473, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_sphere_boundary_grid_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))", "probing input": "def test_sphere_boundary_grid_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_grid(d=13)\n", "probing input new": "def test_sphere_boundary_grid_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center, p=1), 0) for p in points)", "retain": "def test_sphere_boundary_grid_sampling_with_d():\n C = Sphere(R3('x'), [0, 0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))" }, { "id": 7478, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm(x, ord=None, axis=None, keepdims=False):\n x = convert_to_tensor(x)\n if standardize_dtype(x.dtype) == \"int64\":\n dtype = config.floatx()\n else:\n dtype = dtypes.result_type(x.dtype, float)\n x = cast(x, dtype)\n return torch.linalg.norm(x, ord=ord, dim=axis, keepdim=keepdims)", "probing input": "def norm(x, ord=None, axis=None, keepdims=False):\n x = convert_to_tensor(x)\n if standardize_dtype(x.dtype) == \"int64\":\n dtype = config.floatx()\n else:\n dtype = dtypes.result_type(x.dtype, float)\n x = cast(x, dtype)\n", "probing input new": "def norm(x, ord=None, axis=None, keepdims=False):\n x = convert_to_tensor(x)\n if standardize_dtype(x.dtype) == \"int64\":\n dtype = config.floatx()\n else:\n dtype = dtypes.result_type(x.dtype, float)\n x = cast(x, dtype)\n return torch.", "reference": "returntorch.linalg.norm(x,ord=ord,dim=axis,keepdim=keepdims)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(x,ord=ord,dim=axis,keepdim=keepdims)", "y_neg": " return torch.norm(x, ord=ord, axis=axis, keepdims=keepdims)", "retain": "def norm(x, ord=None, axis=None, keepdims=False):\n x = convert_to_tensor(x)\n if standardize_dtype(x.dtype) == \"int64\":\n dtype = config.floatx()\n else:\n dtype = dtypes.result_type(x.dtype, float)\n x = cast(x, dtype)\n return torch.linalg.norm(x, ord=ord, dim=axis, keepdim=keepdims)" }, { "id": 7481, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def rho_criterion(self, c: torch.Tensor = None):\n differences = torch.stack(\n [\n c[:, j : j + 1] - c[:, j : j + 1].T * torch.ones(self.k, self.k)\n for j in range(self.latent_dim)\n ],\n dim=2,\n )\n\n differences_norm = torch.linalg.norm(differences, dim=-1) + 1e16 * torch.eye(\n self.k\n )\n\n min_dist_between_neigh = torch.min(differences_norm, dim=-1).values\n\n rho = torch.max(min_dist_between_neigh)\n\n return rho", "probing input": " def rho_criterion(self, c: torch.Tensor = None):\n differences = torch.stack(\n [\n c[:, j : j + 1] - c[:, j : j + 1].T * torch.ones(self.k, self.k)\n for j in range(self.latent_dim)\n ],\n dim=2,\n )\n\n", "probing input new": " def rho_criterion(self, c: torch.Tensor = None):\n differences = torch.stack(\n [\n c[:, j : j + 1] - c[:, j : j + 1].T * torch.ones(self.k, self.k)\n for j in range(self.latent_dim)\n ],\n dim=2,\n )\n\n differences_", "reference": "differences_norm=torch.linalg.norm(differences,dim=-1)+1e16*torch.eye(self.k)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "differences_norm=torch.linalg.norm(differences,dim=-1)+1e16*torch.eye(self.k)", "y_neg": " differences_norm = torch.norm(differences, p=\"fro\", dim=2)", "retain": " def rho_criterion(self, c: torch.Tensor = None):\n differences = torch.stack(\n [\n c[:, j : j + 1] - c[:, j : j + 1].T * torch.ones(self.k, self.k)\n for j in range(self.latent_dim)\n ],\n dim=2,\n )\n\n differences_norm = torch.linalg.norm(differences, dim=-1) + 1e16 * torch.eye(\n self.k\n )\n\n min_dist_between_neigh = torch.min(differences_norm, dim=-1).values\n\n rho = torch.max(min_dist_between_neigh)\n\n return rho" }, { "id": 7482, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def G(self, z: torch.Tensor = None) -> torch.Tensor:\n if z.requires_grad == False:\n z.requires_grad = True\n\n g_z = sum(\n [cov * basis(z=z) for cov, basis in zip(self.covariances, self.basis)]\n ) + self.lambd * torch.exp(-self.tau * torch.linalg.norm(z, 2)) * torch.eye(\n self.latent_dim\n )\n\n return g_z", "probing input": " def G(self, z: torch.Tensor = None) -> torch.Tensor:\n if z.requires_grad == False:\n z.requires_grad = True\n\n g_z = sum(\n [cov * basis(z=z) for cov, basis in zip(self.covariances, self.basis)]\n", "probing input new": " def G(self, z: torch.Tensor = None) -> torch.Tensor:\n if z.requires_grad == False:\n z.requires_grad = True\n\n g_z = sum(\n [cov * basis(z=z) for cov, basis in zip(self.covariances, self.basis)]\n ) + self.lambd * torch.exp(-self.tau * torch.", "reference": ")+self.lambd*torch.exp(-self.tau*torch.linalg.norm(z,2))*torch.eye(", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": ")+self.lambd*torch.exp(-self.tau*torch.linalg.norm(z,2))*torch.eye(", "y_neg": " ) + self.lambd * torch.exp(-self.tau * torch.norm(z, p='fro', dim=1))", "retain": " def G(self, z: torch.Tensor = None) -> torch.Tensor:\n if z.requires_grad == False:\n z.requires_grad = True\n\n g_z = sum(\n [cov * basis(z=z) for cov, basis in zip(self.covariances, self.basis)]\n ) + self.lambd * torch.exp(-self.tau * torch.linalg.norm(z, 2)) * torch.eye(\n self.latent_dim\n )\n\n return g_z" }, { "id": 7484, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def angle_between(self, sph_v1, sph_v2):\n def sph2cart(sv):\n r, theta, phi = sv[0], sv[1], sv[2]\n return torch.tensor([r * torch.sin(theta) * torch.cos(phi), r * torch.sin(theta) * torch.sin(phi), r * torch.cos(theta)])\n def unit_vector(v):\n return v / torch.linalg.norm(v)\n def angle_between_2_sph(sv1, sv2):\n v1, v2 = sph2cart(sv1), sph2cart(sv2)\n v1_u, v2_u = unit_vector(v1), unit_vector(v2)\n return torch.arccos(torch.clip(torch.dot(v1_u, v2_u), -1.0, 1.0))\n angles = torch.empty(len(sph_v1), len(sph_v2))\n for i, sv1 in enumerate(sph_v1):\n for j, sv2 in enumerate(sph_v2):\n angles[i][j] = angle_between_2_sph(sv1, sv2)\n return angles", "probing input": " def angle_between(self, sph_v1, sph_v2):\n def sph2cart(sv):\n r, theta, phi = sv[0], sv[1], sv[2]\n return torch.tensor([r * torch.sin(theta) * torch.cos(phi), r * torch.sin(theta) * torch.sin(phi), r * torch.cos(theta)])\n def unit_vector(v):\n", "probing input new": " def angle_between(self, sph_v1, sph_v2):\n def sph2cart(sv):\n r, theta, phi = sv[0], sv[1], sv[2]\n return torch.tensor([r * torch.sin(theta) * torch.cos(phi), r * torch.sin(theta) * torch.sin(phi), r * torch.cos(theta)])\n def unit_vector(v):\n return v / torch.", "reference": "returnv/torch.linalg.norm(v)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnv/torch.linalg.norm(v)", "y_neg": " return v / torch.norm(v)", "retain": " def angle_between(self, sph_v1, sph_v2):\n def sph2cart(sv):\n r, theta, phi = sv[0], sv[1], sv[2]\n return torch.tensor([r * torch.sin(theta) * torch.cos(phi), r * torch.sin(theta) * torch.sin(phi), r * torch.cos(theta)])\n def unit_vector(v):\n return v / torch.linalg.norm(v)\n def angle_between_2_sph(sv1, sv2):\n v1, v2 = sph2cart(sv1), sph2cart(sv2)\n v1_u, v2_u = unit_vector(v1), unit_vector(v2)\n return torch.arccos(torch.clip(torch.dot(v1_u, v2_u), -1.0, 1.0))\n angles = torch.empty(len(sph_v1), len(sph_v2))\n for i, sv1 in enumerate(sph_v1):\n for j, sv2 in enumerate(sph_v2):\n angles[i][j] = angle_between_2_sph(sv1, sv2)\n return angles" }, { "id": 7491, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sample_sphere_points(n_points, radius=1.0):\n points = torch.randn(n_points, 3)\n points /= torch.linalg.norm(points, axis=1).view(-1, 1)\n points *= radius\n return points", "probing input": "def sample_sphere_points(n_points, radius=1.0):\n points = torch.randn(n_points, 3)\n", "probing input new": "def sample_sphere_points(n_points, radius=1.0):\n points = torch.randn(n_points, 3)\n points /= torch.", "reference": "points/=torch.linalg.norm(points,axis=1).view(-1,1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "points/=torch.linalg.norm(points,axis=1).view(-1,1)", "y_neg": " points /= torch.norm(points, dim=1, keepdim=True)", "retain": "def sample_sphere_points(n_points, radius=1.0):\n points = torch.randn(n_points, 3)\n points /= torch.linalg.norm(points, axis=1).view(-1, 1)\n points *= radius\n return points" }, { "id": 7499, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def project_M(M, M_constraint):\n\tif M_constraint == 'simplex':\n\t\tproject2simplex(M, dim=0)\n\telif M_constraint == 'unit sphere':\n\t\tM.div_(torch.linalg.norm(M, ord=2, dim=0, keepdim=True))\n\telif M_constraint == 'nonneg unit sphere':\n\t\tM.clip_(1e-10).div_(torch.linalg.norm(M, ord=2, dim=0, keepdim=True))\n\telse:\n\t\traise NotImplementedError()\n\treturn M", "probing input": "def project_M(M, M_constraint):\n\tif M_constraint == 'simplex':\n\t\tproject2simplex(M, dim=0)\n\telif M_constraint == 'unit sphere':\n", "probing input new": "def project_M(M, M_constraint):\n\tif M_constraint == 'simplex':\n\t\tproject2simplex(M, dim=0)\n\telif M_constraint == 'unit sphere':\n\t\tM.div_(torch.", "reference": "M.div_(torch.linalg.norm(M,ord=2,dim=0,keepdim=True))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "M.div_(torch.linalg.norm(M,ord=2,dim=0,keepdim=True))", "y_neg": "\t\tM.div_(torch.norm(M, dim=1, keepdim=True))", "retain": "def project_M(M, M_constraint):\n\tif M_constraint == 'simplex':\n\t\tproject2simplex(M, dim=0)\n\telif M_constraint == 'unit sphere':\n\t\tM.div_(torch.linalg.norm(M, ord=2, dim=0, keepdim=True))\n\telif M_constraint == 'nonneg unit sphere':\n\t\tM.clip_(1e-10).div_(torch.linalg.norm(M, ord=2, dim=0, keepdim=True))\n\telse:\n\t\traise NotImplementedError()\n\treturn M" }, { "id": 7502, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_normals(inputs: torch.Tensor,\n outputs: torch.Tensor,\n eps: float = 1e-4,\n grad_min: float = -1e4,\n grad_max: float = 1e4,\n retain_graph: bool = True):\n \"\"\"\n Args:\n inputs (B, N, d):\n outputs (B, N):\n\n Returns:\n\n \"\"\"\n assert inputs.ndim == 3 and outputs.ndim == 2, 'input shape expeted to be [B, N, d], and output to be [B, N]'\n d_points = torch.ones_like(outputs, requires_grad=False, device=outputs.device)\n points_grad = torch.autograd.grad(\n outputs=outputs,\n inputs=inputs,\n grad_outputs=d_points,\n create_graph=retain_graph,\n retain_graph=retain_graph,\n only_inputs=True)[0][:, :, -3:]\n\n points_grad = torch.clamp(points_grad, grad_min, grad_max)\n norm = torch.linalg.norm(points_grad, dim=-1).unsqueeze(-1).detach()\n point_normals = points_grad / (eps + norm)\n\n return point_normals", "probing input": "def compute_normals(inputs: torch.Tensor,\n outputs: torch.Tensor,\n eps: float = 1e-4,\n grad_min: float = -1e4,\n grad_max: float = 1e4,\n retain_graph: bool = True):\n \"\"\"\n Args:\n inputs (B, N, d):\n outputs (B, N):\n\n Returns:\n\n \"\"\"\n assert inputs.ndim == 3 and outputs.ndim == 2, 'input shape expeted to be [B, N, d], and output to be [B, N]'\n d_points = torch.ones_like(outputs, requires_grad=False, device=outputs.device)\n points_grad = torch.autograd.grad(\n outputs=outputs,\n inputs=inputs,\n grad_outputs=d_points,\n create_graph=retain_graph,\n retain_graph=retain_graph,\n only_inputs=True)[0][:, :, -3:]\n\n points_grad = torch.clamp(points_grad, grad_min, grad_max)\n", "probing input new": "def compute_normals(inputs: torch.Tensor,\n outputs: torch.Tensor,\n eps: float = 1e-4,\n grad_min: float = -1e4,\n grad_max: float = 1e4,\n retain_graph: bool = True):\n \"\"\"\n Args:\n inputs (B, N, d):\n outputs (B, N):\n\n Returns:\n\n \"\"\"\n assert inputs.ndim == 3 and outputs.ndim == 2, 'input shape expeted to be [B, N, d], and output to be [B, N]'\n d_points = torch.ones_like(outputs, requires_grad=False, device=outputs.device)\n points_grad = torch.autograd.grad(\n outputs=outputs,\n inputs=inputs,\n grad_outputs=d_points,\n create_graph=retain_graph,\n retain_graph=retain_graph,\n only_inputs=True)[0][:, :, -3:]\n\n points_grad = torch.clamp(points_grad, grad_min, grad_max)\n ", "reference": "norm=torch.linalg.norm(points_grad,dim=-1).unsqueeze(-1).detach()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norm=torch.linalg.norm(points_grad,dim=-1).unsqueeze(-1).detach()", "y_neg": " points_grad_norm = torch.norm(points_grad, dim=-1, keepdim=True)", "retain": "def compute_normals(inputs: torch.Tensor,\n outputs: torch.Tensor,\n eps: float = 1e-4,\n grad_min: float = -1e4,\n grad_max: float = 1e4,\n retain_graph: bool = True):\n \"\"\"\n Args:\n inputs (B, N, d):\n outputs (B, N):\n\n Returns:\n\n \"\"\"\n assert inputs.ndim == 3 and outputs.ndim == 2, 'input shape expeted to be [B, N, d], and output to be [B, N]'\n d_points = torch.ones_like(outputs, requires_grad=False, device=outputs.device)\n points_grad = torch.autograd.grad(\n outputs=outputs,\n inputs=inputs,\n grad_outputs=d_points,\n create_graph=retain_graph,\n retain_graph=retain_graph,\n only_inputs=True)[0][:, :, -3:]\n\n points_grad = torch.clamp(points_grad, grad_min, grad_max)\n norm = torch.linalg.norm(points_grad, dim=-1).unsqueeze(-1).detach()\n point_normals = points_grad / (eps + norm)\n\n return point_normals" }, { "id": 7505, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def optimize(moduleList : list,learning_rate : float = 2 ** -7,signSGDfactor : float = 1):\n \"\"\"\n Interpolates between signSGD and infinity norm normalization.\n\n signSGDfactor - The interpolation factor for signSGD. 0 is pure infinity norm normalization, while 1 is pure signSGD.\n \"\"\"\n assert (0 <= signSGDfactor <= 1)\n assert (0 <= learning_rate)\n with torch.no_grad():\n for module in moduleList:\n infNorm = torch.scalar_tensor(0)\n paramGroup = [x for x in module.parameters() if x.grad is not None]\n for x in paramGroup: infNorm = torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))\n for x in paramGroup: # The scalars operations are grouped for efficiency.\n if torch.is_nonzero(infNorm):\n if 0 < signSGDfactor: x -= learning_rate * signSGDfactor * torch.sign(x.grad)\n if signSGDfactor < 1: x -= learning_rate * (1 - signSGDfactor) / infNorm * x.grad\n x.grad = None", "probing input": "def optimize(moduleList : list,learning_rate : float = 2 ** -7,signSGDfactor : float = 1):\n \"\"\"\n Interpolates between signSGD and infinity norm normalization.\n\n signSGDfactor - The interpolation factor for signSGD. 0 is pure infinity norm normalization, while 1 is pure signSGD.\n \"\"\"\n assert (0 <= signSGDfactor <= 1)\n assert (0 <= learning_rate)\n with torch.no_grad():\n for module in moduleList:\n infNorm = torch.scalar_tensor(0)\n paramGroup = [x for x in module.parameters() if x.grad is not None]\n", "probing input new": "def optimize(moduleList : list,learning_rate : float = 2 ** -7,signSGDfactor : float = 1):\n \"\"\"\n Interpolates between signSGD and infinity norm normalization.\n\n signSGDfactor - The interpolation factor for signSGD. 0 is pure infinity norm normalization, while 1 is pure signSGD.\n \"\"\"\n assert (0 <= signSGDfactor <= 1)\n assert (0 <= learning_rate)\n with torch.no_grad():\n for module in moduleList:\n infNorm = torch.scalar_tensor(0)\n paramGroup = [x for x in module.parameters() if x.grad is not None]\n for x in paramGroup: infNorm = torch.max(infNorm,torch.", "reference": "forxinparamGroup:infNorm=torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "forxinparamGroup:infNorm=torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))", "y_neg": " for x in paramGroup: infNorm = torch.max(infNorm,torch.norm(x.grad,p='fro'))", "retain": "def optimize(moduleList : list,learning_rate : float = 2 ** -7,signSGDfactor : float = 1):\n \"\"\"\n Interpolates between signSGD and infinity norm normalization.\n\n signSGDfactor - The interpolation factor for signSGD. 0 is pure infinity norm normalization, while 1 is pure signSGD.\n \"\"\"\n assert (0 <= signSGDfactor <= 1)\n assert (0 <= learning_rate)\n with torch.no_grad():\n for module in moduleList:\n infNorm = torch.scalar_tensor(0)\n paramGroup = [x for x in module.parameters() if x.grad is not None]\n for x in paramGroup: infNorm = torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))\n for x in paramGroup: # The scalars operations are grouped for efficiency.\n if torch.is_nonzero(infNorm):\n if 0 < signSGDfactor: x -= learning_rate * signSGDfactor * torch.sign(x.grad)\n if signSGDfactor < 1: x -= learning_rate * (1 - signSGDfactor) / infNorm * x.grad\n x.grad = None" }, { "id": 7506, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def main(self) -> None:\n \"\"\"Main function.\"\"\"\n torch.set_float32_matmul_precision(self.torch_precision)\n assert str(self.output_path)[-4:] == \".ply\"\n self.output_path.parent.mkdir(parents=True, exist_ok=True)\n\n _, pipeline, _ = eval_setup(self.load_config)\n\n CONSOLE.print(\"Extract mesh with marching cubes and may take a while\")\n\n if self.create_visibility_mask:\n assert self.resolution % 512 == 0\n\n coarse_mask = pipeline.get_visibility_mask(\n self.visibility_grid_resolution, self.valid_points_thres, self.sub_sample_factor\n )\n\n def inv_contract(x):\n mag = torch.linalg.norm(x, ord=pipeline.model.scene_contraction.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (1 / (2 - mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n return x_new\n\n if self.save_visibility_grid:\n offset = torch.linspace(-2.0, 2.0, 512)\n x, y, z = torch.meshgrid(offset, offset, offset, indexing=\"ij\")\n offset_cube = torch.stack([x, y, z], dim=-1).reshape(-1, 3).to(coarse_mask.device)\n points = offset_cube[coarse_mask.reshape(-1) > 0]\n points = inv_contract(points)\n save_points(\"mask.ply\", points.cpu().numpy())\n torch.save(coarse_mask, \"coarse_mask.pt\")\n\n get_surface_sliding_with_contraction(\n sdf=lambda x: (\n pipeline.model.field.forward_geonetwork(x)[:, 0] - self.marching_cube_threshold\n ).contiguous(),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n coarse_mask=coarse_mask,\n output_path=self.output_path,\n simplify_mesh=self.simplify_mesh,\n inv_contraction=inv_contract,\n )\n return\n\n if self.is_occupancy:\n # for unisurf\n get_surface_occupancy(\n occupancy_fn=lambda x: torch.sigmoid(\n 10 * pipeline.model.field.forward_geonetwork(x)[:, 0].contiguous()\n ),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n level=0.5,\n device=pipeline.model.device,\n output_path=self.output_path,\n )\n else:\n assert self.resolution % 512 == 0\n # for sdf we can multi-scale extraction.\n get_surface_sliding(\n sdf=lambda x: pipeline.model.field.forward_geonetwork(x)[:, 0].contiguous(),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n coarse_mask=pipeline.model.scene_box.coarse_binary_gird,\n output_path=self.output_path,\n simplify_mesh=self.simplify_mesh,\n )", "probing input": " def main(self) -> None:\n \"\"\"Main function.\"\"\"\n torch.set_float32_matmul_precision(self.torch_precision)\n assert str(self.output_path)[-4:] == \".ply\"\n self.output_path.parent.mkdir(parents=True, exist_ok=True)\n\n _, pipeline, _ = eval_setup(self.load_config)\n\n CONSOLE.print(\"Extract mesh with marching cubes and may take a while\")\n\n if self.create_visibility_mask:\n assert self.resolution % 512 == 0\n\n coarse_mask = pipeline.get_visibility_mask(\n self.visibility_grid_resolution, self.valid_points_thres, self.sub_sample_factor\n )\n\n def inv_contract(x):\n", "probing input new": " def main(self) -> None:\n \"\"\"Main function.\"\"\"\n torch.set_float32_matmul_precision(self.torch_precision)\n assert str(self.output_path)[-4:] == \".ply\"\n self.output_path.parent.mkdir(parents=True, exist_ok=True)\n\n _, pipeline, _ = eval_setup(self.load_config)\n\n CONSOLE.print(\"Extract mesh with marching cubes and may take a while\")\n\n if self.create_visibility_mask:\n assert self.resolution % 512 == 0\n\n coarse_mask = pipeline.get_visibility_mask(\n self.visibility_grid_resolution, self.valid_points_thres, self.sub_sample_factor\n )\n\n def inv_contract(x):\n mag = torch.", "reference": "mag=torch.linalg.norm(x,ord=pipeline.model.scene_contraction.order,dim=-1)", "reference dict": { "CONSOLE": "Console" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,ord=pipeline.model.scene_contraction.order,dim=-1)", "y_neg": " mag = torch.norm(x, p=2, dim=-1, keepdim=True)", "retain": " def main(self) -> None:\n \"\"\"Main function.\"\"\"\n torch.set_float32_matmul_precision(self.torch_precision)\n assert str(self.output_path)[-4:] == \".ply\"\n self.output_path.parent.mkdir(parents=True, exist_ok=True)\n\n _, pipeline, _ = eval_setup(self.load_config)\n\n CONSOLE.print(\"Extract mesh with marching cubes and may take a while\")\n\n if self.create_visibility_mask:\n assert self.resolution % 512 == 0\n\n coarse_mask = pipeline.get_visibility_mask(\n self.visibility_grid_resolution, self.valid_points_thres, self.sub_sample_factor\n )\n\n def inv_contract(x):\n mag = torch.linalg.norm(x, ord=pipeline.model.scene_contraction.order, dim=-1)\n mask = mag >= 1\n x_new = x.clone()\n x_new[mask] = (1 / (2 - mag[mask][..., None])) * (x[mask] / mag[mask][..., None])\n return x_new\n\n if self.save_visibility_grid:\n offset = torch.linspace(-2.0, 2.0, 512)\n x, y, z = torch.meshgrid(offset, offset, offset, indexing=\"ij\")\n offset_cube = torch.stack([x, y, z], dim=-1).reshape(-1, 3).to(coarse_mask.device)\n points = offset_cube[coarse_mask.reshape(-1) > 0]\n points = inv_contract(points)\n save_points(\"mask.ply\", points.cpu().numpy())\n torch.save(coarse_mask, \"coarse_mask.pt\")\n\n get_surface_sliding_with_contraction(\n sdf=lambda x: (\n pipeline.model.field.forward_geonetwork(x)[:, 0] - self.marching_cube_threshold\n ).contiguous(),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n coarse_mask=coarse_mask,\n output_path=self.output_path,\n simplify_mesh=self.simplify_mesh,\n inv_contraction=inv_contract,\n )\n return\n\n if self.is_occupancy:\n # for unisurf\n get_surface_occupancy(\n occupancy_fn=lambda x: torch.sigmoid(\n 10 * pipeline.model.field.forward_geonetwork(x)[:, 0].contiguous()\n ),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n level=0.5,\n device=pipeline.model.device,\n output_path=self.output_path,\n )\n else:\n assert self.resolution % 512 == 0\n # for sdf we can multi-scale extraction.\n get_surface_sliding(\n sdf=lambda x: pipeline.model.field.forward_geonetwork(x)[:, 0].contiguous(),\n resolution=self.resolution,\n bounding_box_min=self.bounding_box_min,\n bounding_box_max=self.bounding_box_max,\n coarse_mask=pipeline.model.scene_box.coarse_binary_gird,\n output_path=self.output_path,\n simplify_mesh=self.simplify_mesh,\n )" }, { "id": 7509, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _compute_local_normal_vector(self, end_corner, start_corner):\n conect_vector = end_corner - start_corner\n side_length = torch.linalg.norm(conect_vector, dim=0)\n normal = torch.index_select(conect_vector, 0, torch.LongTensor([1, 0]))\n normal /= side_length\n normal[1] *= -1\n return normal", "probing input": " def _compute_local_normal_vector(self, end_corner, start_corner):\n conect_vector = end_corner - start_corner\n", "probing input new": " def _compute_local_normal_vector(self, end_corner, start_corner):\n conect_vector = end_corner - start_corner\n side_length = torch.", "reference": "side_length=torch.linalg.norm(conect_vector,dim=0)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "side_length=torch.linalg.norm(conect_vector,dim=0)", "y_neg": " side_length = torch.norm(conect_vector)", "retain": " def _compute_local_normal_vector(self, end_corner, start_corner):\n conect_vector = end_corner - start_corner\n side_length = torch.linalg.norm(conect_vector, dim=0)\n normal = torch.index_select(conect_vector, 0, torch.LongTensor([1, 0]))\n normal /= side_length\n normal[1] *= -1\n return normal" }, { "id": 7512, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _project_constr(\n cls, v: torch.Tensor, constr: ConstraintDict, ric: RIC\n ) -> torch.Tensor:\n \"\"\"Attempts to project the constrained primitive internal coordinates onto the\n non-redundant basis.\n\n Notes:\n This uses the 'old' method used in geomeTRIC, which is a bit more\n battle tested than the more 'correct new' method.\n \"\"\"\n\n n_v = v.shape[1]\n\n constr_to_ic_idx = _match_constr(constr, ric.idxs)\n\n v_constr = v[constr_to_ic_idx, :]\n v_constr = v_constr / torch.linalg.norm(v_constr, dim=-1, keepdim=True)\n\n v_proj = v @ v_constr.T\n v_proj = v_proj / torch.linalg.norm(v_proj, dim=0, keepdim=True)\n\n v = torch.hstack((v_proj, v))\n\n threshold = 1e-6\n\n while True:\n u = []\n for i in range(v.shape[1]):\n v_i = v[:, i].flatten()\n u.append(v_i.clone())\n\n for u_i in u[:-1]:\n u[-1] = u[-1] - u_i * torch.dot(u_i, v_i)\n\n if torch.linalg.norm(u[-1]) < threshold:\n u = u[:-1]\n continue\n\n u[-1] = u[-1] / torch.linalg.norm(u[-1])\n\n if len(u) > n_v:\n threshold *= 10.0\n elif len(u) == n_v:\n break\n elif len(u) < n_v:\n raise RuntimeError(\"Gram-Schmidt orthogonalization failed\")\n\n return torch.vstack(u).T", "probing input": " def _project_constr(\n cls, v: torch.Tensor, constr: ConstraintDict, ric: RIC\n ) -> torch.Tensor:\n \"\"\"Attempts to project the constrained primitive internal coordinates onto the\n non-redundant basis.\n\n Notes:\n This uses the 'old' method used in geomeTRIC, which is a bit more\n battle tested than the more 'correct new' method.\n \"\"\"\n\n n_v = v.shape[1]\n\n constr_to_ic_idx = _match_constr(constr, ric.idxs)\n\n v_constr = v[constr_to_ic_idx, :]\n", "probing input new": " def _project_constr(\n cls, v: torch.Tensor, constr: ConstraintDict, ric: RIC\n ) -> torch.Tensor:\n \"\"\"Attempts to project the constrained primitive internal coordinates onto the\n non-redundant basis.\n\n Notes:\n This uses the 'old' method used in geomeTRIC, which is a bit more\n battle tested than the more 'correct new' method.\n \"\"\"\n\n n_v = v.shape[1]\n\n constr_to_ic_idx = _match_constr(constr, ric.idxs)\n\n v_constr = v[constr_to_ic_idx, :]\n v_constr = v_constr / torch.", "reference": "v_constr=v_constr/torch.linalg.norm(v_constr,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "v_constr=v_constr/torch.linalg.norm(v_constr,dim=-1,keepdim=True)", "y_neg": " v_constr = v_constr / torch.norm(v_constr, p='fro', dim=1, keepdim=True)", "retain": " def _project_constr(\n cls, v: torch.Tensor, constr: ConstraintDict, ric: RIC\n ) -> torch.Tensor:\n \"\"\"Attempts to project the constrained primitive internal coordinates onto the\n non-redundant basis.\n\n Notes:\n This uses the 'old' method used in geomeTRIC, which is a bit more\n battle tested than the more 'correct new' method.\n \"\"\"\n\n n_v = v.shape[1]\n\n constr_to_ic_idx = _match_constr(constr, ric.idxs)\n\n v_constr = v[constr_to_ic_idx, :]\n v_constr = v_constr / torch.linalg.norm(v_constr, dim=-1, keepdim=True)\n\n v_proj = v @ v_constr.T\n v_proj = v_proj / torch.linalg.norm(v_proj, dim=0, keepdim=True)\n\n v = torch.hstack((v_proj, v))\n\n threshold = 1e-6\n\n while True:\n u = []\n for i in range(v.shape[1]):\n v_i = v[:, i].flatten()\n u.append(v_i.clone())\n\n for u_i in u[:-1]:\n u[-1] = u[-1] - u_i * torch.dot(u_i, v_i)\n\n if torch.linalg.norm(u[-1]) < threshold:\n u = u[:-1]\n continue\n\n u[-1] = u[-1] / torch.linalg.norm(u[-1])\n\n if len(u) > n_v:\n threshold *= 10.0\n elif len(u) == n_v:\n break\n elif len(u) < n_v:\n raise RuntimeError(\"Gram-Schmidt orthogonalization failed\")\n\n return torch.vstack(u).T" }, { "id": 7514, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _apply_constraints(\n self, coords_x: torch.Tensor, tol: float = 1e-6\n ) -> tuple[torch.Tensor, torch.Tensor, bool]:\n \"\"\"Attempt to take steps in ICs to enforce any internal coordinate constraints.\n\n Args:\n coords_x: The coordinates with shape=(n_atoms, 3).\n tol: The tolerance for the constraint satisfaction.\n\n Returns:\n The modified coordinates and internal coordinates, and a boolean indicating\n whether the conversion of cartesian to internal coordinates was successful.\n \"\"\"\n iteration = 0\n\n constr_to_ic_idx = _match_constr(self.constr, self.idxs)\n\n dq_norm = 0.0\n dq_norm_best, soln_best = None, None\n\n while True:\n dq = smee.utils.zeros_like(self.v.shape[-1], self.v)\n\n # because of how we construct v, the first n_v columns should be the\n # projected constrained DoF\n constr_delta = -self.compute_constr_delta(coords_x)\n\n dq[: len(constr_delta)] = constr_delta\n dq[: len(constr_delta)] /= self.v[\n constr_to_ic_idx, list(range(len(constr_delta)))\n ]\n\n dq_norm_prev = dq_norm\n dq_norm = torch.linalg.norm(dq)\n\n soln = self.dq_to_x(coords_x, dq, enforce_constr=False)\n coords_x = soln[0]\n\n if dq_norm_best is None or dq_norm < dq_norm_best:\n dq_norm_best, soln_best = dq_norm, soln\n\n if dq_norm < tol:\n return soln\n\n if iteration > 0 and dq_norm > dq_norm_prev:\n _LOGGER.warning(\"constraint satisfaction failed to converge\")\n return soln_best\n\n iteration += 1", "probing input": " def _apply_constraints(\n self, coords_x: torch.Tensor, tol: float = 1e-6\n ) -> tuple[torch.Tensor, torch.Tensor, bool]:\n \"\"\"Attempt to take steps in ICs to enforce any internal coordinate constraints.\n\n Args:\n coords_x: The coordinates with shape=(n_atoms, 3).\n tol: The tolerance for the constraint satisfaction.\n\n Returns:\n The modified coordinates and internal coordinates, and a boolean indicating\n whether the conversion of cartesian to internal coordinates was successful.\n \"\"\"\n iteration = 0\n\n constr_to_ic_idx = _match_constr(self.constr, self.idxs)\n\n dq_norm = 0.0\n dq_norm_best, soln_best = None, None\n\n while True:\n dq = smee.utils.zeros_like(self.v.shape[-1], self.v)\n\n # because of how we construct v, the first n_v columns should be the\n # projected constrained DoF\n constr_delta = -self.compute_constr_delta(coords_x)\n\n dq[: len(constr_delta)] = constr_delta\n dq[: len(constr_delta)] /= self.v[\n constr_to_ic_idx, list(range(len(constr_delta)))\n ]\n\n dq_norm_prev = dq_norm\n", "probing input new": " def _apply_constraints(\n self, coords_x: torch.Tensor, tol: float = 1e-6\n ) -> tuple[torch.Tensor, torch.Tensor, bool]:\n \"\"\"Attempt to take steps in ICs to enforce any internal coordinate constraints.\n\n Args:\n coords_x: The coordinates with shape=(n_atoms, 3).\n tol: The tolerance for the constraint satisfaction.\n\n Returns:\n The modified coordinates and internal coordinates, and a boolean indicating\n whether the conversion of cartesian to internal coordinates was successful.\n \"\"\"\n iteration = 0\n\n constr_to_ic_idx = _match_constr(self.constr, self.idxs)\n\n dq_norm = 0.0\n dq_norm_best, soln_best = None, None\n\n while True:\n dq = smee.utils.zeros_like(self.v.shape[-1], self.v)\n\n # because of how we construct v, the first n_v columns should be the\n # projected constrained DoF\n constr_delta = -self.compute_constr_delta(coords_x)\n\n dq[: len(constr_delta)] = constr_delta\n dq[: len(constr_delta)] /= self.v[\n constr_to_ic_idx, list(range(len(constr_delta)))\n ]\n\n dq_norm_prev = dq_norm\n dq_", "reference": "dq_norm=torch.linalg.norm(dq)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dq_norm=torch.linalg.norm(dq)", "y_neg": " dq_norm = torch.norm(dq)", "retain": " def _apply_constraints(\n self, coords_x: torch.Tensor, tol: float = 1e-6\n ) -> tuple[torch.Tensor, torch.Tensor, bool]:\n \"\"\"Attempt to take steps in ICs to enforce any internal coordinate constraints.\n\n Args:\n coords_x: The coordinates with shape=(n_atoms, 3).\n tol: The tolerance for the constraint satisfaction.\n\n Returns:\n The modified coordinates and internal coordinates, and a boolean indicating\n whether the conversion of cartesian to internal coordinates was successful.\n \"\"\"\n iteration = 0\n\n constr_to_ic_idx = _match_constr(self.constr, self.idxs)\n\n dq_norm = 0.0\n dq_norm_best, soln_best = None, None\n\n while True:\n dq = smee.utils.zeros_like(self.v.shape[-1], self.v)\n\n # because of how we construct v, the first n_v columns should be the\n # projected constrained DoF\n constr_delta = -self.compute_constr_delta(coords_x)\n\n dq[: len(constr_delta)] = constr_delta\n dq[: len(constr_delta)] /= self.v[\n constr_to_ic_idx, list(range(len(constr_delta)))\n ]\n\n dq_norm_prev = dq_norm\n dq_norm = torch.linalg.norm(dq)\n\n soln = self.dq_to_x(coords_x, dq, enforce_constr=False)\n coords_x = soln[0]\n\n if dq_norm_best is None or dq_norm < dq_norm_best:\n dq_norm_best, soln_best = dq_norm, soln\n\n if dq_norm < tol:\n return soln\n\n if iteration > 0 and dq_norm > dq_norm_prev:\n _LOGGER.warning(\"constraint satisfaction failed to converge\")\n return soln_best\n\n iteration += 1" }, { "id": 7522, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_rays, 3\n rays_v = torch.matmul(c2w[None, :3, :3], rays_v[:, :, None]).squeeze() # N_rays, 3\n rays_o = c2w[None, :3, 3].expand(rays_v.shape) # N_rays, 3\n\n image = image.permute(1, 2, 0)\n color = image.view(-1, 3)\n depth = depth.view(-1, 1) if depth is not None else None\n mask = mask.view(-1, 1) if mask is not None else torch.ones([H * W, 1]).to(device)\n sample = {\n 'rays_o': rays_o,\n 'rays_v': rays_v,\n 'rays_ndc_uv': rays_ndc_uv,\n 'rays_color': color,\n # 'rays_depth': depth,\n 'rays_mask': mask,\n 'rays_norm_XYZ_cam': p # - XYZ_cam, before multiply depth\n }\n if depth is not None:\n sample['rays_depth'] = depth\n\n return sample", "probing input": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n", "probing input new": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # N_rays, 3", "retain": "def gen_rays_from_single_image(H, W, image, intrinsic, c2w, depth=None, mask=None):\n \"\"\"\n generate rays in world space, for image image\n :param H:\n :param W:\n :param intrinsics: [3,3]\n :param c2ws: [4,4]\n :return:\n \"\"\"\n device = image.device\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W)) # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n # normalized ndc uv coordinates, (-1, 1)\n ndc_u = 2 * xs / (W - 1) - 1\n ndc_v = 2 * ys / (H - 1) - 1\n rays_ndc_uv = torch.stack([ndc_u, ndc_v], dim=-1).view(-1, 2).float().to(device)\n\n intrinsic_inv = torch.inverse(intrinsic)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # N_rays, 3\n rays_v = torch.matmul(c2w[None, :3, :3], rays_v[:, :, None]).squeeze() # N_rays, 3\n rays_o = c2w[None, :3, 3].expand(rays_v.shape) # N_rays, 3\n\n image = image.permute(1, 2, 0)\n color = image.view(-1, 3)\n depth = depth.view(-1, 1) if depth is not None else None\n mask = mask.view(-1, 1) if mask is not None else torch.ones([H * W, 1]).to(device)\n sample = {\n 'rays_o': rays_o,\n 'rays_v': rays_v,\n 'rays_ndc_uv': rays_ndc_uv,\n 'rays_color': color,\n # 'rays_depth': depth,\n 'rays_mask': mask,\n 'rays_norm_XYZ_cam': p # - XYZ_cam, before multiply depth\n }\n if depth is not None:\n sample['rays_depth'] = depth\n\n return sample" }, { "id": 7524, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_project_gaussians_forward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n H, W = 512, 512\n cx, cy = W / 2, H / 2\n # 90 degree FOV\n fx, fy = W / 2, W / 2\n clip_thresh = 0.01\n viewmat = torch.tensor(\n [\n [1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 8.0],\n [0.0, 0.0, 0.0, 1.0],\n ],\n device=device,\n )\n viewmat[:3, :3] = _torch_impl.quat_to_rotmat(torch.randn(4))\n BLOCK_SIZE = 16\n\n (\n xys,\n depths,\n radii,\n conics,\n compensation,\n num_tiles_hit,\n cov3d,\n ) = project_gaussians(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n fx,\n fy,\n cx,\n cy,\n H,\n W,\n BLOCK_SIZE,\n clip_thresh,\n )\n masks = num_tiles_hit > 0\n\n with torch.no_grad():\n (\n _cov3d,\n _,\n _xys,\n _depths,\n _radii,\n _conics,\n _compensation,\n _num_tiles_hit,\n _masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, cx, cy),\n (W, H),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n check_close(masks, _masks, atol=1e-5, rtol=1e-5)\n check_close(cov3d, _cov3d)\n check_close(xys, _xys)\n check_close(depths, _depths)\n check_close(radii, _radii)\n check_close(conics, _conics)\n check_close(compensation, _compensation)\n check_close(num_tiles_hit, _num_tiles_hit)\n print(\"passed project_gaussians_forward test\")", "probing input": "def test_project_gaussians_forward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n", "probing input new": "def test_project_gaussians_forward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.", "reference": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats /= torch.norm(quats, dim=1, keepdim=True)", "retain": "def test_project_gaussians_forward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n H, W = 512, 512\n cx, cy = W / 2, H / 2\n # 90 degree FOV\n fx, fy = W / 2, W / 2\n clip_thresh = 0.01\n viewmat = torch.tensor(\n [\n [1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 8.0],\n [0.0, 0.0, 0.0, 1.0],\n ],\n device=device,\n )\n viewmat[:3, :3] = _torch_impl.quat_to_rotmat(torch.randn(4))\n BLOCK_SIZE = 16\n\n (\n xys,\n depths,\n radii,\n conics,\n compensation,\n num_tiles_hit,\n cov3d,\n ) = project_gaussians(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n fx,\n fy,\n cx,\n cy,\n H,\n W,\n BLOCK_SIZE,\n clip_thresh,\n )\n masks = num_tiles_hit > 0\n\n with torch.no_grad():\n (\n _cov3d,\n _,\n _xys,\n _depths,\n _radii,\n _conics,\n _compensation,\n _num_tiles_hit,\n _masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, cx, cy),\n (W, H),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n check_close(masks, _masks, atol=1e-5, rtol=1e-5)\n check_close(cov3d, _cov3d)\n check_close(xys, _xys)\n check_close(depths, _depths)\n check_close(radii, _radii)\n check_close(conics, _conics)\n check_close(compensation, _compensation)\n check_close(num_tiles_hit, _num_tiles_hit)\n print(\"passed project_gaussians_forward test\")" }, { "id": 7525, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_project_gaussians_backward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n H, W = 512, 512\n cx, cy = W / 2, H / 2\n # 90 degree FOV\n fx, fy = W / 2, W / 2\n clip_thresh = 0.01\n viewmat = torch.tensor(\n [\n [1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 8.0],\n [0.0, 0.0, 0.0, 1.0],\n ],\n device=device,\n )\n viewmat[:3, :3] = _torch_impl.quat_to_rotmat(torch.randn(4))\n\n BLOCK_SIZE = 16\n\n (\n cov3d,\n cov2d,\n xys,\n depths,\n radii,\n conics,\n compensation,\n _,\n masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, cx, cy),\n (W, H),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n # Test backward pass\n\n v_xys = torch.randn_like(xys)\n v_depths = torch.randn_like(depths)\n v_conics = torch.randn_like(conics)\n # compensation gradients\n v_compensation = torch.randn_like(compensation)\n v_cov2d, v_cov3d, v_mean3d, v_scale, v_quat = _C.project_gaussians_backward(\n num_points,\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n fx,\n fy,\n cx,\n cy,\n H,\n W,\n cov3d,\n radii,\n conics,\n compensation,\n v_xys,\n v_depths,\n v_conics,\n v_compensation,\n )\n\n def scale_rot_to_cov3d_partial(scale, quat):\n \"\"\"\n scale (*, 3), quat (*, 3) -> cov3d (upper tri) (*, 6)\n \"\"\"\n cov3d = _torch_impl.scale_rot_to_cov3d(scale, glob_scale, quat)\n i, j = torch.triu_indices(3, 3)\n cov3d_triu = cov3d[..., i, j]\n return cov3d_triu\n\n def project_cov3d_ewa_partial(mean3d, cov3d):\n \"\"\"\n mean3d (*, 3), cov3d (upper tri) (*, 6) -> cov2d (upper tri) (*, 3)\n \"\"\"\n tan_fovx = 0.5 * W / fx\n tan_fovy = 0.5 * H / fy\n\n cov3d_mat = torch.zeros(*cov3d.shape[:-1], 3, 3, device=device)\n i, j = torch.triu_indices(3, 3)\n cov3d_mat[..., i, j] = cov3d\n cov3d_mat[..., [1, 2, 2], [0, 0, 1]] = cov3d[..., [1, 2, 4]]\n cov2d, _ = _torch_impl.project_cov3d_ewa(\n mean3d, cov3d_mat, viewmat, fx, fy, tan_fovx, tan_fovy\n )\n ii, jj = torch.triu_indices(2, 2)\n return cov2d[..., ii, jj]\n\n def compute_cov2d_bounds_partial(cov2d):\n \"\"\"\n cov2d (upper tri) (*, 3) -> conic (upper tri) (*, 3)\n \"\"\"\n cov2d_mat = torch.zeros(*cov2d.shape[:-1], 2, 2, device=device)\n i, j = torch.triu_indices(2, 2)\n cov2d_mat[..., i, j] = cov2d\n cov2d_mat[..., 1, 0] = cov2d[..., 1]\n conic, _, _ = _torch_impl.compute_cov2d_bounds(cov2d_mat)\n return conic\n\n def compute_compensation_partial(cov2d):\n \"\"\"\n cov2d (upper tri) (*, 3) -> compensation (*, 1)\n \"\"\"\n cov2d_mat = torch.zeros(*cov2d.shape[:-1], 2, 2, device=device)\n i, j = torch.triu_indices(2, 2)\n cov2d_mat[..., i, j] = cov2d\n cov2d_mat[..., 1, 0] = cov2d[..., 1]\n return _torch_impl.compute_compensation(cov2d_mat)\n\n def project_pix_partial(mean3d):\n \"\"\"\n mean3d (*, 3) -> xy (*, 2)\n \"\"\"\n p_view, _ = _torch_impl.clip_near_plane(mean3d, viewmat, clip_thresh)\n return _torch_impl.project_pix((fx, fy), p_view, (cx, cy))\n\n def compute_depth_partial(mean3d):\n \"\"\"\n mean3d (*, 3) -> depth (*)\n \"\"\"\n p_view, _ = _torch_impl.clip_near_plane(mean3d, viewmat, clip_thresh)\n depth = p_view[..., 2]\n return depth\n\n _, vjp_scale_rot_to_cov3d = vjp(scale_rot_to_cov3d_partial, scales, quats) # type: ignore\n _, vjp_project_cov3d_ewa = vjp(project_cov3d_ewa_partial, means3d, cov3d) # type: ignore\n _, vjp_compute_cov2d_bounds = vjp(compute_cov2d_bounds_partial, cov2d) # type: ignore\n _, vjp_compute_compensation = vjp(compute_compensation_partial, cov2d) # type: ignore\n _, vjp_project_pix = vjp(project_pix_partial, means3d) # type: ignore\n _, vjp_compute_depth = vjp(compute_depth_partial, means3d) # type: ignore\n\n _v_cov2d = vjp_compute_cov2d_bounds(v_conics)[0]\n _v_cov2d = _v_cov2d + vjp_compute_compensation(v_compensation)[0]\n _v_mean3d_cov2d, _v_cov3d = vjp_project_cov3d_ewa(_v_cov2d)\n _v_mean3d_xy = vjp_project_pix(v_xys)[0]\n _v_mean3d_depth = vjp_compute_depth(v_depths)[0]\n _v_mean3d = _v_mean3d_cov2d + _v_mean3d_xy + _v_mean3d_depth\n _v_scale, _v_quat = vjp_scale_rot_to_cov3d(_v_cov3d)\n\n atol = 5e-4\n rtol = 1e-5\n check_close(v_cov2d, _v_cov2d, atol=atol, rtol=rtol)\n check_close(v_cov3d, _v_cov3d, atol=atol, rtol=rtol)\n check_close(v_mean3d[:, :], _v_mean3d[:, :], atol=atol, rtol=rtol)\n check_close(v_scale, _v_scale, atol=atol, rtol=rtol)\n check_close(v_quat, _v_quat, atol=atol, rtol=rtol)\n print(\"passed project_gaussians_backward test\")", "probing input": "def test_project_gaussians_backward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n", "probing input new": "def test_project_gaussians_backward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.", "reference": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats/=torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats /= torch.norm(quats, dim=1, keepdim=True)", "retain": "def test_project_gaussians_backward():\n num_points = 100\n\n means3d = torch.randn((num_points, 3), device=device, requires_grad=True)\n scales = torch.rand((num_points, 3), device=device) + 0.2\n glob_scale = 0.1\n quats = torch.randn((num_points, 4), device=device)\n quats /= torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n H, W = 512, 512\n cx, cy = W / 2, H / 2\n # 90 degree FOV\n fx, fy = W / 2, W / 2\n clip_thresh = 0.01\n viewmat = torch.tensor(\n [\n [1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 8.0],\n [0.0, 0.0, 0.0, 1.0],\n ],\n device=device,\n )\n viewmat[:3, :3] = _torch_impl.quat_to_rotmat(torch.randn(4))\n\n BLOCK_SIZE = 16\n\n (\n cov3d,\n cov2d,\n xys,\n depths,\n radii,\n conics,\n compensation,\n _,\n masks,\n ) = _torch_impl.project_gaussians_forward(\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n (fx, fy, cx, cy),\n (W, H),\n BLOCK_SIZE,\n clip_thresh,\n )\n\n # Test backward pass\n\n v_xys = torch.randn_like(xys)\n v_depths = torch.randn_like(depths)\n v_conics = torch.randn_like(conics)\n # compensation gradients\n v_compensation = torch.randn_like(compensation)\n v_cov2d, v_cov3d, v_mean3d, v_scale, v_quat = _C.project_gaussians_backward(\n num_points,\n means3d,\n scales,\n glob_scale,\n quats,\n viewmat,\n fx,\n fy,\n cx,\n cy,\n H,\n W,\n cov3d,\n radii,\n conics,\n compensation,\n v_xys,\n v_depths,\n v_conics,\n v_compensation,\n )\n\n def scale_rot_to_cov3d_partial(scale, quat):\n \"\"\"\n scale (*, 3), quat (*, 3) -> cov3d (upper tri) (*, 6)\n \"\"\"\n cov3d = _torch_impl.scale_rot_to_cov3d(scale, glob_scale, quat)\n i, j = torch.triu_indices(3, 3)\n cov3d_triu = cov3d[..., i, j]\n return cov3d_triu\n\n def project_cov3d_ewa_partial(mean3d, cov3d):\n \"\"\"\n mean3d (*, 3), cov3d (upper tri) (*, 6) -> cov2d (upper tri) (*, 3)\n \"\"\"\n tan_fovx = 0.5 * W / fx\n tan_fovy = 0.5 * H / fy\n\n cov3d_mat = torch.zeros(*cov3d.shape[:-1], 3, 3, device=device)\n i, j = torch.triu_indices(3, 3)\n cov3d_mat[..., i, j] = cov3d\n cov3d_mat[..., [1, 2, 2], [0, 0, 1]] = cov3d[..., [1, 2, 4]]\n cov2d, _ = _torch_impl.project_cov3d_ewa(\n mean3d, cov3d_mat, viewmat, fx, fy, tan_fovx, tan_fovy\n )\n ii, jj = torch.triu_indices(2, 2)\n return cov2d[..., ii, jj]\n\n def compute_cov2d_bounds_partial(cov2d):\n \"\"\"\n cov2d (upper tri) (*, 3) -> conic (upper tri) (*, 3)\n \"\"\"\n cov2d_mat = torch.zeros(*cov2d.shape[:-1], 2, 2, device=device)\n i, j = torch.triu_indices(2, 2)\n cov2d_mat[..., i, j] = cov2d\n cov2d_mat[..., 1, 0] = cov2d[..., 1]\n conic, _, _ = _torch_impl.compute_cov2d_bounds(cov2d_mat)\n return conic\n\n def compute_compensation_partial(cov2d):\n \"\"\"\n cov2d (upper tri) (*, 3) -> compensation (*, 1)\n \"\"\"\n cov2d_mat = torch.zeros(*cov2d.shape[:-1], 2, 2, device=device)\n i, j = torch.triu_indices(2, 2)\n cov2d_mat[..., i, j] = cov2d\n cov2d_mat[..., 1, 0] = cov2d[..., 1]\n return _torch_impl.compute_compensation(cov2d_mat)\n\n def project_pix_partial(mean3d):\n \"\"\"\n mean3d (*, 3) -> xy (*, 2)\n \"\"\"\n p_view, _ = _torch_impl.clip_near_plane(mean3d, viewmat, clip_thresh)\n return _torch_impl.project_pix((fx, fy), p_view, (cx, cy))\n\n def compute_depth_partial(mean3d):\n \"\"\"\n mean3d (*, 3) -> depth (*)\n \"\"\"\n p_view, _ = _torch_impl.clip_near_plane(mean3d, viewmat, clip_thresh)\n depth = p_view[..., 2]\n return depth\n\n _, vjp_scale_rot_to_cov3d = vjp(scale_rot_to_cov3d_partial, scales, quats) # type: ignore\n _, vjp_project_cov3d_ewa = vjp(project_cov3d_ewa_partial, means3d, cov3d) # type: ignore\n _, vjp_compute_cov2d_bounds = vjp(compute_cov2d_bounds_partial, cov2d) # type: ignore\n _, vjp_compute_compensation = vjp(compute_compensation_partial, cov2d) # type: ignore\n _, vjp_project_pix = vjp(project_pix_partial, means3d) # type: ignore\n _, vjp_compute_depth = vjp(compute_depth_partial, means3d) # type: ignore\n\n _v_cov2d = vjp_compute_cov2d_bounds(v_conics)[0]\n _v_cov2d = _v_cov2d + vjp_compute_compensation(v_compensation)[0]\n _v_mean3d_cov2d, _v_cov3d = vjp_project_cov3d_ewa(_v_cov2d)\n _v_mean3d_xy = vjp_project_pix(v_xys)[0]\n _v_mean3d_depth = vjp_compute_depth(v_depths)[0]\n _v_mean3d = _v_mean3d_cov2d + _v_mean3d_xy + _v_mean3d_depth\n _v_scale, _v_quat = vjp_scale_rot_to_cov3d(_v_cov3d)\n\n atol = 5e-4\n rtol = 1e-5\n check_close(v_cov2d, _v_cov2d, atol=atol, rtol=rtol)\n check_close(v_cov3d, _v_cov3d, atol=atol, rtol=rtol)\n check_close(v_mean3d[:, :], _v_mean3d[:, :], atol=atol, rtol=rtol)\n check_close(v_scale, _v_scale, atol=atol, rtol=rtol)\n check_close(v_quat, _v_quat, atol=atol, rtol=rtol)\n print(\"passed project_gaussians_backward test\")" }, { "id": 7526, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def evaluate_true(self, X: Tensor) -> Tensor:\n a, b, c = self.a, self.b, self.c\n part1 = -a * torch.exp(-b / math.sqrt(self.dim) * torch.linalg.norm(X, dim=-1))\n part2 = -(torch.exp(torch.mean(torch.cos(c * X), dim=-1)))\n return part1 + part2 + a + math.e", "probing input": " def evaluate_true(self, X: Tensor) -> Tensor:\n a, b, c = self.a, self.b, self.c\n", "probing input new": " def evaluate_true(self, X: Tensor) -> Tensor:\n a, b, c = self.a, self.b, self.c\n part1 = -a * torch.exp(-b / math.sqrt(self.dim) * torch.", "reference": "part1=-a*torch.exp(-b/math.sqrt(self.dim)*torch.linalg.norm(X,dim=-1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "part1=-a*torch.exp(-b/math.sqrt(self.dim)*torch.linalg.norm(X,dim=-1))", "y_neg": " part1 = -a * torch.exp(-b / math.sqrt(self.dim) * torch.norm(X, 2, 1))", "retain": " def evaluate_true(self, X: Tensor) -> Tensor:\n a, b, c = self.a, self.b, self.c\n part1 = -a * torch.exp(-b / math.sqrt(self.dim) * torch.linalg.norm(X, dim=-1))\n part2 = -(torch.exp(torch.mean(torch.cos(c * X), dim=-1)))\n return part1 + part2 + a + math.e" }, { "id": 7529, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(x):\n return x / torch.linalg.norm(x, dim=-2, keepdim=True)", "probing input": "def normalize(x):\n", "probing input new": "def normalize(x):\n return x / torch.", "reference": "returnx/torch.linalg.norm(x,dim=-2,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnx/torch.linalg.norm(x,dim=-2,keepdim=True)", "y_neg": " return x / torch.norm(x, p=2, dim=1, keepdim=True)", "retain": "def normalize(x):\n return x / torch.linalg.norm(x, dim=-2, keepdim=True)" }, { "id": 7531, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_compute_linear_truncated_kernel_no_batch(self):\n x1 = torch.tensor([[1, 0.1, 0.2], [2, 0.3, 0.4]])\n x2 = torch.tensor([[3, 0.5, 0.6], [4, 0.7, 0.8]])\n t_1 = torch.tensor([[0.3584, 0.1856], [0.2976, 0.1584]])\n for nu, fidelity_dims in itertools.product({0.5, 1.5, 2.5}, ([2], [1, 2])):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=fidelity_dims, dimension=3, nu=nu\n )\n kernel.power = 1\n n_fid = len(fidelity_dims)\n if n_fid > 1:\n active_dimsM = [0]\n t_2 = torch.tensor([[0.4725, 0.2889], [0.4025, 0.2541]])\n t_3 = torch.tensor([[0.1685, 0.0531], [0.1168, 0.0386]])\n t = 1 + t_1 + t_2 + t_3\n else:\n active_dimsM = [0, 1]\n t = 1 + t_1\n\n matern_ker = MaternKernel(nu=nu, active_dims=active_dimsM)\n matern_term = matern_ker(x1, x2).to_dense()\n actual = t * matern_term\n res = kernel(x1, x2).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-4)\n # test diagonal mode\n res_diag = kernel(x1, x2, diag=True)\n self.assertLess(torch.linalg.norm(res_diag - actual.diag()), 1e-4)\n # make sure that we error out if last_dim_is_batch=True\n with self.assertRaises(NotImplementedError):\n kernel(x1, x2, diag=True, last_dim_is_batch=True)", "probing input": " def test_compute_linear_truncated_kernel_no_batch(self):\n x1 = torch.tensor([[1, 0.1, 0.2], [2, 0.3, 0.4]])\n x2 = torch.tensor([[3, 0.5, 0.6], [4, 0.7, 0.8]])\n t_1 = torch.tensor([[0.3584, 0.1856], [0.2976, 0.1584]])\n for nu, fidelity_dims in itertools.product({0.5, 1.5, 2.5}, ([2], [1, 2])):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=fidelity_dims, dimension=3, nu=nu\n )\n kernel.power = 1\n n_fid = len(fidelity_dims)\n if n_fid > 1:\n active_dimsM = [0]\n t_2 = torch.tensor([[0.4725, 0.2889], [0.4025, 0.2541]])\n t_3 = torch.tensor([[0.1685, 0.0531], [0.1168, 0.0386]])\n t = 1 + t_1 + t_2 + t_3\n else:\n active_dimsM = [0, 1]\n t = 1 + t_1\n\n matern_ker = MaternKernel(nu=nu, active_dims=active_dimsM)\n matern_term = matern_ker(x1, x2).to_dense()\n actual = t * matern_term\n res = kernel(x1, x2).to_dense()\n", "probing input new": " def test_compute_linear_truncated_kernel_no_batch(self):\n x1 = torch.tensor([[1, 0.1, 0.2], [2, 0.3, 0.4]])\n x2 = torch.tensor([[3, 0.5, 0.6], [4, 0.7, 0.8]])\n t_1 = torch.tensor([[0.3584, 0.1856], [0.2976, 0.1584]])\n for nu, fidelity_dims in itertools.product({0.5, 1.5, 2.5}, ([2], [1, 2])):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=fidelity_dims, dimension=3, nu=nu\n )\n kernel.power = 1\n n_fid = len(fidelity_dims)\n if n_fid > 1:\n active_dimsM = [0]\n t_2 = torch.tensor([[0.4725, 0.2889], [0.4025, 0.2541]])\n t_3 = torch.tensor([[0.1685, 0.0531], [0.1168, 0.0386]])\n t = 1 + t_1 + t_2 + t_3\n else:\n active_dimsM = [0, 1]\n t = 1 + t_1\n\n matern_ker = MaternKernel(nu=nu, active_dims=active_dimsM)\n matern_term = matern_ker(x1, x2).to_dense()\n actual = t * matern_term\n res = kernel(x1, x2).to_dense()\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(res-actual),1e-4)", "reference dict": { "kernel": "LinearTruncatedFidelityKernel", "matern_ker": "MaternKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(res-actual),1e-4)", "y_neg": " self.assertLess(torch.norm(res - actual) / torch.norm(actual), 1e-5)", "retain": " def test_compute_linear_truncated_kernel_no_batch(self):\n x1 = torch.tensor([[1, 0.1, 0.2], [2, 0.3, 0.4]])\n x2 = torch.tensor([[3, 0.5, 0.6], [4, 0.7, 0.8]])\n t_1 = torch.tensor([[0.3584, 0.1856], [0.2976, 0.1584]])\n for nu, fidelity_dims in itertools.product({0.5, 1.5, 2.5}, ([2], [1, 2])):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=fidelity_dims, dimension=3, nu=nu\n )\n kernel.power = 1\n n_fid = len(fidelity_dims)\n if n_fid > 1:\n active_dimsM = [0]\n t_2 = torch.tensor([[0.4725, 0.2889], [0.4025, 0.2541]])\n t_3 = torch.tensor([[0.1685, 0.0531], [0.1168, 0.0386]])\n t = 1 + t_1 + t_2 + t_3\n else:\n active_dimsM = [0, 1]\n t = 1 + t_1\n\n matern_ker = MaternKernel(nu=nu, active_dims=active_dimsM)\n matern_term = matern_ker(x1, x2).to_dense()\n actual = t * matern_term\n res = kernel(x1, x2).to_dense()\n self.assertLess(torch.linalg.norm(res - actual), 1e-4)\n # test diagonal mode\n res_diag = kernel(x1, x2, diag=True)\n self.assertLess(torch.linalg.norm(res_diag - actual.diag()), 1e-4)\n # make sure that we error out if last_dim_is_batch=True\n with self.assertRaises(NotImplementedError):\n kernel(x1, x2, diag=True, last_dim_is_batch=True)" }, { "id": 7532, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_power(self):\n kernel = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=3)\n kernel.initialize(power=1)\n actual_value = torch.tensor(1, dtype=torch.float).view_as(kernel.power)\n self.assertLess(torch.linalg.norm(kernel.power - actual_value), 1e-5)", "probing input": " def test_initialize_power(self):\n kernel = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=3)\n kernel.initialize(power=1)\n actual_value = torch.tensor(1, dtype=torch.float).view_as(kernel.power)\n", "probing input new": " def test_initialize_power(self):\n kernel = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=3)\n kernel.initialize(power=1)\n actual_value = torch.tensor(1, dtype=torch.float).view_as(kernel.power)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.power-actual_value),1e-5)", "reference dict": { "kernel": "LinearTruncatedFidelityKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.power-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.power - actual_value), 1e-5)", "retain": " def test_initialize_power(self):\n kernel = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=3)\n kernel.initialize(power=1)\n actual_value = torch.tensor(1, dtype=torch.float).view_as(kernel.power)\n self.assertLess(torch.linalg.norm(kernel.power - actual_value), 1e-5)" }, { "id": 7533, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_power_batch(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=3, batch_shape=torch.Size([2])\n )\n power_init = torch.tensor([1, 2], dtype=torch.float)\n kernel.initialize(power=power_init)\n actual_value = power_init.view_as(kernel.power)\n self.assertLess(torch.linalg.norm(kernel.power - actual_value), 1e-5)", "probing input": " def test_initialize_power_batch(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=3, batch_shape=torch.Size([2])\n )\n power_init = torch.tensor([1, 2], dtype=torch.float)\n kernel.initialize(power=power_init)\n actual_value = power_init.view_as(kernel.power)\n", "probing input new": " def test_initialize_power_batch(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=3, batch_shape=torch.Size([2])\n )\n power_init = torch.tensor([1, 2], dtype=torch.float)\n kernel.initialize(power=power_init)\n actual_value = power_init.view_as(kernel.power)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.power-actual_value),1e-5)", "reference dict": { "kernel": "LinearTruncatedFidelityKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.power-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.power - actual_value), 1e-5)", "retain": " def test_initialize_power_batch(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=3, batch_shape=torch.Size([2])\n )\n power_init = torch.tensor([1, 2], dtype=torch.float)\n kernel.initialize(power=power_init)\n actual_value = power_init.view_as(kernel.power)\n self.assertLess(torch.linalg.norm(kernel.power - actual_value), 1e-5)" }, { "id": 7534, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_active_dims_list(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=[0, 2, 4, 6]\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=4)\n covar_mat_actual = kernel_basic(x[:, [0, 2, 4, 6]]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.linalg.norm(covar_mat - covar_mat_actual) / covar_mat_actual.norm(),\n 1e-4,\n )", "probing input": " def test_active_dims_list(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=[0, 2, 4, 6]\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=4)\n covar_mat_actual = kernel_basic(x[:, [0, 2, 4, 6]]).evaluate_kernel().to_dense()\n self.assertLess(\n", "probing input new": " def test_active_dims_list(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=[0, 2, 4, 6]\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=4)\n covar_mat_actual = kernel_basic(x[:, [0, 2, 4, 6]]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.", "reference": "torch.linalg.norm(covar_mat-covar_mat_actual)/covar_mat_actual.norm(),", "reference dict": { "kernel": "LinearTruncatedFidelityKernel", "kernel_basic": "LinearTruncatedFidelityKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "torch.linalg.norm(covar_mat-covar_mat_actual)/covar_mat_actual.norm(),", "y_neg": " torch.norm(covar_mat - covar_mat_actual, p=\"fro\"),", "retain": " def test_active_dims_list(self):\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=[0, 2, 4, 6]\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=4)\n covar_mat_actual = kernel_basic(x[:, [0, 2, 4, 6]]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.linalg.norm(covar_mat - covar_mat_actual) / covar_mat_actual.norm(),\n 1e-4,\n )" }, { "id": 7535, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_active_dims_range(self):\n active_dims = list(range(3, 9))\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=active_dims\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=6)\n covar_mat_actual = kernel_basic(x[:, active_dims]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.linalg.norm(covar_mat - covar_mat_actual) / covar_mat_actual.norm(),\n 1e-4,\n )", "probing input": " def test_active_dims_range(self):\n active_dims = list(range(3, 9))\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=active_dims\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=6)\n covar_mat_actual = kernel_basic(x[:, active_dims]).evaluate_kernel().to_dense()\n self.assertLess(\n", "probing input new": " def test_active_dims_range(self):\n active_dims = list(range(3, 9))\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=active_dims\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=6)\n covar_mat_actual = kernel_basic(x[:, active_dims]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.", "reference": "torch.linalg.norm(covar_mat-covar_mat_actual)/covar_mat_actual.norm(),", "reference dict": { "kernel": "LinearTruncatedFidelityKernel", "kernel_basic": "LinearTruncatedFidelityKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "torch.linalg.norm(covar_mat-covar_mat_actual)/covar_mat_actual.norm(),", "y_neg": " torch.norm(covar_mat - covar_mat_actual, p=\"fro\"),", "retain": " def test_active_dims_range(self):\n active_dims = list(range(3, 9))\n kernel = LinearTruncatedFidelityKernel(\n fidelity_dims=[1, 2], dimension=10, active_dims=active_dims\n )\n x = self.create_data_no_batch()\n covar_mat = kernel(x).evaluate_kernel().to_dense()\n kernel_basic = LinearTruncatedFidelityKernel(fidelity_dims=[1, 2], dimension=6)\n covar_mat_actual = kernel_basic(x[:, active_dims]).evaluate_kernel().to_dense()\n self.assertLess(\n torch.linalg.norm(covar_mat - covar_mat_actual) / covar_mat_actual.norm(),\n 1e-4,\n )" }, { "id": 7536, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm(array, axis=None, keepdims=False, ord=None):\n return torch.linalg.norm(array, dim=axis, keepdim=keepdims, ord=ord)", "probing input": "def norm(array, axis=None, keepdims=False, ord=None):\n", "probing input new": "def norm(array, axis=None, keepdims=False, ord=None):\n return torch.", "reference": "returntorch.linalg.norm(array,dim=axis,keepdim=keepdims,ord=ord)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(array,dim=axis,keepdim=keepdims,ord=ord)", "y_neg": " return torch.norm(array, axis=axis, keepdims=keepdims, ord=ord)", "retain": "def norm(array, axis=None, keepdims=False, ord=None):\n return torch.linalg.norm(array, dim=axis, keepdim=keepdims, ord=ord)" }, { "id": 7537, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_model_normalization(self):\n names = [\"fp16/ViT-B/32\", \"onnx16/open_clip/ViT-B-32/laion400m_e32\", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',\n 'RN50', \"ViT-B/16\", \"all-MiniLM-L6-v1\",\n \"all_datasets_v4_MiniLM-L6\", \"hf/all-MiniLM-L6-v1\", \"hf/all_datasets_v4_MiniLM-L6\",\n \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n \n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-6\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=True)\n output = _convert_vectorized_output(output)\n max_output_norm = max(torch.linalg.norm(FloatTensor(output), dim=1))\n min_output_norm = min(torch.linalg.norm(FloatTensor(output), dim=1))\n\n assert abs(max_output_norm - 1) < eps, f\"{name}, {sentence}\"\n assert abs(min_output_norm - 1) < eps, f\"{name}, {sentence}\"\n\n clear_loaded_models()", "probing input": " def test_model_normalization(self):\n names = [\"fp16/ViT-B/32\", \"onnx16/open_clip/ViT-B-32/laion400m_e32\", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',\n 'RN50', \"ViT-B/16\", \"all-MiniLM-L6-v1\",\n \"all_datasets_v4_MiniLM-L6\", \"hf/all-MiniLM-L6-v1\", \"hf/all_datasets_v4_MiniLM-L6\",\n \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n \n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-6\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=True)\n output = _convert_vectorized_output(output)\n", "probing input new": " def test_model_normalization(self):\n names = [\"fp16/ViT-B/32\", \"onnx16/open_clip/ViT-B-32/laion400m_e32\", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',\n 'RN50', \"ViT-B/16\", \"all-MiniLM-L6-v1\",\n \"all_datasets_v4_MiniLM-L6\", \"hf/all-MiniLM-L6-v1\", \"hf/all_datasets_v4_MiniLM-L6\",\n \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n \n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-6\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=True)\n output = _convert_vectorized_output(output)\n max_output_", "reference": "max_output_norm=max(torch.linalg.norm(FloatTensor(output),dim=1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "max_output_norm=max(torch.linalg.norm(FloatTensor(output),dim=1))", "y_neg": " max_output_norm = torch.norm(output, p='fro', dim=-1).max().item()", "retain": " def test_model_normalization(self):\n names = [\"fp16/ViT-B/32\", \"onnx16/open_clip/ViT-B-32/laion400m_e32\", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',\n 'RN50', \"ViT-B/16\", \"all-MiniLM-L6-v1\",\n \"all_datasets_v4_MiniLM-L6\", \"hf/all-MiniLM-L6-v1\", \"hf/all_datasets_v4_MiniLM-L6\",\n \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n \n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-6\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=True)\n output = _convert_vectorized_output(output)\n max_output_norm = max(torch.linalg.norm(FloatTensor(output), dim=1))\n min_output_norm = min(torch.linalg.norm(FloatTensor(output), dim=1))\n\n assert abs(max_output_norm - 1) < eps, f\"{name}, {sentence}\"\n assert abs(min_output_norm - 1) < eps, f\"{name}, {sentence}\"\n\n clear_loaded_models()" }, { "id": 7538, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_model_un_normalization(self):\n # note: sbert native seems to provide normalized embeddings even with = False, needs more investigation\n # , \n names = [ 'RN50', \"ViT-B/16\", \"hf/all-MiniLM-L6-v1\",\n \"hf/all_datasets_v4_MiniLM-L6\", \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n\n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-3\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=False)\n output = _convert_vectorized_output(output)\n max_output_norm = max(torch.linalg.norm(FloatTensor(output), dim=1))\n min_output_norm = min(torch.linalg.norm(FloatTensor(output), dim=1))\n\n assert abs(max_output_norm - 1) > eps, f\"{name}, {sentence}\"\n assert abs(min_output_norm - 1) > eps, f\"{name}, {sentence}\"\n\n clear_loaded_models()", "probing input": " def test_model_un_normalization(self):\n # note: sbert native seems to provide normalized embeddings even with = False, needs more investigation\n # , \n names = [ 'RN50', \"ViT-B/16\", \"hf/all-MiniLM-L6-v1\",\n \"hf/all_datasets_v4_MiniLM-L6\", \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n\n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-3\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=False)\n output = _convert_vectorized_output(output)\n", "probing input new": " def test_model_un_normalization(self):\n # note: sbert native seems to provide normalized embeddings even with = False, needs more investigation\n # , \n names = [ 'RN50', \"ViT-B/16\", \"hf/all-MiniLM-L6-v1\",\n \"hf/all_datasets_v4_MiniLM-L6\", \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n\n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-3\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=False)\n output = _convert_vectorized_output(output)\n max_output_", "reference": "max_output_norm=max(torch.linalg.norm(FloatTensor(output),dim=1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "max_output_norm=max(torch.linalg.norm(FloatTensor(output),dim=1))", "y_neg": " max_output_norm = torch.norm(output, p='fro', dim=1).max().item()", "retain": " def test_model_un_normalization(self):\n # note: sbert native seems to provide normalized embeddings even with = False, needs more investigation\n # , \n names = [ 'RN50', \"ViT-B/16\", \"hf/all-MiniLM-L6-v1\",\n \"hf/all_datasets_v4_MiniLM-L6\", \"onnx/all-MiniLM-L6-v1\", \"onnx/all_datasets_v4_MiniLM-L6\"]\n\n names_e5 = [\"hf/e5-small\", \"hf/e5-base\", \"hf/e5-small-unsupervised\", \"hf/e5-base-unsupervised\", \"hf/e5-base-v2\",\n \"hf/multilingual-e5-small\"]\n names += names_e5\n\n sentences = ['hello', 'this is a test sentence. so is this.', ['hello', 'this is a test sentence. so is this.']]\n device = 'cpu'\n eps = 1e-3\n\n for name in names:\n model_properties = get_model_properties_from_registry(name)\n model = _load_model(model_properties['name'], model_properties=model_properties, device=device)\n\n for sentence in sentences:\n output = model.encode(sentence, normalize=False)\n output = _convert_vectorized_output(output)\n max_output_norm = max(torch.linalg.norm(FloatTensor(output), dim=1))\n min_output_norm = min(torch.linalg.norm(FloatTensor(output), dim=1))\n\n assert abs(max_output_norm - 1) > eps, f\"{name}, {sentence}\"\n assert abs(min_output_norm - 1) > eps, f\"{name}, {sentence}\"\n\n clear_loaded_models()" }, { "id": 7541, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize(v):\n if isinstance(v, torch.Tensor):\n norm = torch.linalg.norm(v)\n else:\n norm = np.linalg.norm(v)\n if norm == 0.:\n return v\n return v / norm", "probing input": "def normalize(v):\n if isinstance(v, torch.Tensor):\n", "probing input new": "def normalize(v):\n if isinstance(v, torch.Tensor):\n ", "reference": "norm=torch.linalg.norm(v)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norm=torch.linalg.norm(v)", "y_neg": " return v / torch.norm(v)", "retain": "def normalize(v):\n if isinstance(v, torch.Tensor):\n norm = torch.linalg.norm(v)\n else:\n norm = np.linalg.norm(v)\n if norm == 0.:\n return v\n return v / norm" }, { "id": 7543, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_polyline_length(polyline):\n \"\"\"Calculate the length of a polyline.\n Args:\n polyline: Numpy array of shape (N,3)\n Returns:\n The length of the polyline as a scalar.\n Raises:\n RuntimeError: If `polyline` doesn't have shape (N,2) or (N,3).\n \"\"\"\n if polyline.shape[1] not in [2, 3]:\n raise RuntimeError(\"Polyline must have shape (N,2) or (N,3)\")\n offsets = torch.diff(polyline, axis=0)\n return float(torch.linalg.norm(offsets, axis=1).sum())", "probing input": "def get_polyline_length(polyline):\n \"\"\"Calculate the length of a polyline.\n Args:\n polyline: Numpy array of shape (N,3)\n Returns:\n The length of the polyline as a scalar.\n Raises:\n RuntimeError: If `polyline` doesn't have shape (N,2) or (N,3).\n \"\"\"\n if polyline.shape[1] not in [2, 3]:\n raise RuntimeError(\"Polyline must have shape (N,2) or (N,3)\")\n offsets = torch.diff(polyline, axis=0)\n", "probing input new": "def get_polyline_length(polyline):\n \"\"\"Calculate the length of a polyline.\n Args:\n polyline: Numpy array of shape (N,3)\n Returns:\n The length of the polyline as a scalar.\n Raises:\n RuntimeError: If `polyline` doesn't have shape (N,2) or (N,3).\n \"\"\"\n if polyline.shape[1] not in [2, 3]:\n raise RuntimeError(\"Polyline must have shape (N,2) or (N,3)\")\n offsets = torch.diff(polyline, axis=0)\n return float(torch.", "reference": "returnfloat(torch.linalg.norm(offsets,axis=1).sum())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnfloat(torch.linalg.norm(offsets,axis=1).sum())", "y_neg": " return float(torch.norm(offsets, p=2, dim=1).sum())", "retain": "def get_polyline_length(polyline):\n \"\"\"Calculate the length of a polyline.\n Args:\n polyline: Numpy array of shape (N,3)\n Returns:\n The length of the polyline as a scalar.\n Raises:\n RuntimeError: If `polyline` doesn't have shape (N,2) or (N,3).\n \"\"\"\n if polyline.shape[1] not in [2, 3]:\n raise RuntimeError(\"Polyline must have shape (N,2) or (N,3)\")\n offsets = torch.diff(polyline, axis=0)\n return float(torch.linalg.norm(offsets, axis=1).sum())" }, { "id": 7545, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_norm(self, weight):\n with torch.no_grad():\n weight_q, weight_k = weight[:self.num_features, :], weight[self.num_features:, :]\n dot_matrix = weight_q @ weight_k.T * self.scale\n self.lipnorm = torch.linalg.norm(torch.eye(self.num_features,\n device=weight.device) + 2 * dot_matrix,\n ord=2) + 5", "probing input": " def get_norm(self, weight):\n with torch.no_grad():\n weight_q, weight_k = weight[:self.num_features, :], weight[self.num_features:, :]\n dot_matrix = weight_q @ weight_k.T * self.scale\n", "probing input new": " def get_norm(self, weight):\n with torch.no_grad():\n weight_q, weight_k = weight[:self.num_features, :], weight[self.num_features:, :]\n dot_matrix = weight_q @ weight_k.T * self.scale\n self.lip", "reference": "self.lipnorm=torch.linalg.norm(torch.eye(self.num_features,device=weight.device)+2*dot_matrix,ord=2)+5", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.lipnorm=torch.linalg.norm(torch.eye(self.num_features,device=weight.device)+2*dot_matrix,ord=2)+5", "y_neg": " self.lip_norm = torch.norm(dot_matrix, p='fro', dim=1)", "retain": " def get_norm(self, weight):\n with torch.no_grad():\n weight_q, weight_k = weight[:self.num_features, :], weight[self.num_features:, :]\n dot_matrix = weight_q @ weight_k.T * self.scale\n self.lipnorm = torch.linalg.norm(torch.eye(self.num_features,\n device=weight.device) + 2 * dot_matrix,\n ord=2) + 5" }, { "id": 7546, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def iterative_pinv_analysis(\n identity_tolerance: float = 1e-1,\n pinv_tolerance: float = 5e-1,\n max_iters: int = 30,\n plot: bool = True,\n):\n\n for i in range(1, 10):\n B, M = 1, 2**i\n a = torch.rand(B, M, M)\n a = torch.softmax(a, dim=-1)\n\n for n_iter in range(1, max_iters + 1):\n result = iterative_pinv(a, n_iter=n_iter)\n expected = torch.linalg.pinv(a)\n\n result_identity = torch.matmul(a, result)\n identity = torch.eye(M)\n\n # Default is frobenius norm.\n identity_error = torch.linalg.norm(identity - result_identity, dim=(-2, -1))\n inverse_error = torch.linalg.norm(expected - result, dim=(-2, -1))\n\n if (identity_error < identity_tolerance).all() or n_iter == max_iters:\n print(\n f\"Size {M}, n_iters {n_iter}: \\n\\t \\\n Final Error from Identity: {identity_error.item()} \\n\\t \\\n Final Error from linalg.pinv {inverse_error.item()}\"\n )\n break", "probing input": "def iterative_pinv_analysis(\n identity_tolerance: float = 1e-1,\n pinv_tolerance: float = 5e-1,\n max_iters: int = 30,\n plot: bool = True,\n):\n\n for i in range(1, 10):\n B, M = 1, 2**i\n a = torch.rand(B, M, M)\n a = torch.softmax(a, dim=-1)\n\n for n_iter in range(1, max_iters + 1):\n result = iterative_pinv(a, n_iter=n_iter)\n expected = torch.linalg.pinv(a)\n\n result_identity = torch.matmul(a, result)\n identity = torch.eye(M)\n\n # Default is frobenius norm.\n", "probing input new": "def iterative_pinv_analysis(\n identity_tolerance: float = 1e-1,\n pinv_tolerance: float = 5e-1,\n max_iters: int = 30,\n plot: bool = True,\n):\n\n for i in range(1, 10):\n B, M = 1, 2**i\n a = torch.rand(B, M, M)\n a = torch.softmax(a, dim=-1)\n\n for n_iter in range(1, max_iters + 1):\n result = iterative_pinv(a, n_iter=n_iter)\n expected = torch.linalg.pinv(a)\n\n result_identity = torch.matmul(a, result)\n identity = torch.eye(M)\n\n # Default is frobenius norm.\n identity_error = torch.", "reference": "identity_error=torch.linalg.norm(identity-result_identity,dim=(-2,-1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "identity_error=torch.linalg.norm(identity-result_identity,dim=(-2,-1))", "y_neg": " identity_error = torch.norm(result_identity - identity, 'fro')", "retain": "def iterative_pinv_analysis(\n identity_tolerance: float = 1e-1,\n pinv_tolerance: float = 5e-1,\n max_iters: int = 30,\n plot: bool = True,\n):\n\n for i in range(1, 10):\n B, M = 1, 2**i\n a = torch.rand(B, M, M)\n a = torch.softmax(a, dim=-1)\n\n for n_iter in range(1, max_iters + 1):\n result = iterative_pinv(a, n_iter=n_iter)\n expected = torch.linalg.pinv(a)\n\n result_identity = torch.matmul(a, result)\n identity = torch.eye(M)\n\n # Default is frobenius norm.\n identity_error = torch.linalg.norm(identity - result_identity, dim=(-2, -1))\n inverse_error = torch.linalg.norm(expected - result, dim=(-2, -1))\n\n if (identity_error < identity_tolerance).all() or n_iter == max_iters:\n print(\n f\"Size {M}, n_iters {n_iter}: \\n\\t \\\n Final Error from Identity: {identity_error.item()} \\n\\t \\\n Final Error from linalg.pinv {inverse_error.item()}\"\n )\n break" }, { "id": 7549, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def volumetric_rendering(rgb, density, t_samples, dirs, white_bkgd):\n \"\"\"Volumetric Rendering Function.\n Args:\n rgb: torch.Tensor, color, [batch_size, num_samples, 3]\n density: torch.Tensor, density, [batch_size, num_samples, 1].\n t_samples: torch.Tensor, [batch_size, num_samples+1].\n dirs: torch.Tensor, [batch_size, 3].\n white_bkgd: bool.\n Returns:\n comp_rgb: torch.Tensor, [batch_size, 3].\n disp: torch.Tensor, [batch_size].\n acc: torch.Tensor, [batch_size].\n weights: torch.Tensor, [batch_size, num_samples]\n \"\"\"\n t_mids = 0.5 * (t_samples[..., :-1] + t_samples[..., 1:])\n t_interval = t_samples[..., 1:] - t_samples[..., :-1] # [B, N]\n # models/mip.py:8 here sample point by multiply the interval with the direction without normalized, so\n # the delta is norm(t1*d-t2*d) = (t1-t2)*norm(d)\n delta = t_interval * torch.linalg.norm(torch.unsqueeze(dirs, dim=-2), dim=-1)\n # Note that we're quietly turning density from [..., 0] to [...].\n density_delta = density[..., 0] * delta\n\n alpha = 1 - torch.exp(-density_delta)\n trans = torch.exp(-torch.cat([\n torch.zeros_like(density_delta[..., :1]),\n torch.cumsum(density_delta[..., :-1], dim=-1)\n ], dim=-1))\n weights = alpha * trans # [B, N]\n\n comp_rgb = (torch.unsqueeze(weights, dim=-1) * rgb).sum(axis=-2) # [B, N, 1] * [B, N, 3] -> [B, 3]\n acc = weights.sum(axis=-1)\n distance = (weights * t_mids).sum(axis=-1)\n distance = torch.clamp(torch.nan_to_num(distance), t_samples[:, 0], t_samples[:, -1])\n if white_bkgd:\n comp_rgb = comp_rgb + (1. - torch.unsqueeze(acc, dim=-1))\n return comp_rgb, distance, acc, weights", "probing input": "def volumetric_rendering(rgb, density, t_samples, dirs, white_bkgd):\n \"\"\"Volumetric Rendering Function.\n Args:\n rgb: torch.Tensor, color, [batch_size, num_samples, 3]\n density: torch.Tensor, density, [batch_size, num_samples, 1].\n t_samples: torch.Tensor, [batch_size, num_samples+1].\n dirs: torch.Tensor, [batch_size, 3].\n white_bkgd: bool.\n Returns:\n comp_rgb: torch.Tensor, [batch_size, 3].\n disp: torch.Tensor, [batch_size].\n acc: torch.Tensor, [batch_size].\n weights: torch.Tensor, [batch_size, num_samples]\n \"\"\"\n t_mids = 0.5 * (t_samples[..., :-1] + t_samples[..., 1:])\n t_interval = t_samples[..., 1:] - t_samples[..., :-1] # [B, N]\n # models/mip.py:8 here sample point by multiply the interval with the direction without normalized, so\n # the delta is norm(t1*d-t2*d) = (t1-t2)*norm(d)\n", "probing input new": "def volumetric_rendering(rgb, density, t_samples, dirs, white_bkgd):\n \"\"\"Volumetric Rendering Function.\n Args:\n rgb: torch.Tensor, color, [batch_size, num_samples, 3]\n density: torch.Tensor, density, [batch_size, num_samples, 1].\n t_samples: torch.Tensor, [batch_size, num_samples+1].\n dirs: torch.Tensor, [batch_size, 3].\n white_bkgd: bool.\n Returns:\n comp_rgb: torch.Tensor, [batch_size, 3].\n disp: torch.Tensor, [batch_size].\n acc: torch.Tensor, [batch_size].\n weights: torch.Tensor, [batch_size, num_samples]\n \"\"\"\n t_mids = 0.5 * (t_samples[..., :-1] + t_samples[..., 1:])\n t_interval = t_samples[..., 1:] - t_samples[..., :-1] # [B, N]\n # models/mip.py:8 here sample point by multiply the interval with the direction without normalized, so\n # the delta is norm(t1*d-t2*d) = (t1-t2)*norm(d)\n delta = t_interval * torch.", "reference": "delta=t_interval*torch.linalg.norm(torch.unsqueeze(dirs,dim=-2),dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "delta=t_interval*torch.linalg.norm(torch.unsqueeze(dirs,dim=-2),dim=-1)", "y_neg": " delta = t_interval * torch.norm(dirs, dim=-1, keepdim=True) # [B, N, 3]", "retain": "def volumetric_rendering(rgb, density, t_samples, dirs, white_bkgd):\n \"\"\"Volumetric Rendering Function.\n Args:\n rgb: torch.Tensor, color, [batch_size, num_samples, 3]\n density: torch.Tensor, density, [batch_size, num_samples, 1].\n t_samples: torch.Tensor, [batch_size, num_samples+1].\n dirs: torch.Tensor, [batch_size, 3].\n white_bkgd: bool.\n Returns:\n comp_rgb: torch.Tensor, [batch_size, 3].\n disp: torch.Tensor, [batch_size].\n acc: torch.Tensor, [batch_size].\n weights: torch.Tensor, [batch_size, num_samples]\n \"\"\"\n t_mids = 0.5 * (t_samples[..., :-1] + t_samples[..., 1:])\n t_interval = t_samples[..., 1:] - t_samples[..., :-1] # [B, N]\n # models/mip.py:8 here sample point by multiply the interval with the direction without normalized, so\n # the delta is norm(t1*d-t2*d) = (t1-t2)*norm(d)\n delta = t_interval * torch.linalg.norm(torch.unsqueeze(dirs, dim=-2), dim=-1)\n # Note that we're quietly turning density from [..., 0] to [...].\n density_delta = density[..., 0] * delta\n\n alpha = 1 - torch.exp(-density_delta)\n trans = torch.exp(-torch.cat([\n torch.zeros_like(density_delta[..., :1]),\n torch.cumsum(density_delta[..., :-1], dim=-1)\n ], dim=-1))\n weights = alpha * trans # [B, N]\n\n comp_rgb = (torch.unsqueeze(weights, dim=-1) * rgb).sum(axis=-2) # [B, N, 1] * [B, N, 3] -> [B, 3]\n acc = weights.sum(axis=-1)\n distance = (weights * t_mids).sum(axis=-1)\n distance = torch.clamp(torch.nan_to_num(distance), t_samples[:, 0], t_samples[:, -1])\n if white_bkgd:\n comp_rgb = comp_rgb + (1. - torch.unsqueeze(acc, dim=-1))\n return comp_rgb, distance, acc, weights" }, { "id": 7550, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, torch.Tensor]):\n # coords_grid should remain immutable (a new tensor is implicitly created here)\n pixel_y, pixel_x = pixel_grid\n pixel_x = pixel_x.to(camera.device, camera.dtype)\n pixel_y = pixel_y.to(camera.device, camera.dtype)\n\n # Account for principal point offset from canvas center\n pixel_x = pixel_x - camera.x0\n pixel_y = pixel_y + camera.y0\n\n # pixel values are now in range [-1, 1], both tensors are of shape res_y x res_x\n pixel_x = 2 * (pixel_x / camera.width) - 1.0\n pixel_y = 2 * (pixel_y / camera.height) - 1.0\n\n ray_dir = torch.stack((pixel_x * camera.tan_half_fov(CameraFOV.HORIZONTAL),\n -pixel_y * camera.tan_half_fov(CameraFOV.VERTICAL),\n -torch.ones_like(pixel_x)), dim=-1)\n\n ray_dir = ray_dir.reshape(-1, 3) # Flatten grid rays to 1D array\n ray_orig = torch.zeros_like(ray_dir)\n\n # Transform from camera to world coordinates\n ray_orig, ray_dir = camera.extrinsics.inv_transform_rays(ray_orig, ray_dir)\n ray_dir /= torch.linalg.norm(ray_dir, dim=-1, keepdim=True)\n ray_orig, ray_dir = ray_orig[0], ray_dir[0] # Assume a single camera\n\n return ray_orig, ray_dir, camera.near, camera.far", "probing input": "def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, torch.Tensor]):\n # coords_grid should remain immutable (a new tensor is implicitly created here)\n pixel_y, pixel_x = pixel_grid\n pixel_x = pixel_x.to(camera.device, camera.dtype)\n pixel_y = pixel_y.to(camera.device, camera.dtype)\n\n # Account for principal point offset from canvas center\n pixel_x = pixel_x - camera.x0\n pixel_y = pixel_y + camera.y0\n\n # pixel values are now in range [-1, 1], both tensors are of shape res_y x res_x\n pixel_x = 2 * (pixel_x / camera.width) - 1.0\n pixel_y = 2 * (pixel_y / camera.height) - 1.0\n\n ray_dir = torch.stack((pixel_x * camera.tan_half_fov(CameraFOV.HORIZONTAL),\n -pixel_y * camera.tan_half_fov(CameraFOV.VERTICAL),\n -torch.ones_like(pixel_x)), dim=-1)\n\n ray_dir = ray_dir.reshape(-1, 3) # Flatten grid rays to 1D array\n ray_orig = torch.zeros_like(ray_dir)\n\n # Transform from camera to world coordinates\n ray_orig, ray_dir = camera.extrinsics.inv_transform_rays(ray_orig, ray_dir)\n", "probing input new": "def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, torch.Tensor]):\n # coords_grid should remain immutable (a new tensor is implicitly created here)\n pixel_y, pixel_x = pixel_grid\n pixel_x = pixel_x.to(camera.device, camera.dtype)\n pixel_y = pixel_y.to(camera.device, camera.dtype)\n\n # Account for principal point offset from canvas center\n pixel_x = pixel_x - camera.x0\n pixel_y = pixel_y + camera.y0\n\n # pixel values are now in range [-1, 1], both tensors are of shape res_y x res_x\n pixel_x = 2 * (pixel_x / camera.width) - 1.0\n pixel_y = 2 * (pixel_y / camera.height) - 1.0\n\n ray_dir = torch.stack((pixel_x * camera.tan_half_fov(CameraFOV.HORIZONTAL),\n -pixel_y * camera.tan_half_fov(CameraFOV.VERTICAL),\n -torch.ones_like(pixel_x)), dim=-1)\n\n ray_dir = ray_dir.reshape(-1, 3) # Flatten grid rays to 1D array\n ray_orig = torch.zeros_like(ray_dir)\n\n # Transform from camera to world coordinates\n ray_orig, ray_dir = camera.extrinsics.inv_transform_rays(ray_orig, ray_dir)\n ray_dir /= torch.", "reference": "ray_dir/=torch.linalg.norm(ray_dir,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "ray_dir/=torch.linalg.norm(ray_dir,dim=-1,keepdim=True)", "y_neg": " ray_dir /= torch.norm(ray_dir, dim=-1, keepdim=True)", "retain": "def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, torch.Tensor]):\n # coords_grid should remain immutable (a new tensor is implicitly created here)\n pixel_y, pixel_x = pixel_grid\n pixel_x = pixel_x.to(camera.device, camera.dtype)\n pixel_y = pixel_y.to(camera.device, camera.dtype)\n\n # Account for principal point offset from canvas center\n pixel_x = pixel_x - camera.x0\n pixel_y = pixel_y + camera.y0\n\n # pixel values are now in range [-1, 1], both tensors are of shape res_y x res_x\n pixel_x = 2 * (pixel_x / camera.width) - 1.0\n pixel_y = 2 * (pixel_y / camera.height) - 1.0\n\n ray_dir = torch.stack((pixel_x * camera.tan_half_fov(CameraFOV.HORIZONTAL),\n -pixel_y * camera.tan_half_fov(CameraFOV.VERTICAL),\n -torch.ones_like(pixel_x)), dim=-1)\n\n ray_dir = ray_dir.reshape(-1, 3) # Flatten grid rays to 1D array\n ray_orig = torch.zeros_like(ray_dir)\n\n # Transform from camera to world coordinates\n ray_orig, ray_dir = camera.extrinsics.inv_transform_rays(ray_orig, ray_dir)\n ray_dir /= torch.linalg.norm(ray_dir, dim=-1, keepdim=True)\n ray_orig, ray_dir = ray_orig[0], ray_dir[0] # Assume a single camera\n\n return ray_orig, ray_dir, camera.near, camera.far" }, { "id": 7553, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_rotvec(self, eps: float = 1e-6) -> torch.Tensor:\n \"\"\"Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.linalg.norm(quat[..., 1:], dim=-1), quat[..., 0])\n\n angle2 = angle * angle\n small_angle_scales = 2 + angle2 / 12 + 7 * angle2 * angle2 / 2880\n large_angle_scales = angle / torch.sin(angle / 2 + eps)\n\n small_angles = (angle <= 1e-3).float()\n rot_vec_scale = small_angle_scales * small_angles + (1 - small_angles) * large_angle_scales\n rot_vec = rot_vec_scale[..., None] * quat[..., 1:]\n return rot_vec", "probing input": " def get_rotvec(self, eps: float = 1e-6) -> torch.Tensor:\n \"\"\"Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n", "probing input new": " def get_rotvec(self, eps: float = 1e-6) -> torch.Tensor:\n \"\"\"Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.", "reference": "angle=2*torch.atan2(torch.linalg.norm(quat[...,1:],dim=-1),quat[...,0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "angle=2*torch.atan2(torch.linalg.norm(quat[...,1:],dim=-1),quat[...,0])", "y_neg": " angle = 2 * torch.atan2(torch.norm(quat[..., 1:], dim=-1), quat[..., 0])", "retain": " def get_rotvec(self, eps: float = 1e-6) -> torch.Tensor:\n \"\"\"Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.linalg.norm(quat[..., 1:], dim=-1), quat[..., 0])\n\n angle2 = angle * angle\n small_angle_scales = 2 + angle2 / 12 + 7 * angle2 * angle2 / 2880\n large_angle_scales = angle / torch.sin(angle / 2 + eps)\n\n small_angles = (angle <= 1e-3).float()\n rot_vec_scale = small_angle_scales * small_angles + (1 - small_angles) * large_angle_scales\n rot_vec = rot_vec_scale[..., None] * quat[..., 1:]\n return rot_vec" }, { "id": 7556, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, positions):\n # Apply global scale and translation\n positions = (\n positions * self.global_scale[None, None, :]\n + self.global_translation[None, None, :]\n )\n\n mag = torch.linalg.norm(positions, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = positions.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (positions[mask] / mag[mask][..., None])\n\n return x_new", "probing input": " def forward(self, positions):\n # Apply global scale and translation\n positions = (\n positions * self.global_scale[None, None, :]\n + self.global_translation[None, None, :]\n )\n\n", "probing input new": " def forward(self, positions):\n # Apply global scale and translation\n positions = (\n positions * self.global_scale[None, None, :]\n + self.global_translation[None, None, :]\n )\n\n mag = torch.", "reference": "mag=torch.linalg.norm(positions,ord=self.order,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(positions,ord=self.order,dim=-1)", "y_neg": " mag = torch.norm(positions, dim=-1, keepdim=True)", "retain": " def forward(self, positions):\n # Apply global scale and translation\n positions = (\n positions * self.global_scale[None, None, :]\n + self.global_translation[None, None, :]\n )\n\n mag = torch.linalg.norm(positions, ord=self.order, dim=-1)\n mask = mag >= 1\n x_new = positions.clone()\n x_new[mask] = (2 - (1 / mag[mask][..., None])) * (positions[mask] / mag[mask][..., None])\n\n return x_new" }, { "id": 7561, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x: torch.Tensor) -> torch.Tensor:\n assert (x.shape[-2] == self.input_size) and (\n x.shape[-1] == self.input_size\n ), f\"The model expects input images to be resized to {self.input_size}x{self.input_size}\"\n\n res = self.visual.forward(x)\n if self.normalize:\n res = res / torch.linalg.norm(res, 2, dim=1, keepdim=True).detach()\n return res", "probing input": " def forward(self, x: torch.Tensor) -> torch.Tensor:\n assert (x.shape[-2] == self.input_size) and (\n x.shape[-1] == self.input_size\n ), f\"The model expects input images to be resized to {self.input_size}x{self.input_size}\"\n\n res = self.visual.forward(x)\n if self.normalize:\n", "probing input new": " def forward(self, x: torch.Tensor) -> torch.Tensor:\n assert (x.shape[-2] == self.input_size) and (\n x.shape[-1] == self.input_size\n ), f\"The model expects input images to be resized to {self.input_size}x{self.input_size}\"\n\n res = self.visual.forward(x)\n if self.normalize:\n res = res / torch.", "reference": "res=res/torch.linalg.norm(res,2,dim=1,keepdim=True).detach()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "res=res/torch.linalg.norm(res,2,dim=1,keepdim=True).detach()", "y_neg": " res = res / torch.norm(res, p='fro', dim=1, keepdim=True)", "retain": " def forward(self, x: torch.Tensor) -> torch.Tensor:\n assert (x.shape[-2] == self.input_size) and (\n x.shape[-1] == self.input_size\n ), f\"The model expects input images to be resized to {self.input_size}x{self.input_size}\"\n\n res = self.visual.forward(x)\n if self.normalize:\n res = res / torch.linalg.norm(res, 2, dim=1, keepdim=True).detach()\n return res" }, { "id": 7564, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def torch_find_closest_on_surface_full(othersRefList, refN, pointN, resource_folder):\n \"\"\"\n full implementation of cortical projection using the balloon inflation algorithm described in\n https://doi.org/10.1016/j.neuroimage.2005.01.018\n :param othersRefList: the refN x pointN x 3 transformed sensor locations (into ref brains)\n :param refN: number of reference brains\n :param pointN: number of sensors\n :return:\n \"\"\"\n device = othersRefList.device\n otherRefCList = torch.empty((refN, pointN, 3), dtype=torch.float).to(device)\n # otherRefCList = np.empty((1, refN), dtype=object)\n for i in range(refN):\n my_str = resource_folder+\"/MNI_templates/xyzall{}.npy\".format(str(i + 1))\n XYZ = load_raw_MNI_data(my_str, i, resource_folder=resource_folder)\n XYZ = torch.FloatTensor(XYZ).to(othersRefList.device).to(device)\n projectionListC = torch.ones((pointN, 3)).to(device)\n for j in range(pointN):\n P = othersRefList[i, j, :3]\n PP = torch.broadcast_to(P, XYZ.shape)\n D = torch.linalg.norm(XYZ - PP, dim=1)\n top = round(XYZ.shape[0] * 0.05) # select 5% of data (original paper selects 1000 points)\n XYZtop = XYZ[torch.topk(D, largest=False, k=top).indices, :]\n Nclose = 200\n XYZclose = XYZ[torch.topk(D, largest=False, k=Nclose).indices, :]\n PNear = torch.mean(XYZclose, dim=0) # select mean of closest 200 points\n\n # Line between P and PNear\n p1 = P.unsqueeze(0)\n p2 = PNear.unsqueeze(0)\n p3 = XYZtop\n # cross product the line with the point and normalize gives exactly distance from line\n distance_from_line = torch.linalg.norm(torch.cross(torch.broadcast_to(p2 - p1, p3.shape), p3 - p1) / torch.linalg.norm(p2-p1), dim=1)\n det = 0\n rodR = 0\n while det == 0:\n rodR += 1\n Iless2 = torch.where(distance_from_line <= rodR)\n rod = XYZtop[Iless2]\n det = torch.sum(rod ** 2)\n\n # Find brain surface points on the vicinity of P (l 862)\n PPB = torch.broadcast_to(P, rod.shape)\n VicD = torch.linalg.norm(rod - PPB, dim=1)\n NVic = 3\n if rod.shape[0] < NVic:\n NVic = rod.shape[0]\n IVicD = torch.argsort(VicD)\n NIVicD = IVicD[0:NVic]\n Vic = rod[NIVicD, :]\n CP = torch.mean(Vic, dim=0)\n\n projectionListC[j, :] = CP\n otherRefCList[i] = projectionListC\n return otherRefCList", "probing input": "def torch_find_closest_on_surface_full(othersRefList, refN, pointN, resource_folder):\n \"\"\"\n full implementation of cortical projection using the balloon inflation algorithm described in\n https://doi.org/10.1016/j.neuroimage.2005.01.018\n :param othersRefList: the refN x pointN x 3 transformed sensor locations (into ref brains)\n :param refN: number of reference brains\n :param pointN: number of sensors\n :return:\n \"\"\"\n device = othersRefList.device\n otherRefCList = torch.empty((refN, pointN, 3), dtype=torch.float).to(device)\n # otherRefCList = np.empty((1, refN), dtype=object)\n for i in range(refN):\n my_str = resource_folder+\"/MNI_templates/xyzall{}.npy\".format(str(i + 1))\n XYZ = load_raw_MNI_data(my_str, i, resource_folder=resource_folder)\n XYZ = torch.FloatTensor(XYZ).to(othersRefList.device).to(device)\n projectionListC = torch.ones((pointN, 3)).to(device)\n for j in range(pointN):\n P = othersRefList[i, j, :3]\n PP = torch.broadcast_to(P, XYZ.shape)\n", "probing input new": "def torch_find_closest_on_surface_full(othersRefList, refN, pointN, resource_folder):\n \"\"\"\n full implementation of cortical projection using the balloon inflation algorithm described in\n https://doi.org/10.1016/j.neuroimage.2005.01.018\n :param othersRefList: the refN x pointN x 3 transformed sensor locations (into ref brains)\n :param refN: number of reference brains\n :param pointN: number of sensors\n :return:\n \"\"\"\n device = othersRefList.device\n otherRefCList = torch.empty((refN, pointN, 3), dtype=torch.float).to(device)\n # otherRefCList = np.empty((1, refN), dtype=object)\n for i in range(refN):\n my_str = resource_folder+\"/MNI_templates/xyzall{}.npy\".format(str(i + 1))\n XYZ = load_raw_MNI_data(my_str, i, resource_folder=resource_folder)\n XYZ = torch.FloatTensor(XYZ).to(othersRefList.device).to(device)\n projectionListC = torch.ones((pointN, 3)).to(device)\n for j in range(pointN):\n P = othersRefList[i, j, :3]\n PP = torch.broadcast_to(P, XYZ.shape)\n D = torch.", "reference": "D=torch.linalg.norm(XYZ-PP,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "D=torch.linalg.norm(XYZ-PP,dim=1)", "y_neg": " D = torch.norm(PP - XYZ, dim=-1)", "retain": "def torch_find_closest_on_surface_full(othersRefList, refN, pointN, resource_folder):\n \"\"\"\n full implementation of cortical projection using the balloon inflation algorithm described in\n https://doi.org/10.1016/j.neuroimage.2005.01.018\n :param othersRefList: the refN x pointN x 3 transformed sensor locations (into ref brains)\n :param refN: number of reference brains\n :param pointN: number of sensors\n :return:\n \"\"\"\n device = othersRefList.device\n otherRefCList = torch.empty((refN, pointN, 3), dtype=torch.float).to(device)\n # otherRefCList = np.empty((1, refN), dtype=object)\n for i in range(refN):\n my_str = resource_folder+\"/MNI_templates/xyzall{}.npy\".format(str(i + 1))\n XYZ = load_raw_MNI_data(my_str, i, resource_folder=resource_folder)\n XYZ = torch.FloatTensor(XYZ).to(othersRefList.device).to(device)\n projectionListC = torch.ones((pointN, 3)).to(device)\n for j in range(pointN):\n P = othersRefList[i, j, :3]\n PP = torch.broadcast_to(P, XYZ.shape)\n D = torch.linalg.norm(XYZ - PP, dim=1)\n top = round(XYZ.shape[0] * 0.05) # select 5% of data (original paper selects 1000 points)\n XYZtop = XYZ[torch.topk(D, largest=False, k=top).indices, :]\n Nclose = 200\n XYZclose = XYZ[torch.topk(D, largest=False, k=Nclose).indices, :]\n PNear = torch.mean(XYZclose, dim=0) # select mean of closest 200 points\n\n # Line between P and PNear\n p1 = P.unsqueeze(0)\n p2 = PNear.unsqueeze(0)\n p3 = XYZtop\n # cross product the line with the point and normalize gives exactly distance from line\n distance_from_line = torch.linalg.norm(torch.cross(torch.broadcast_to(p2 - p1, p3.shape), p3 - p1) / torch.linalg.norm(p2-p1), dim=1)\n det = 0\n rodR = 0\n while det == 0:\n rodR += 1\n Iless2 = torch.where(distance_from_line <= rodR)\n rod = XYZtop[Iless2]\n det = torch.sum(rod ** 2)\n\n # Find brain surface points on the vicinity of P (l 862)\n PPB = torch.broadcast_to(P, rod.shape)\n VicD = torch.linalg.norm(rod - PPB, dim=1)\n NVic = 3\n if rod.shape[0] < NVic:\n NVic = rod.shape[0]\n IVicD = torch.argsort(VicD)\n NIVicD = IVicD[0:NVic]\n Vic = rod[NIVicD, :]\n CP = torch.mean(Vic, dim=0)\n\n projectionListC[j, :] = CP\n otherRefCList[i] = projectionListC\n return otherRefCList" }, { "id": 7565, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n if(quats is not None and normalize_quats):\n", "probing input new": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if((rot_mats is None and quats is None) or \n (rot_mats is not None and quats is not None)):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or \n (quats is not None and quats.shape[-1] != 4)):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n if(quats is not None and normalize_quats):\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7571, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit\n quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7576, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_rays(directions: torch.Tensor,\n c2w: torch.Tensor,\n ndc: bool,\n ndc_near: float = 1.0,\n intrinsics: Optional[Intrinsics] = None,\n normalize_rd: bool = True):\n \"\"\"Get ray origin and normalized directions in world coordinate for all pixels in one image.\n Reference: https://www.scratchapixel.com/lessons/3d-basic-rendering/\n ray-tracing-generating-camera-rays/standard-coordinate-systems\n\n Args:\n directions:\n c2w:\n ndc:\n ndc_near:\n intrinsics:\n normalize_rd:\n\n Returns:\n\n \"\"\"\n directions = directions.view(-1, 3) # [n_rays, 3]\n if len(c2w.shape) == 2:\n c2w = c2w[None, ...]\n rd = (directions[:, None, :] * c2w[:, :3, :3]).sum(dim=-1)\n ro = torch.broadcast_to(c2w[:, :3, 3], directions.shape)\n if ndc:\n assert intrinsics is not None, \"intrinsics must not be None when NDC active.\"\n ro, rd = ndc_rays_blender(\n intrinsics=intrinsics, near=ndc_near, rays_o=ro, rays_d=rd)\n if normalize_rd:\n rd /= torch.linalg.norm(rd, dim=-1, keepdim=True)\n return ro, rd", "probing input": "def get_rays(directions: torch.Tensor,\n c2w: torch.Tensor,\n ndc: bool,\n ndc_near: float = 1.0,\n intrinsics: Optional[Intrinsics] = None,\n normalize_rd: bool = True):\n \"\"\"Get ray origin and normalized directions in world coordinate for all pixels in one image.\n Reference: https://www.scratchapixel.com/lessons/3d-basic-rendering/\n ray-tracing-generating-camera-rays/standard-coordinate-systems\n\n Args:\n directions:\n c2w:\n ndc:\n ndc_near:\n intrinsics:\n normalize_rd:\n\n Returns:\n\n \"\"\"\n directions = directions.view(-1, 3) # [n_rays, 3]\n if len(c2w.shape) == 2:\n c2w = c2w[None, ...]\n rd = (directions[:, None, :] * c2w[:, :3, :3]).sum(dim=-1)\n ro = torch.broadcast_to(c2w[:, :3, 3], directions.shape)\n if ndc:\n assert intrinsics is not None, \"intrinsics must not be None when NDC active.\"\n ro, rd = ndc_rays_blender(\n intrinsics=intrinsics, near=ndc_near, rays_o=ro, rays_d=rd)\n if normalize_rd:\n", "probing input new": "def get_rays(directions: torch.Tensor,\n c2w: torch.Tensor,\n ndc: bool,\n ndc_near: float = 1.0,\n intrinsics: Optional[Intrinsics] = None,\n normalize_rd: bool = True):\n \"\"\"Get ray origin and normalized directions in world coordinate for all pixels in one image.\n Reference: https://www.scratchapixel.com/lessons/3d-basic-rendering/\n ray-tracing-generating-camera-rays/standard-coordinate-systems\n\n Args:\n directions:\n c2w:\n ndc:\n ndc_near:\n intrinsics:\n normalize_rd:\n\n Returns:\n\n \"\"\"\n directions = directions.view(-1, 3) # [n_rays, 3]\n if len(c2w.shape) == 2:\n c2w = c2w[None, ...]\n rd = (directions[:, None, :] * c2w[:, :3, :3]).sum(dim=-1)\n ro = torch.broadcast_to(c2w[:, :3, 3], directions.shape)\n if ndc:\n assert intrinsics is not None, \"intrinsics must not be None when NDC active.\"\n ro, rd = ndc_rays_blender(\n intrinsics=intrinsics, near=ndc_near, rays_o=ro, rays_d=rd)\n if normalize_rd:\n rd /= torch.", "reference": "rd/=torch.linalg.norm(rd,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rd/=torch.linalg.norm(rd,dim=-1,keepdim=True)", "y_neg": " rd /= torch.norm(rd, dim=-1, keepdim=True)", "retain": "def get_rays(directions: torch.Tensor,\n c2w: torch.Tensor,\n ndc: bool,\n ndc_near: float = 1.0,\n intrinsics: Optional[Intrinsics] = None,\n normalize_rd: bool = True):\n \"\"\"Get ray origin and normalized directions in world coordinate for all pixels in one image.\n Reference: https://www.scratchapixel.com/lessons/3d-basic-rendering/\n ray-tracing-generating-camera-rays/standard-coordinate-systems\n\n Args:\n directions:\n c2w:\n ndc:\n ndc_near:\n intrinsics:\n normalize_rd:\n\n Returns:\n\n \"\"\"\n directions = directions.view(-1, 3) # [n_rays, 3]\n if len(c2w.shape) == 2:\n c2w = c2w[None, ...]\n rd = (directions[:, None, :] * c2w[:, :3, :3]).sum(dim=-1)\n ro = torch.broadcast_to(c2w[:, :3, 3], directions.shape)\n if ndc:\n assert intrinsics is not None, \"intrinsics must not be None when NDC active.\"\n ro, rd = ndc_rays_blender(\n intrinsics=intrinsics, near=ndc_near, rays_o=ro, rays_d=rd)\n if normalize_rd:\n rd /= torch.linalg.norm(rd, dim=-1, keepdim=True)\n return ro, rd" }, { "id": 7577, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews,\n tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.linalg.norm(axes, dim=-1) # (B,)\n cos_values = (src_vectors * tgt_vectors).sum(dim=-1) # (B,)\n axes = F.normalize(axes, dim=-1, p=2) # (B, 3)\n skews = skew_symmetric_matrix(axes) # (B, 3, 3)\n eyes = torch.eye(3).cuda().unsqueeze(0).expand_as(skews) # (B, 3, 3)\n sin_values = sin_values.view(-1, 1, 1)\n cos_values = cos_values.view(-1, 1, 1)\n rotations = eyes + sin_values * skews + (1.0 - cos_values) * torch.matmul(\n skews, skews)\n\n # handle opposite direction\n sin_values = sin_values.view(-1)\n cos_values = cos_values.view(-1)\n masks = torch.logical_and(torch.eq(sin_values, 0.0),\n torch.lt(cos_values, 0.0))\n rotations[masks] *= -1\n\n output_shape = input_shape[:-1] + (3, 3)\n rotations = rotations.view(*output_shape)\n\n return rotations", "probing input": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews,\n tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n", "probing input new": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews,\n tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.", "reference": "sin_values=torch.linalg.norm(axes,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "sin_values=torch.linalg.norm(axes,dim=-1)", "y_neg": " sin_values = torch.norm(axes, dim=-1) # (B,)", "retain": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews,\n tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.linalg.norm(axes, dim=-1) # (B,)\n cos_values = (src_vectors * tgt_vectors).sum(dim=-1) # (B,)\n axes = F.normalize(axes, dim=-1, p=2) # (B, 3)\n skews = skew_symmetric_matrix(axes) # (B, 3, 3)\n eyes = torch.eye(3).cuda().unsqueeze(0).expand_as(skews) # (B, 3, 3)\n sin_values = sin_values.view(-1, 1, 1)\n cos_values = cos_values.view(-1, 1, 1)\n rotations = eyes + sin_values * skews + (1.0 - cos_values) * torch.matmul(\n skews, skews)\n\n # handle opposite direction\n sin_values = sin_values.view(-1)\n cos_values = cos_values.view(-1)\n masks = torch.logical_and(torch.eq(sin_values, 0.0),\n torch.lt(cos_values, 0.0))\n rotations[masks] *= -1\n\n output_shape = input_shape[:-1] + (3, 3)\n rotations = rotations.view(*output_shape)\n\n return rotations" }, { "id": 7578, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_dislf(seq, xyz, mask):\n L = seq.shape[0]\n resolved_cys_mask = ((seq==ChemData().aa2num['CYS']) * mask[:,5]).nonzero().squeeze(-1) # cys[5]=='sg'\n sgs = xyz[resolved_cys_mask,5]\n ii,jj = torch.triu_indices(sgs.shape[0],sgs.shape[0],1)\n d_sg_sg = torch.linalg.norm(sgs[ii,:]-sgs[jj,:], dim=-1)\n is_dslf = (d_sg_sg>1.7)*(d_sg_sg<2.3)\n\n dslf = []\n for i in is_dslf.nonzero():\n dslf.append( (\n resolved_cys_mask[ii[i]].item(),\n resolved_cys_mask[jj[i]].item(),\n ) )\n return dslf", "probing input": "def get_dislf(seq, xyz, mask):\n L = seq.shape[0]\n resolved_cys_mask = ((seq==ChemData().aa2num['CYS']) * mask[:,5]).nonzero().squeeze(-1) # cys[5]=='sg'\n sgs = xyz[resolved_cys_mask,5]\n ii,jj = torch.triu_indices(sgs.shape[0],sgs.shape[0],1)\n", "probing input new": "def get_dislf(seq, xyz, mask):\n L = seq.shape[0]\n resolved_cys_mask = ((seq==ChemData().aa2num['CYS']) * mask[:,5]).nonzero().squeeze(-1) # cys[5]=='sg'\n sgs = xyz[resolved_cys_mask,5]\n ii,jj = torch.triu_indices(sgs.shape[0],sgs.shape[0],1)\n d_sg_sg = torch.", "reference": "d_sg_sg=torch.linalg.norm(sgs[ii,:]-sgs[jj,:],dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "d_sg_sg=torch.linalg.norm(sgs[ii,:]-sgs[jj,:],dim=-1)", "y_neg": " d_sg_sg = torch.norm(xyz[ii,:3]-xyz[jj,:3],p=2,dim=-1)", "retain": "def get_dislf(seq, xyz, mask):\n L = seq.shape[0]\n resolved_cys_mask = ((seq==ChemData().aa2num['CYS']) * mask[:,5]).nonzero().squeeze(-1) # cys[5]=='sg'\n sgs = xyz[resolved_cys_mask,5]\n ii,jj = torch.triu_indices(sgs.shape[0],sgs.shape[0],1)\n d_sg_sg = torch.linalg.norm(sgs[ii,:]-sgs[jj,:], dim=-1)\n is_dslf = (d_sg_sg>1.7)*(d_sg_sg<2.3)\n\n dslf = []\n for i in is_dslf.nonzero():\n dslf.append( (\n resolved_cys_mask[ii[i]].item(),\n resolved_cys_mask[jj[i]].item(),\n ) )\n return dslf" }, { "id": 7581, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def calculate_acceletation(motionloader, device, xyz):\n # for now even if it is not xyz, the acceleration is one the euclidian/pose\n outfeat = \"output_xyz\" if xyz else \"output\"\n\n sum_acc = 0\n num_acc = 0\n for batch in motionloader:\n motion = batch[outfeat].permute(0, 3, 1, 2)\n bs, num_frames, njoints, nfeats = motion.shape\n \n velocity = motion[:, 1:] - motion[:, :-1]\n acceleration = velocity[:, 1:] - velocity[:, :-1]\n acceleration_normed = torch.linalg.norm(acceleration, axis=3)\n\n lengths = batch[\"lengths\"]\n mask = lengths_to_mask(lengths - 2) # because acceleration\n\n usefull_accs_n = acceleration_normed[mask]\n sum_acc += usefull_accs_n.sum().item()\n num_acc += np.prod(usefull_accs_n.shape)\n\n acceleration = sum_acc/num_acc\n return acceleration", "probing input": "def calculate_acceletation(motionloader, device, xyz):\n # for now even if it is not xyz, the acceleration is one the euclidian/pose\n outfeat = \"output_xyz\" if xyz else \"output\"\n\n sum_acc = 0\n num_acc = 0\n for batch in motionloader:\n motion = batch[outfeat].permute(0, 3, 1, 2)\n bs, num_frames, njoints, nfeats = motion.shape\n \n velocity = motion[:, 1:] - motion[:, :-1]\n acceleration = velocity[:, 1:] - velocity[:, :-1]\n", "probing input new": "def calculate_acceletation(motionloader, device, xyz):\n # for now even if it is not xyz, the acceleration is one the euclidian/pose\n outfeat = \"output_xyz\" if xyz else \"output\"\n\n sum_acc = 0\n num_acc = 0\n for batch in motionloader:\n motion = batch[outfeat].permute(0, 3, 1, 2)\n bs, num_frames, njoints, nfeats = motion.shape\n \n velocity = motion[:, 1:] - motion[:, :-1]\n acceleration = velocity[:, 1:] - velocity[:, :-1]\n acceleration_", "reference": "acceleration_normed=torch.linalg.norm(acceleration,axis=3)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "acceleration_normed=torch.linalg.norm(acceleration,axis=3)", "y_neg": " acceleration_norm = torch.norm(acceleration, p=2, dim=-1)", "retain": "def calculate_acceletation(motionloader, device, xyz):\n # for now even if it is not xyz, the acceleration is one the euclidian/pose\n outfeat = \"output_xyz\" if xyz else \"output\"\n\n sum_acc = 0\n num_acc = 0\n for batch in motionloader:\n motion = batch[outfeat].permute(0, 3, 1, 2)\n bs, num_frames, njoints, nfeats = motion.shape\n \n velocity = motion[:, 1:] - motion[:, :-1]\n acceleration = velocity[:, 1:] - velocity[:, :-1]\n acceleration_normed = torch.linalg.norm(acceleration, axis=3)\n\n lengths = batch[\"lengths\"]\n mask = lengths_to_mask(lengths - 2) # because acceleration\n\n usefull_accs_n = acceleration_normed[mask]\n sum_acc += usefull_accs_n.sum().item()\n num_acc += np.prod(usefull_accs_n.shape)\n\n acceleration = sum_acc/num_acc\n return acceleration" }, { "id": 7582, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def mouth_open_degree(scaled_mouth_keypoints):\n \"\"\"\n 计算张嘴程度\n :param scaled_mouth_keypoints: 按嘴部框范围标准化后的关键点坐标\n :return:\n \"\"\"\n up_mouth_keypoints = scaled_mouth_keypoints[13:16]\n down_mouth_keypoints = scaled_mouth_keypoints[17:20]\n # 计算嘴对应点之间的距离\n mouth_distance = torch.linalg.norm(up_mouth_keypoints - down_mouth_keypoints, axis=1)\n return mouth_distance", "probing input": " def mouth_open_degree(scaled_mouth_keypoints):\n \"\"\"\n 计算张嘴程度\n :param scaled_mouth_keypoints: 按嘴部框范围标准化后的关键点坐标\n :return:\n \"\"\"\n up_mouth_keypoints = scaled_mouth_keypoints[13:16]\n down_mouth_keypoints = scaled_mouth_keypoints[17:20]\n # 计算嘴对应点之间的距离\n", "probing input new": " def mouth_open_degree(scaled_mouth_keypoints):\n \"\"\"\n 计算张嘴程度\n :param scaled_mouth_keypoints: 按嘴部框范围标准化后的关键点坐标\n :return:\n \"\"\"\n up_mouth_keypoints = scaled_mouth_keypoints[13:16]\n down_mouth_keypoints = scaled_mouth_keypoints[17:20]\n # 计算嘴对应点之间的距离\n mouth_distance = torch.", "reference": "mouth_distance=torch.linalg.norm(up_mouth_keypoints-down_mouth_keypoints,axis=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mouth_distance=torch.linalg.norm(up_mouth_keypoints-down_mouth_keypoints,axis=1)", "y_neg": " mouth_distance = torch.norm(up_mouth_keypoints - down_mouth_keypoints)", "retain": " def mouth_open_degree(scaled_mouth_keypoints):\n \"\"\"\n 计算张嘴程度\n :param scaled_mouth_keypoints: 按嘴部框范围标准化后的关键点坐标\n :return:\n \"\"\"\n up_mouth_keypoints = scaled_mouth_keypoints[13:16]\n down_mouth_keypoints = scaled_mouth_keypoints[17:20]\n # 计算嘴对应点之间的距离\n mouth_distance = torch.linalg.norm(up_mouth_keypoints - down_mouth_keypoints, axis=1)\n return mouth_distance" }, { "id": 7586, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_lookat_box(bb_min, bb_max, intrins):\n \"\"\"\n The center and distance to a scene with bb_min, bb_max\n to place a camera with given intrinsics\n :param bb_min (3,)\n :param bb_max (3,)\n :param intrinsics, (fx, fy, cx, cy) of camera\n :param view_angle (optional) viewing angle in radians (elevation)\n \"\"\"\n fx, fy, cx, cy = intrins\n bb_min, bb_max = torch.tensor(bb_min), torch.tensor(bb_max)\n center = 0.5 * (bb_min + bb_max)\n size = torch.linalg.norm(bb_max - bb_min)\n cam_dist = np.sqrt(fx**2 + fy**2) / np.sqrt(cx**2 + cy**2)\n cam_dist = 0.75 * size * cam_dist\n return center, cam_dist", "probing input": "def compute_lookat_box(bb_min, bb_max, intrins):\n \"\"\"\n The center and distance to a scene with bb_min, bb_max\n to place a camera with given intrinsics\n :param bb_min (3,)\n :param bb_max (3,)\n :param intrinsics, (fx, fy, cx, cy) of camera\n :param view_angle (optional) viewing angle in radians (elevation)\n \"\"\"\n fx, fy, cx, cy = intrins\n bb_min, bb_max = torch.tensor(bb_min), torch.tensor(bb_max)\n center = 0.5 * (bb_min + bb_max)\n", "probing input new": "def compute_lookat_box(bb_min, bb_max, intrins):\n \"\"\"\n The center and distance to a scene with bb_min, bb_max\n to place a camera with given intrinsics\n :param bb_min (3,)\n :param bb_max (3,)\n :param intrinsics, (fx, fy, cx, cy) of camera\n :param view_angle (optional) viewing angle in radians (elevation)\n \"\"\"\n fx, fy, cx, cy = intrins\n bb_min, bb_max = torch.tensor(bb_min), torch.tensor(bb_max)\n center = 0.5 * (bb_min + bb_max)\n size = torch.", "reference": "size=torch.linalg.norm(bb_max-bb_min)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "size=torch.linalg.norm(bb_max-bb_min)", "y_neg": " size = torch.norm(bb_max - bb_min)", "retain": "def compute_lookat_box(bb_min, bb_max, intrins):\n \"\"\"\n The center and distance to a scene with bb_min, bb_max\n to place a camera with given intrinsics\n :param bb_min (3,)\n :param bb_max (3,)\n :param intrinsics, (fx, fy, cx, cy) of camera\n :param view_angle (optional) viewing angle in radians (elevation)\n \"\"\"\n fx, fy, cx, cy = intrins\n bb_min, bb_max = torch.tensor(bb_min), torch.tensor(bb_max)\n center = 0.5 * (bb_min + bb_max)\n size = torch.linalg.norm(bb_max - bb_min)\n cam_dist = np.sqrt(fx**2 + fy**2) / np.sqrt(cx**2 + cy**2)\n cam_dist = 0.75 * size * cam_dist\n return center, cam_dist" }, { "id": 7587, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lookat_matrix(source_pos, target_pos, up):\n \"\"\"\n IMPORTANT: USES RIGHT UP BACK XYZ CONVENTION\n :param source_pos (*, 3)\n :param target_pos (*, 3)\n :param up (3,)\n \"\"\"\n *dims, _ = source_pos.shape\n up = up.reshape(*(1,) * len(dims), 3)\n up = up / torch.linalg.norm(up, dim=-1, keepdim=True)\n back = normalize(target_pos - source_pos)\n right = normalize(torch.linalg.cross(up, back))\n up = normalize(torch.linalg.cross(back, right))\n R = torch.stack([right, up, back], dim=-1)\n return make_4x4_pose(R, source_pos)", "probing input": "def lookat_matrix(source_pos, target_pos, up):\n \"\"\"\n IMPORTANT: USES RIGHT UP BACK XYZ CONVENTION\n :param source_pos (*, 3)\n :param target_pos (*, 3)\n :param up (3,)\n \"\"\"\n *dims, _ = source_pos.shape\n up = up.reshape(*(1,) * len(dims), 3)\n", "probing input new": "def lookat_matrix(source_pos, target_pos, up):\n \"\"\"\n IMPORTANT: USES RIGHT UP BACK XYZ CONVENTION\n :param source_pos (*, 3)\n :param target_pos (*, 3)\n :param up (3,)\n \"\"\"\n *dims, _ = source_pos.shape\n up = up.reshape(*(1,) * len(dims), 3)\n up = up / torch.", "reference": "up=up/torch.linalg.norm(up,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "up=up/torch.linalg.norm(up,dim=-1,keepdim=True)", "y_neg": " up = up / torch.norm(up, p=2, dim=-1, keepdim=True)", "retain": "def lookat_matrix(source_pos, target_pos, up):\n \"\"\"\n IMPORTANT: USES RIGHT UP BACK XYZ CONVENTION\n :param source_pos (*, 3)\n :param target_pos (*, 3)\n :param up (3,)\n \"\"\"\n *dims, _ = source_pos.shape\n up = up.reshape(*(1,) * len(dims), 3)\n up = up / torch.linalg.norm(up, dim=-1, keepdim=True)\n back = normalize(target_pos - source_pos)\n right = normalize(torch.linalg.cross(up, back))\n up = normalize(torch.linalg.cross(back, right))\n R = torch.stack([right, up, back], dim=-1)\n return make_4x4_pose(R, source_pos)" }, { "id": 7591, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self, V: torch.Tensor, k: int, max_iter: int, tol: float\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :param max_iter:\n :type max_iter: int\n :param tol:\n :type tol: float\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n W, H = self.initialize(V, k) # NNDSVD-A init\n init_err = torch.linalg.norm(V - torch.mm(W, H))\n prev_err = init_err\n\n for i in range(1, max_iter + 1):\n W, H = self.step(V, W, H)\n\n if i % 10 == 0: # check rel err stopping criterion\n err = torch.linalg.norm(V - torch.mm(W, H))\n if (prev_err - err) / init_err < tol:\n break\n prev_err = err\n\n # TODO: convergence warning for case i == max_iter:\n\n return W, H", "probing input": " def forward(\n self, V: torch.Tensor, k: int, max_iter: int, tol: float\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :param max_iter:\n :type max_iter: int\n :param tol:\n :type tol: float\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n W, H = self.initialize(V, k) # NNDSVD-A init\n", "probing input new": " def forward(\n self, V: torch.Tensor, k: int, max_iter: int, tol: float\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :param max_iter:\n :type max_iter: int\n :param tol:\n :type tol: float\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n W, H = self.initialize(V, k) # NNDSVD-A init\n init_err = torch.", "reference": "init_err=torch.linalg.norm(V-torch.mm(W,H))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "init_err=torch.linalg.norm(V-torch.mm(W,H))", "y_neg": " init_err = torch.norm(V - self.approximate(W, H, k), 'fro')", "retain": " def forward(\n self, V: torch.Tensor, k: int, max_iter: int, tol: float\n ) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n\n :param V:\n :type V: torch.Tensor\n :param k:\n :type k: int\n :param max_iter:\n :type max_iter: int\n :param tol:\n :type tol: float\n :return:\n :rtype: Tuple[torch.Tensor, torch.Tensor]\n \"\"\"\n W, H = self.initialize(V, k) # NNDSVD-A init\n init_err = torch.linalg.norm(V - torch.mm(W, H))\n prev_err = init_err\n\n for i in range(1, max_iter + 1):\n W, H = self.step(V, W, H)\n\n if i % 10 == 0: # check rel err stopping criterion\n err = torch.linalg.norm(V - torch.mm(W, H))\n if (prev_err - err) / init_err < tol:\n break\n prev_err = err\n\n # TODO: convergence warning for case i == max_iter:\n\n return W, H" }, { "id": 7592, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = rays_o.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]).to(device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = rays_o.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = rays_o.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = rays_o.device\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]).to(device), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]).to(device), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7593, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # Batch, N_rays, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # Batch, N_rays, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # Batch, N_rays, 3\n rays_d = rays_v\n\n rays_o = rays_o.contiguous().view(-1, 3)\n rays_d = rays_d.contiguous().view(-1, 3)\n\n ################## - sphere tracer to extract depth maps ######################\n depth_masks_sphere, depth_maps_sphere = self.ray_tracer.extract_depth_maps(\n rays_o, rays_d,\n near[None, :].repeat(rays_o.shape[0], 1),\n far[None, :].repeat(rays_o.shape[0], 1),\n sdf_network, con_volume\n )\n\n depth_maps = depth_maps_sphere.view(batch_size, 1, H, W)\n depth_masks = depth_masks_sphere.view(batch_size, 1, H, W)\n\n depth_maps = torch.where(depth_masks, depth_maps,\n torch.zeros_like(depth_masks.float()).to(device)) # fill invalid pixels by 0\n\n return depth_maps, depth_masks", "probing input": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n", "probing input new": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # Batch, N_rays, 3", "retain": " def extract_depth_maps(self, sdf_network, con_volume, intrinsics, c2ws, H, W, near, far):\n \"\"\"\n extract depth maps from the density volume\n :param con_volume: [1, 1+C, dX, dY, dZ] can by con_volume or sdf_volume\n :param c2ws: [B, 4, 4]\n :param H:\n :param W:\n :param near:\n :param far:\n :return:\n \"\"\"\n device = con_volume.device\n batch_size = intrinsics.shape[0]\n\n with torch.no_grad():\n ys, xs = torch.meshgrid(torch.linspace(0, H - 1, H),\n torch.linspace(0, W - 1, W), indexing=\"ij\") # pytorch's meshgrid has indexing='ij'\n p = torch.stack([xs, ys, torch.ones_like(ys)], dim=-1) # H, W, 3\n\n intrinsics_inv = torch.inverse(intrinsics)\n\n p = p.view(-1, 3).float().to(device) # N_rays, 3\n p = torch.matmul(intrinsics_inv[:, None, :3, :3], p[:, :, None]).squeeze() # Batch, N_rays, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # Batch, N_rays, 3\n rays_v = torch.matmul(c2ws[:, None, :3, :3], rays_v[:, :, :, None]).squeeze() # Batch, N_rays, 3\n rays_o = c2ws[:, None, :3, 3].expand(rays_v.shape) # Batch, N_rays, 3\n rays_d = rays_v\n\n rays_o = rays_o.contiguous().view(-1, 3)\n rays_d = rays_d.contiguous().view(-1, 3)\n\n ################## - sphere tracer to extract depth maps ######################\n depth_masks_sphere, depth_maps_sphere = self.ray_tracer.extract_depth_maps(\n rays_o, rays_d,\n near[None, :].repeat(rays_o.shape[0], 1),\n far[None, :].repeat(rays_o.shape[0], 1),\n sdf_network, con_volume\n )\n\n depth_maps = depth_maps_sphere.view(batch_size, 1, H, W)\n depth_masks = depth_masks_sphere.view(batch_size, 1, H, W)\n\n depth_maps = torch.where(depth_masks, depth_maps,\n torch.zeros_like(depth_masks.float()).to(device)) # fill invalid pixels by 0\n\n return depth_maps, depth_masks" }, { "id": 7596, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def sample(self, points_torch, \n sensor_origin_torch,\n normal_torch,\n sem_label_torch):\n\n dev = self.dev\n\n world_scale = self.config.scale\n surface_sample_range_scaled = self.config.surface_sample_range_m * self.config.scale\n surface_sample_n = self.config.surface_sample_n\n clearance_sample_n = self.config.clearance_sample_n # new part\n\n freespace_sample_n = self.config.free_sample_n\n all_sample_n = surface_sample_n+clearance_sample_n+freespace_sample_n\n free_min_ratio = self.config.free_sample_begin_ratio\n free_sample_end_dist_m_scaled = self.config.free_sample_end_dist_m * self.config.scale\n clearance_dist_scaled = self.config.clearance_dist_m * self.config.scale\n \n sigma_base = self.config.sigma_sigmoid_m * self.config.scale\n # sigma_scale_constant = self.config.sigma_scale_constant\n\n # get sample points\n shift_points = points_torch - sensor_origin_torch\n point_num = shift_points.shape[0]\n distances = torch.linalg.norm(shift_points, dim=1, keepdim=True) # ray distances (scaled)\n \n # Part 1. close-to-surface uniform sampling \n # uniform sample in the close-to-surface range (+- range)\n surface_sample_displacement = (torch.rand(point_num*surface_sample_n, 1, device=dev)-0.5)*2*surface_sample_range_scaled \n \n repeated_dist = distances.repeat(surface_sample_n,1)\n surface_sample_dist_ratio = surface_sample_displacement/repeated_dist + 1.0 # 1.0 means on the surface\n if sem_label_torch is not None:\n surface_sem_label_tensor = sem_label_torch.repeat(1, surface_sample_n).transpose(0,1)\n \n # Part 2. near surface uniform sampling (for clearance) [from the close surface lower bound closer to the sensor for a clearance distance]\n clearance_sample_displacement = -torch.rand(point_num*clearance_sample_n, 1, device=dev)*clearance_dist_scaled - surface_sample_range_scaled\n\n repeated_dist = distances.repeat(clearance_sample_n,1)\n clearance_sample_dist_ratio = clearance_sample_displacement/repeated_dist + 1.0 # 1.0 means on the surface\n if sem_label_torch is not None:\n clearance_sem_label_tensor = torch.zeros_like(repeated_dist)\n\n # Part 3. free space uniform sampling\n repeated_dist = distances.repeat(freespace_sample_n,1)\n free_max_ratio = free_sample_end_dist_m_scaled / repeated_dist + 1.0\n free_diff_ratio = free_max_ratio - free_min_ratio\n\n free_sample_dist_ratio = torch.rand(point_num*freespace_sample_n, 1, device=dev)*free_diff_ratio + free_min_ratio\n \n free_sample_displacement = (free_sample_dist_ratio - 1.0) * repeated_dist\n if sem_label_torch is not None:\n free_sem_label_tensor = torch.zeros_like(repeated_dist)\n \n # all together\n all_sample_displacement = torch.cat((surface_sample_displacement, clearance_sample_displacement, free_sample_displacement),0)\n all_sample_dist_ratio = torch.cat((surface_sample_dist_ratio, clearance_sample_dist_ratio, free_sample_dist_ratio),0)\n \n repeated_points = shift_points.repeat(all_sample_n,1)\n repeated_dist = distances.repeat(all_sample_n,1)\n all_sample_points = repeated_points*all_sample_dist_ratio + sensor_origin_torch\n\n # depth tensor of all the samples\n depths_tensor = repeated_dist * all_sample_dist_ratio\n depths_tensor /= world_scale # unit: m\n\n # linear error model: sigma(d) = sigma_base + d * sigma_scale_constant\n # ray_sigma = sigma_base + distances * sigma_scale_constant \n # different sigma value for different ray with different distance (deprecated)\n # sigma_tensor = ray_sigma.repeat(all_sample_n,1).squeeze(1)\n\n # get the weight vector as the inverse of sigma\n weight_tensor = torch.ones_like(depths_tensor)\n\n # behind surface weight drop-off because we have less uncertainty behind the surface\n if self.config.behind_dropoff_on:\n dropoff_min = self.config.dropoff_min_sigma\n dropoff_max = self.config.dropoff_max_sigma\n dropoff_diff = dropoff_max - dropoff_min\n behind_displacement = (repeated_dist*(all_sample_dist_ratio-1.0)/sigma_base).squeeze(1)\n dropoff_weight = (dropoff_max - behind_displacement) / dropoff_diff\n dropoff_weight = torch.clamp(dropoff_weight, min = 0.0, max = 1.0)\n weight_tensor *= dropoff_weight\n \n # give a flag indicating the type of the sample [negative: freespace, positive: surface]\n weight_tensor[point_num*surface_sample_n:] *= -1.0 \n \n # ray-wise depth\n distances /= world_scale # unit: m\n distances = distances.squeeze(1)\n\n # assign sdf labels to the samples\n # projective distance as the label: behind +, in-front - \n sdf_label_tensor = all_sample_displacement.squeeze(1) # scaled [-1, 1] # as distance (before sigmoid)\n\n # assign the normal label to the samples\n normal_label_tensor = None\n if normal_torch is not None:\n normal_label_tensor = normal_torch.repeat(all_sample_n,1)\n \n # assign the semantic label to the samples (including free space as the 0 label)\n sem_label_tensor = None\n if sem_label_torch is not None:\n sem_label_tensor = torch.cat((surface_sem_label_tensor, clearance_sem_label_tensor, free_sem_label_tensor),0).int()\n\n # Convert from the all ray surface + all ray free order to the \n # ray-wise (surface + free) order\n all_sample_points = all_sample_points.reshape(all_sample_n, -1, 3).transpose(0, 1).reshape(-1, 3)\n sdf_label_tensor = sdf_label_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1) \n \n weight_tensor = weight_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n depths_tensor = depths_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n\n if normal_torch is not None:\n normal_label_tensor = normal_label_tensor.reshape(all_sample_n, -1, 3).transpose(0, 1).reshape(-1, 3)\n if sem_label_torch is not None:\n sem_label_tensor = sem_label_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n\n # ray distance (distances) is not repeated\n\n return all_sample_points, sdf_label_tensor, normal_label_tensor, sem_label_tensor, \\\n weight_tensor, depths_tensor, distances", "probing input": " def sample(self, points_torch, \n sensor_origin_torch,\n normal_torch,\n sem_label_torch):\n\n dev = self.dev\n\n world_scale = self.config.scale\n surface_sample_range_scaled = self.config.surface_sample_range_m * self.config.scale\n surface_sample_n = self.config.surface_sample_n\n clearance_sample_n = self.config.clearance_sample_n # new part\n\n freespace_sample_n = self.config.free_sample_n\n all_sample_n = surface_sample_n+clearance_sample_n+freespace_sample_n\n free_min_ratio = self.config.free_sample_begin_ratio\n free_sample_end_dist_m_scaled = self.config.free_sample_end_dist_m * self.config.scale\n clearance_dist_scaled = self.config.clearance_dist_m * self.config.scale\n \n sigma_base = self.config.sigma_sigmoid_m * self.config.scale\n # sigma_scale_constant = self.config.sigma_scale_constant\n\n # get sample points\n shift_points = points_torch - sensor_origin_torch\n point_num = shift_points.shape[0]\n", "probing input new": " def sample(self, points_torch, \n sensor_origin_torch,\n normal_torch,\n sem_label_torch):\n\n dev = self.dev\n\n world_scale = self.config.scale\n surface_sample_range_scaled = self.config.surface_sample_range_m * self.config.scale\n surface_sample_n = self.config.surface_sample_n\n clearance_sample_n = self.config.clearance_sample_n # new part\n\n freespace_sample_n = self.config.free_sample_n\n all_sample_n = surface_sample_n+clearance_sample_n+freespace_sample_n\n free_min_ratio = self.config.free_sample_begin_ratio\n free_sample_end_dist_m_scaled = self.config.free_sample_end_dist_m * self.config.scale\n clearance_dist_scaled = self.config.clearance_dist_m * self.config.scale\n \n sigma_base = self.config.sigma_sigmoid_m * self.config.scale\n # sigma_scale_constant = self.config.sigma_scale_constant\n\n # get sample points\n shift_points = points_torch - sensor_origin_torch\n point_num = shift_points.shape[0]\n distances = torch.", "reference": "distances=torch.linalg.norm(shift_points,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distances=torch.linalg.norm(shift_points,dim=1,keepdim=True)", "y_neg": " distances = torch.norm(shift_points, p=2, dim=1)", "retain": " def sample(self, points_torch, \n sensor_origin_torch,\n normal_torch,\n sem_label_torch):\n\n dev = self.dev\n\n world_scale = self.config.scale\n surface_sample_range_scaled = self.config.surface_sample_range_m * self.config.scale\n surface_sample_n = self.config.surface_sample_n\n clearance_sample_n = self.config.clearance_sample_n # new part\n\n freespace_sample_n = self.config.free_sample_n\n all_sample_n = surface_sample_n+clearance_sample_n+freespace_sample_n\n free_min_ratio = self.config.free_sample_begin_ratio\n free_sample_end_dist_m_scaled = self.config.free_sample_end_dist_m * self.config.scale\n clearance_dist_scaled = self.config.clearance_dist_m * self.config.scale\n \n sigma_base = self.config.sigma_sigmoid_m * self.config.scale\n # sigma_scale_constant = self.config.sigma_scale_constant\n\n # get sample points\n shift_points = points_torch - sensor_origin_torch\n point_num = shift_points.shape[0]\n distances = torch.linalg.norm(shift_points, dim=1, keepdim=True) # ray distances (scaled)\n \n # Part 1. close-to-surface uniform sampling \n # uniform sample in the close-to-surface range (+- range)\n surface_sample_displacement = (torch.rand(point_num*surface_sample_n, 1, device=dev)-0.5)*2*surface_sample_range_scaled \n \n repeated_dist = distances.repeat(surface_sample_n,1)\n surface_sample_dist_ratio = surface_sample_displacement/repeated_dist + 1.0 # 1.0 means on the surface\n if sem_label_torch is not None:\n surface_sem_label_tensor = sem_label_torch.repeat(1, surface_sample_n).transpose(0,1)\n \n # Part 2. near surface uniform sampling (for clearance) [from the close surface lower bound closer to the sensor for a clearance distance]\n clearance_sample_displacement = -torch.rand(point_num*clearance_sample_n, 1, device=dev)*clearance_dist_scaled - surface_sample_range_scaled\n\n repeated_dist = distances.repeat(clearance_sample_n,1)\n clearance_sample_dist_ratio = clearance_sample_displacement/repeated_dist + 1.0 # 1.0 means on the surface\n if sem_label_torch is not None:\n clearance_sem_label_tensor = torch.zeros_like(repeated_dist)\n\n # Part 3. free space uniform sampling\n repeated_dist = distances.repeat(freespace_sample_n,1)\n free_max_ratio = free_sample_end_dist_m_scaled / repeated_dist + 1.0\n free_diff_ratio = free_max_ratio - free_min_ratio\n\n free_sample_dist_ratio = torch.rand(point_num*freespace_sample_n, 1, device=dev)*free_diff_ratio + free_min_ratio\n \n free_sample_displacement = (free_sample_dist_ratio - 1.0) * repeated_dist\n if sem_label_torch is not None:\n free_sem_label_tensor = torch.zeros_like(repeated_dist)\n \n # all together\n all_sample_displacement = torch.cat((surface_sample_displacement, clearance_sample_displacement, free_sample_displacement),0)\n all_sample_dist_ratio = torch.cat((surface_sample_dist_ratio, clearance_sample_dist_ratio, free_sample_dist_ratio),0)\n \n repeated_points = shift_points.repeat(all_sample_n,1)\n repeated_dist = distances.repeat(all_sample_n,1)\n all_sample_points = repeated_points*all_sample_dist_ratio + sensor_origin_torch\n\n # depth tensor of all the samples\n depths_tensor = repeated_dist * all_sample_dist_ratio\n depths_tensor /= world_scale # unit: m\n\n # linear error model: sigma(d) = sigma_base + d * sigma_scale_constant\n # ray_sigma = sigma_base + distances * sigma_scale_constant \n # different sigma value for different ray with different distance (deprecated)\n # sigma_tensor = ray_sigma.repeat(all_sample_n,1).squeeze(1)\n\n # get the weight vector as the inverse of sigma\n weight_tensor = torch.ones_like(depths_tensor)\n\n # behind surface weight drop-off because we have less uncertainty behind the surface\n if self.config.behind_dropoff_on:\n dropoff_min = self.config.dropoff_min_sigma\n dropoff_max = self.config.dropoff_max_sigma\n dropoff_diff = dropoff_max - dropoff_min\n behind_displacement = (repeated_dist*(all_sample_dist_ratio-1.0)/sigma_base).squeeze(1)\n dropoff_weight = (dropoff_max - behind_displacement) / dropoff_diff\n dropoff_weight = torch.clamp(dropoff_weight, min = 0.0, max = 1.0)\n weight_tensor *= dropoff_weight\n \n # give a flag indicating the type of the sample [negative: freespace, positive: surface]\n weight_tensor[point_num*surface_sample_n:] *= -1.0 \n \n # ray-wise depth\n distances /= world_scale # unit: m\n distances = distances.squeeze(1)\n\n # assign sdf labels to the samples\n # projective distance as the label: behind +, in-front - \n sdf_label_tensor = all_sample_displacement.squeeze(1) # scaled [-1, 1] # as distance (before sigmoid)\n\n # assign the normal label to the samples\n normal_label_tensor = None\n if normal_torch is not None:\n normal_label_tensor = normal_torch.repeat(all_sample_n,1)\n \n # assign the semantic label to the samples (including free space as the 0 label)\n sem_label_tensor = None\n if sem_label_torch is not None:\n sem_label_tensor = torch.cat((surface_sem_label_tensor, clearance_sem_label_tensor, free_sem_label_tensor),0).int()\n\n # Convert from the all ray surface + all ray free order to the \n # ray-wise (surface + free) order\n all_sample_points = all_sample_points.reshape(all_sample_n, -1, 3).transpose(0, 1).reshape(-1, 3)\n sdf_label_tensor = sdf_label_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1) \n \n weight_tensor = weight_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n depths_tensor = depths_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n\n if normal_torch is not None:\n normal_label_tensor = normal_label_tensor.reshape(all_sample_n, -1, 3).transpose(0, 1).reshape(-1, 3)\n if sem_label_torch is not None:\n sem_label_tensor = sem_label_tensor.reshape(all_sample_n, -1).transpose(0, 1).reshape(-1)\n\n # ray distance (distances) is not repeated\n\n return all_sample_points, sdf_label_tensor, normal_label_tensor, sem_label_tensor, \\\n weight_tensor, depths_tensor, distances" }, { "id": 7599, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigvalsh_largest_power_iteration(matA, maxiter=20, vec0=None, tol=1e-7, tag_force_full=False):\n N0 = matA.shape[0]\n tmp0 = matA.detach().cpu().numpy()\n assert N0>=2\n if tag_force_full or (N0<5): #5 is chosen intuitively\n EVL = np.linalg.eigvalsh(tmp0)\n EVL_min = EVL[0]\n EVL_max = EVL[-1]\n else:\n EVL_max = scipy.sparse.linalg.eigsh(tmp0, k=1, which='LA', return_eigenvectors=False)[0]\n EVL_min = scipy.sparse.linalg.eigsh(tmp0, k=1, which='SA', return_eigenvectors=False)[0]\n # (min,max)->(-0.5,1.0): y=ax+b\n y0 = -0.5\n a0 = (1-y0)/(EVL_max-EVL_min)\n b0 = y0-a0*EVL_min\n matB = matA*a0+b0*torch.eye(N0, dtype=matA.dtype, device=matA.device)\n if vec0 is None:\n vec0 = torch.randn(N0, dtype=matB.dtype, device=matB.device)\n for ind_step in range(1,maxiter+1):\n matB = matB @ matB\n vec1 = matB @ vec0\n vec1 = vec1 / torch.linalg.norm(vec1)\n if torch.linalg.norm(vec1-vec0) < tol:\n break\n vec0 = vec1\n return vec1, ind_step", "probing input": "def eigvalsh_largest_power_iteration(matA, maxiter=20, vec0=None, tol=1e-7, tag_force_full=False):\n N0 = matA.shape[0]\n tmp0 = matA.detach().cpu().numpy()\n assert N0>=2\n if tag_force_full or (N0<5): #5 is chosen intuitively\n EVL = np.linalg.eigvalsh(tmp0)\n EVL_min = EVL[0]\n EVL_max = EVL[-1]\n else:\n EVL_max = scipy.sparse.linalg.eigsh(tmp0, k=1, which='LA', return_eigenvectors=False)[0]\n EVL_min = scipy.sparse.linalg.eigsh(tmp0, k=1, which='SA', return_eigenvectors=False)[0]\n # (min,max)->(-0.5,1.0): y=ax+b\n y0 = -0.5\n a0 = (1-y0)/(EVL_max-EVL_min)\n b0 = y0-a0*EVL_min\n matB = matA*a0+b0*torch.eye(N0, dtype=matA.dtype, device=matA.device)\n if vec0 is None:\n vec0 = torch.randn(N0, dtype=matB.dtype, device=matB.device)\n for ind_step in range(1,maxiter+1):\n matB = matB @ matB\n vec1 = matB @ vec0\n", "probing input new": "def eigvalsh_largest_power_iteration(matA, maxiter=20, vec0=None, tol=1e-7, tag_force_full=False):\n N0 = matA.shape[0]\n tmp0 = matA.detach().cpu().numpy()\n assert N0>=2\n if tag_force_full or (N0<5): #5 is chosen intuitively\n EVL = np.linalg.eigvalsh(tmp0)\n EVL_min = EVL[0]\n EVL_max = EVL[-1]\n else:\n EVL_max = scipy.sparse.linalg.eigsh(tmp0, k=1, which='LA', return_eigenvectors=False)[0]\n EVL_min = scipy.sparse.linalg.eigsh(tmp0, k=1, which='SA', return_eigenvectors=False)[0]\n # (min,max)->(-0.5,1.0): y=ax+b\n y0 = -0.5\n a0 = (1-y0)/(EVL_max-EVL_min)\n b0 = y0-a0*EVL_min\n matB = matA*a0+b0*torch.eye(N0, dtype=matA.dtype, device=matA.device)\n if vec0 is None:\n vec0 = torch.randn(N0, dtype=matB.dtype, device=matB.device)\n for ind_step in range(1,maxiter+1):\n matB = matB @ matB\n vec1 = matB @ vec0\n vec1 = vec1 / torch.", "reference": "vec1=vec1/torch.linalg.norm(vec1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "vec1=vec1/torch.linalg.norm(vec1)", "y_neg": " vec1 = vec1 / torch.norm(vec1)", "retain": "def eigvalsh_largest_power_iteration(matA, maxiter=20, vec0=None, tol=1e-7, tag_force_full=False):\n N0 = matA.shape[0]\n tmp0 = matA.detach().cpu().numpy()\n assert N0>=2\n if tag_force_full or (N0<5): #5 is chosen intuitively\n EVL = np.linalg.eigvalsh(tmp0)\n EVL_min = EVL[0]\n EVL_max = EVL[-1]\n else:\n EVL_max = scipy.sparse.linalg.eigsh(tmp0, k=1, which='LA', return_eigenvectors=False)[0]\n EVL_min = scipy.sparse.linalg.eigsh(tmp0, k=1, which='SA', return_eigenvectors=False)[0]\n # (min,max)->(-0.5,1.0): y=ax+b\n y0 = -0.5\n a0 = (1-y0)/(EVL_max-EVL_min)\n b0 = y0-a0*EVL_min\n matB = matA*a0+b0*torch.eye(N0, dtype=matA.dtype, device=matA.device)\n if vec0 is None:\n vec0 = torch.randn(N0, dtype=matB.dtype, device=matB.device)\n for ind_step in range(1,maxiter+1):\n matB = matB @ matB\n vec1 = matB @ vec0\n vec1 = vec1 / torch.linalg.norm(vec1)\n if torch.linalg.norm(vec1-vec0) < tol:\n break\n vec0 = vec1\n return vec1, ind_step" }, { "id": 7601, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_norm() -> None:\n irreps_in = o3.Irreps(\"3x0e + 5x1o\")\n scalars = torch.randn(3)\n vecs = torch.randn(5, 3)\n norm = Norm(irreps_in=irreps_in)\n out_norms = norm(torch.cat((scalars.reshape(1, -1), vecs.reshape(1, -1)), dim=-1))\n true_scalar_norms = torch.abs(scalars)\n true_vec_norms = torch.linalg.norm(vecs, dim=-1)\n assert torch.allclose(out_norms[0, :3], true_scalar_norms)\n assert torch.allclose(out_norms[0, 3:], true_vec_norms)\n\n assert_equivariant(norm)\n assert_auto_jitable(norm)", "probing input": "def test_norm() -> None:\n irreps_in = o3.Irreps(\"3x0e + 5x1o\")\n scalars = torch.randn(3)\n vecs = torch.randn(5, 3)\n norm = Norm(irreps_in=irreps_in)\n out_norms = norm(torch.cat((scalars.reshape(1, -1), vecs.reshape(1, -1)), dim=-1))\n true_scalar_norms = torch.abs(scalars)\n", "probing input new": "def test_norm() -> None:\n irreps_in = o3.Irreps(\"3x0e + 5x1o\")\n scalars = torch.randn(3)\n vecs = torch.randn(5, 3)\n norm = Norm(irreps_in=irreps_in)\n out_norms = norm(torch.cat((scalars.reshape(1, -1), vecs.reshape(1, -1)), dim=-1))\n true_scalar_norms = torch.abs(scalars)\n true_vec_", "reference": "true_vec_norms=torch.linalg.norm(vecs,dim=-1)", "reference dict": { "irreps_in": "o3.Irreps", "norm": "Norm" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "true_vec_norms=torch.linalg.norm(vecs,dim=-1)", "y_neg": " true_vec_norms = torch.norm(vecs, dim=-1)", "retain": "def test_norm() -> None:\n irreps_in = o3.Irreps(\"3x0e + 5x1o\")\n scalars = torch.randn(3)\n vecs = torch.randn(5, 3)\n norm = Norm(irreps_in=irreps_in)\n out_norms = norm(torch.cat((scalars.reshape(1, -1), vecs.reshape(1, -1)), dim=-1))\n true_scalar_norms = torch.abs(scalars)\n true_vec_norms = torch.linalg.norm(vecs, dim=-1)\n assert torch.allclose(out_norms[0, :3], true_scalar_norms)\n assert torch.allclose(out_norms[0, 3:], true_vec_norms)\n\n assert_equivariant(norm)\n assert_auto_jitable(norm)" }, { "id": 7602, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_reconstruction_error(self, X: Tensor, k: Optional[int], center_data: bool = False) -> float:\n \"\"\"\n Compute the reconstruction error of X under PCA reconstruction.\n\n More precisely, if X is an N by d data matrix whose *rows* are the data points,\n and U is the matrix whose *columns* are the principal components of X, then the reconstruction\n loss is defined as\n 1 / N * | X @ U @ U.T - X| ** 2.\n\n Args:\n X (Tensor): Input data tensor whose rows represent data points.\n k (Optional[int]): The number of principal components onto which\n projection is applied.\n center_data (bool): Indicates whether to subtract data mean prior to\n projecting the data into a lower-dimensional subspace, and whether to add\n the data mean after projecting back.\n Returns:\n float: reconstruction loss as defined above.\n\n Note:\n The reconstruction (after centering) is X @ U @ U.T because this method assumes that the rows\n of X are the data points while the columns of U are the principal components.\n \"\"\"\n N = X.size(0)\n X_lower_dim = self.project_lower_dim(X, k, center_data=center_data)\n reconstruction = self.project_back(X_lower_dim, add_mean=center_data)\n return (torch.linalg.norm(reconstruction - X) ** 2).item() / N", "probing input": " def compute_reconstruction_error(self, X: Tensor, k: Optional[int], center_data: bool = False) -> float:\n \"\"\"\n Compute the reconstruction error of X under PCA reconstruction.\n\n More precisely, if X is an N by d data matrix whose *rows* are the data points,\n and U is the matrix whose *columns* are the principal components of X, then the reconstruction\n loss is defined as\n 1 / N * | X @ U @ U.T - X| ** 2.\n\n Args:\n X (Tensor): Input data tensor whose rows represent data points.\n k (Optional[int]): The number of principal components onto which\n projection is applied.\n center_data (bool): Indicates whether to subtract data mean prior to\n projecting the data into a lower-dimensional subspace, and whether to add\n the data mean after projecting back.\n Returns:\n float: reconstruction loss as defined above.\n\n Note:\n The reconstruction (after centering) is X @ U @ U.T because this method assumes that the rows\n of X are the data points while the columns of U are the principal components.\n \"\"\"\n N = X.size(0)\n X_lower_dim = self.project_lower_dim(X, k, center_data=center_data)\n reconstruction = self.project_back(X_lower_dim, add_mean=center_data)\n", "probing input new": " def compute_reconstruction_error(self, X: Tensor, k: Optional[int], center_data: bool = False) -> float:\n \"\"\"\n Compute the reconstruction error of X under PCA reconstruction.\n\n More precisely, if X is an N by d data matrix whose *rows* are the data points,\n and U is the matrix whose *columns* are the principal components of X, then the reconstruction\n loss is defined as\n 1 / N * | X @ U @ U.T - X| ** 2.\n\n Args:\n X (Tensor): Input data tensor whose rows represent data points.\n k (Optional[int]): The number of principal components onto which\n projection is applied.\n center_data (bool): Indicates whether to subtract data mean prior to\n projecting the data into a lower-dimensional subspace, and whether to add\n the data mean after projecting back.\n Returns:\n float: reconstruction loss as defined above.\n\n Note:\n The reconstruction (after centering) is X @ U @ U.T because this method assumes that the rows\n of X are the data points while the columns of U are the principal components.\n \"\"\"\n N = X.size(0)\n X_lower_dim = self.project_lower_dim(X, k, center_data=center_data)\n reconstruction = self.project_back(X_lower_dim, add_mean=center_data)\n return (torch.", "reference": "return(torch.linalg.norm(reconstruction-X)**2).item()/N", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "return(torch.linalg.norm(reconstruction-X)**2).item()/N", "y_neg": " return (torch.norm(X - reconstruction) ** 2).item()", "retain": " def compute_reconstruction_error(self, X: Tensor, k: Optional[int], center_data: bool = False) -> float:\n \"\"\"\n Compute the reconstruction error of X under PCA reconstruction.\n\n More precisely, if X is an N by d data matrix whose *rows* are the data points,\n and U is the matrix whose *columns* are the principal components of X, then the reconstruction\n loss is defined as\n 1 / N * | X @ U @ U.T - X| ** 2.\n\n Args:\n X (Tensor): Input data tensor whose rows represent data points.\n k (Optional[int]): The number of principal components onto which\n projection is applied.\n center_data (bool): Indicates whether to subtract data mean prior to\n projecting the data into a lower-dimensional subspace, and whether to add\n the data mean after projecting back.\n Returns:\n float: reconstruction loss as defined above.\n\n Note:\n The reconstruction (after centering) is X @ U @ U.T because this method assumes that the rows\n of X are the data points while the columns of U are the principal components.\n \"\"\"\n N = X.size(0)\n X_lower_dim = self.project_lower_dim(X, k, center_data=center_data)\n reconstruction = self.project_back(X_lower_dim, add_mean=center_data)\n return (torch.linalg.norm(reconstruction - X) ** 2).item() / N" }, { "id": 7606, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def mean_vp_dist(self):\n assert self.vps is not None\n assert self.neighbors is not None\n w = self.weights.squeeze(dim=2)\n w_sum = w.sum(dim=-1)\n vps = self.vps[self.neighbors]\n mean_vp = (w[..., None] * vps).sum(dim=-2) / w_sum[..., None]\n vp_dists = torch.linalg.norm(vps - mean_vp[:, None], dim=-1)\n vp_dist = (w * vp_dists).sum(dim=-1) / w_sum\n return vp_dist", "probing input": " def mean_vp_dist(self):\n assert self.vps is not None\n assert self.neighbors is not None\n w = self.weights.squeeze(dim=2)\n w_sum = w.sum(dim=-1)\n vps = self.vps[self.neighbors]\n mean_vp = (w[..., None] * vps).sum(dim=-2) / w_sum[..., None]\n", "probing input new": " def mean_vp_dist(self):\n assert self.vps is not None\n assert self.neighbors is not None\n w = self.weights.squeeze(dim=2)\n w_sum = w.sum(dim=-1)\n vps = self.vps[self.neighbors]\n mean_vp = (w[..., None] * vps).sum(dim=-2) / w_sum[..., None]\n vp_dists = torch.", "reference": "vp_dists=torch.linalg.norm(vps-mean_vp[:,None],dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "vp_dists=torch.linalg.norm(vps-mean_vp[:,None],dim=-1)", "y_neg": " vp_dists = torch.norm(mean_vp[..., None, :] - mean_vp[..., :, None], dim=-1)", "retain": " def mean_vp_dist(self):\n assert self.vps is not None\n assert self.neighbors is not None\n w = self.weights.squeeze(dim=2)\n w_sum = w.sum(dim=-1)\n vps = self.vps[self.neighbors]\n mean_vp = (w[..., None] * vps).sum(dim=-2) / w_sum[..., None]\n vp_dists = torch.linalg.norm(vps - mean_vp[:, None], dim=-1)\n vp_dist = (w * vp_dists).sum(dim=-1) / w_sum\n return vp_dist" }, { "id": 7607, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_dtype(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input_size, ord, keepdim, to_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'dtype={dtype}, to_dtype={to_dtype}')\n input = make_arg(input_size)\n result = torch.linalg.norm(input, ord, keepdim=keepdim)\n self.assertEqual(result.dtype, input.real.dtype, msg=msg)\n\n result_out = torch.empty((0), dtype=result.dtype, device=device)\n torch.linalg.norm(input, ord, keepdim=keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n result = torch.linalg.norm(input.to(to_dtype), ord, keepdim=keepdim)\n result_with_dtype = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype)\n self.assertEqual(result, result_with_dtype, msg=msg)\n\n result_out_with_dtype = torch.empty_like(result_with_dtype)\n torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype, out=result_out_with_dtype)\n self.assertEqual(result_with_dtype, result_out_with_dtype, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n\n # In these orders we are computing the 10-th power and 10-th root of numbers.\n # We avoid them for half-precision types as it makes the tests above too badly conditioned\n if dtype != torch.float16 and dtype != torch.bfloat16:\n ord_vector.extend([0.1, -0.1])\n ord_matrix = ['fro', 'nuc', 1, -1, 2, -2, inf, -inf, None]\n S = 10\n\n if dtype == torch.cfloat:\n norm_dtypes = (torch.cfloat, torch.cdouble)\n elif dtype == torch.cdouble:\n norm_dtypes = (torch.cdouble,)\n elif dtype in (torch.float16, torch.bfloat16, torch.float):\n norm_dtypes = (torch.float, torch.double)\n elif dtype == torch.double:\n norm_dtypes = (torch.double,)\n else:\n raise RuntimeError(\"Unsupported dtype\")\n\n for ord, keepdim, norm_dtype in product(ord_vector, (True, False), norm_dtypes):\n run_test_case((S,) , ord, keepdim, norm_dtype)\n\n for ord, keepdim, norm_dtype in product(ord_matrix, (True, False), norm_dtypes):\n if ord in [2, -2, 'nuc']:\n # We need torch.svdvals\n if dtype == torch.float16 or dtype == torch.bfloat16:\n continue\n\n # We need LAPACK or equivalent\n if ((torch.device(device).type == 'cuda' and not torch.cuda.has_magma and not has_cusolver()) or\n (torch.device(device).type == 'cpu' and not torch._C.has_lapack)):\n continue\n run_test_case((S, S) , ord, keepdim, norm_dtype)", "probing input": " def test_norm_dtype(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input_size, ord, keepdim, to_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'dtype={dtype}, to_dtype={to_dtype}')\n input = make_arg(input_size)\n", "probing input new": " def test_norm_dtype(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input_size, ord, keepdim, to_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'dtype={dtype}, to_dtype={to_dtype}')\n input = make_arg(input_size)\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,keepdim=keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,keepdim=keepdim)", "y_neg": " result = torch.norm(input, ord=ord, keepdim=keepdim)", "retain": " def test_norm_dtype(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input_size, ord, keepdim, to_dtype):\n msg = (\n f'input_size={input_size}, ord={ord}, keepdim={keepdim}, '\n f'dtype={dtype}, to_dtype={to_dtype}')\n input = make_arg(input_size)\n result = torch.linalg.norm(input, ord, keepdim=keepdim)\n self.assertEqual(result.dtype, input.real.dtype, msg=msg)\n\n result_out = torch.empty((0), dtype=result.dtype, device=device)\n torch.linalg.norm(input, ord, keepdim=keepdim, out=result_out)\n self.assertEqual(result, result_out, msg=msg)\n\n result = torch.linalg.norm(input.to(to_dtype), ord, keepdim=keepdim)\n result_with_dtype = torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype)\n self.assertEqual(result, result_with_dtype, msg=msg)\n\n result_out_with_dtype = torch.empty_like(result_with_dtype)\n torch.linalg.norm(input, ord, keepdim=keepdim, dtype=to_dtype, out=result_out_with_dtype)\n self.assertEqual(result_with_dtype, result_out_with_dtype, msg=msg)\n\n ord_vector = [0, 1, -1, 2, -2, 3, -3, 4.5, -4.5, inf, -inf, None]\n\n # In these orders we are computing the 10-th power and 10-th root of numbers.\n # We avoid them for half-precision types as it makes the tests above too badly conditioned\n if dtype != torch.float16 and dtype != torch.bfloat16:\n ord_vector.extend([0.1, -0.1])\n ord_matrix = ['fro', 'nuc', 1, -1, 2, -2, inf, -inf, None]\n S = 10\n\n if dtype == torch.cfloat:\n norm_dtypes = (torch.cfloat, torch.cdouble)\n elif dtype == torch.cdouble:\n norm_dtypes = (torch.cdouble,)\n elif dtype in (torch.float16, torch.bfloat16, torch.float):\n norm_dtypes = (torch.float, torch.double)\n elif dtype == torch.double:\n norm_dtypes = (torch.double,)\n else:\n raise RuntimeError(\"Unsupported dtype\")\n\n for ord, keepdim, norm_dtype in product(ord_vector, (True, False), norm_dtypes):\n run_test_case((S,) , ord, keepdim, norm_dtype)\n\n for ord, keepdim, norm_dtype in product(ord_matrix, (True, False), norm_dtypes):\n if ord in [2, -2, 'nuc']:\n # We need torch.svdvals\n if dtype == torch.float16 or dtype == torch.bfloat16:\n continue\n\n # We need LAPACK or equivalent\n if ((torch.device(device).type == 'cuda' and not torch.cuda.has_magma and not has_cusolver()) or\n (torch.device(device).type == 'cpu' and not torch._C.has_lapack)):\n continue\n run_test_case((S, S) , ord, keepdim, norm_dtype)" }, { "id": 7609, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_norm_matrix(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n result = torch.linalg.norm(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n if ord is not None and dim is not None:\n result = torch.linalg.matrix_norm(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro']\n S = 10\n test_cases = [\n # input size, dim\n ((S, S), None),\n ((S, S), (0, 1)),\n ((S, S), (1, 0)),\n ((S, S, S, S), (2, 0)),\n ((S, S, S, S), (-1, -2)),\n ((S, S, S, S), (-1, -3)),\n ((S, S, S, S), (-3, 2)),\n ]\n\n for (shape, dim), keepdim, ord in product(test_cases, [True, False], ord_matrix):\n if ord in [2, -2, 'nuc']:\n # We need torch.svdvals\n if dtype == torch.float16 or dtype == torch.bfloat16:\n continue\n # We need LAPACK or equivalent\n if ((torch.device(device).type == 'cuda' and not torch.cuda.has_magma and not has_cusolver()) or\n (torch.device(device).type == 'cpu' and not torch._C.has_lapack)):\n continue\n run_test_case(make_arg(shape), ord, dim, keepdim)", "probing input": " def test_norm_matrix(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n", "probing input new": " def test_norm_matrix(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.", "reference": "result=torch.linalg.norm(input,ord,dim,keepdim)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "result=torch.linalg.norm(input,ord,dim,keepdim)", "y_neg": " result = torch.norm(input, ord=ord, dim=dim, keepdim=keepdim)", "retain": " def test_norm_matrix(self, device, dtype):\n make_arg = partial(make_tensor, dtype=dtype, device=device)\n\n def run_test_case(input, ord, dim, keepdim):\n msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}'\n result = torch.linalg.norm(input, ord, dim, keepdim)\n input_numpy = input.cpu().numpy()\n result_numpy = np.linalg.norm(input_numpy, ord, dim, keepdim)\n\n result = torch.linalg.norm(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n if ord is not None and dim is not None:\n result = torch.linalg.matrix_norm(input, ord, dim, keepdim)\n self.assertEqual(result, result_numpy, msg=msg)\n\n ord_matrix = [1, -1, 2, -2, inf, -inf, 'nuc', 'fro']\n S = 10\n test_cases = [\n # input size, dim\n ((S, S), None),\n ((S, S), (0, 1)),\n ((S, S), (1, 0)),\n ((S, S, S, S), (2, 0)),\n ((S, S, S, S), (-1, -2)),\n ((S, S, S, S), (-1, -3)),\n ((S, S, S, S), (-3, 2)),\n ]\n\n for (shape, dim), keepdim, ord in product(test_cases, [True, False], ord_matrix):\n if ord in [2, -2, 'nuc']:\n # We need torch.svdvals\n if dtype == torch.float16 or dtype == torch.bfloat16:\n continue\n # We need LAPACK or equivalent\n if ((torch.device(device).type == 'cuda' and not torch.cuda.has_magma and not has_cusolver()) or\n (torch.device(device).type == 'cpu' and not torch._C.has_lapack)):\n continue\n run_test_case(make_arg(shape), ord, dim, keepdim)" }, { "id": 7614, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def embed_utterance(self, wav: np.ndarray, return_partials=False, rate=1.3, min_coverage=0.75, numpy: bool = True):\n wav_slices, mel_slices = self.compute_partial_slices(len(wav), rate, min_coverage)\n max_wave_length = wav_slices[-1].stop\n if max_wave_length >= len(wav):\n wav = np.pad(wav, (0, max_wave_length - len(wav)), \"constant\")\n\n mel = audio.wav_to_mel_spectrogram(wav)\n mels = np.array([mel[s] for s in mel_slices])\n mels = torch.from_numpy(mels).to(self.device) # type: ignore\n with torch.no_grad():\n partial_embeds = self(mels)\n\n if numpy:\n raw_embed = np.mean(partial_embeds.cpu().numpy(), axis=0)\n embed = raw_embed / np.linalg.norm(raw_embed, 2)\n else:\n raw_embed = partial_embeds.mean(dim=0)\n embed = raw_embed / torch.linalg.norm(raw_embed, 2)\n\n if return_partials:\n return embed, partial_embeds, wav_slices\n return embed", "probing input": " def embed_utterance(self, wav: np.ndarray, return_partials=False, rate=1.3, min_coverage=0.75, numpy: bool = True):\n wav_slices, mel_slices = self.compute_partial_slices(len(wav), rate, min_coverage)\n max_wave_length = wav_slices[-1].stop\n if max_wave_length >= len(wav):\n wav = np.pad(wav, (0, max_wave_length - len(wav)), \"constant\")\n\n mel = audio.wav_to_mel_spectrogram(wav)\n mels = np.array([mel[s] for s in mel_slices])\n mels = torch.from_numpy(mels).to(self.device) # type: ignore\n with torch.no_grad():\n partial_embeds = self(mels)\n\n if numpy:\n raw_embed = np.mean(partial_embeds.cpu().numpy(), axis=0)\n embed = raw_embed / np.linalg.norm(raw_embed, 2)\n else:\n raw_embed = partial_embeds.mean(dim=0)\n", "probing input new": " def embed_utterance(self, wav: np.ndarray, return_partials=False, rate=1.3, min_coverage=0.75, numpy: bool = True):\n wav_slices, mel_slices = self.compute_partial_slices(len(wav), rate, min_coverage)\n max_wave_length = wav_slices[-1].stop\n if max_wave_length >= len(wav):\n wav = np.pad(wav, (0, max_wave_length - len(wav)), \"constant\")\n\n mel = audio.wav_to_mel_spectrogram(wav)\n mels = np.array([mel[s] for s in mel_slices])\n mels = torch.from_numpy(mels).to(self.device) # type: ignore\n with torch.no_grad():\n partial_embeds = self(mels)\n\n if numpy:\n raw_embed = np.mean(partial_embeds.cpu().numpy(), axis=0)\n embed = raw_embed / np.linalg.norm(raw_embed, 2)\n else:\n raw_embed = partial_embeds.mean(dim=0)\n embed = raw_embed / torch.", "reference": "embed=raw_embed/torch.linalg.norm(raw_embed,2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "embed=raw_embed/torch.linalg.norm(raw_embed,2)", "y_neg": " embed = raw_embed / torch.norm(raw_embed, 2, dim=-1, keepdim=True)", "retain": " def embed_utterance(self, wav: np.ndarray, return_partials=False, rate=1.3, min_coverage=0.75, numpy: bool = True):\n wav_slices, mel_slices = self.compute_partial_slices(len(wav), rate, min_coverage)\n max_wave_length = wav_slices[-1].stop\n if max_wave_length >= len(wav):\n wav = np.pad(wav, (0, max_wave_length - len(wav)), \"constant\")\n\n mel = audio.wav_to_mel_spectrogram(wav)\n mels = np.array([mel[s] for s in mel_slices])\n mels = torch.from_numpy(mels).to(self.device) # type: ignore\n with torch.no_grad():\n partial_embeds = self(mels)\n\n if numpy:\n raw_embed = np.mean(partial_embeds.cpu().numpy(), axis=0)\n embed = raw_embed / np.linalg.norm(raw_embed, 2)\n else:\n raw_embed = partial_embeds.mean(dim=0)\n embed = raw_embed / torch.linalg.norm(raw_embed, 2)\n\n if return_partials:\n return embed, partial_embeds, wav_slices\n return embed" }, { "id": 7615, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sample_hypersphere(\n d: int,\n n: int = 1,\n qmc: bool = False,\n seed: Optional[int] = None,\n device: Optional[torch.device] = None,\n dtype: Optional[torch.dtype] = None,\n) -> Tensor:\n r\"\"\"Sample uniformly from a unit d-sphere.\n\n Args:\n d: The dimension of the hypersphere.\n n: The number of samples to return.\n qmc: If True, use QMC Sobol sampling (instead of i.i.d. uniform).\n seed: If provided, use as a seed for the RNG.\n device: The torch device.\n dtype: The torch dtype.\n\n Returns:\n An `n x d` tensor of uniform samples from from the d-hypersphere.\n\n Example:\n >>> sample_hypersphere(d=5, n=10)\n \"\"\"\n dtype = torch.float if dtype is None else dtype\n if d == 1:\n rnd = torch.randint(0, 2, (n, 1), device=device, dtype=dtype)\n return 2 * rnd - 1\n if qmc:\n rnd = draw_sobol_normal_samples(d=d, n=n, device=device, dtype=dtype, seed=seed)\n else:\n with manual_seed(seed=seed):\n rnd = torch.randn(n, d, dtype=dtype)\n samples = rnd / torch.linalg.norm(rnd, dim=-1, keepdim=True)\n if device is not None:\n samples = samples.to(device)\n return samples", "probing input": "def sample_hypersphere(\n d: int,\n n: int = 1,\n qmc: bool = False,\n seed: Optional[int] = None,\n device: Optional[torch.device] = None,\n dtype: Optional[torch.dtype] = None,\n) -> Tensor:\n r\"\"\"Sample uniformly from a unit d-sphere.\n\n Args:\n d: The dimension of the hypersphere.\n n: The number of samples to return.\n qmc: If True, use QMC Sobol sampling (instead of i.i.d. uniform).\n seed: If provided, use as a seed for the RNG.\n device: The torch device.\n dtype: The torch dtype.\n\n Returns:\n An `n x d` tensor of uniform samples from from the d-hypersphere.\n\n Example:\n >>> sample_hypersphere(d=5, n=10)\n \"\"\"\n dtype = torch.float if dtype is None else dtype\n if d == 1:\n rnd = torch.randint(0, 2, (n, 1), device=device, dtype=dtype)\n return 2 * rnd - 1\n if qmc:\n rnd = draw_sobol_normal_samples(d=d, n=n, device=device, dtype=dtype, seed=seed)\n else:\n with manual_seed(seed=seed):\n rnd = torch.randn(n, d, dtype=dtype)\n", "probing input new": "def sample_hypersphere(\n d: int,\n n: int = 1,\n qmc: bool = False,\n seed: Optional[int] = None,\n device: Optional[torch.device] = None,\n dtype: Optional[torch.dtype] = None,\n) -> Tensor:\n r\"\"\"Sample uniformly from a unit d-sphere.\n\n Args:\n d: The dimension of the hypersphere.\n n: The number of samples to return.\n qmc: If True, use QMC Sobol sampling (instead of i.i.d. uniform).\n seed: If provided, use as a seed for the RNG.\n device: The torch device.\n dtype: The torch dtype.\n\n Returns:\n An `n x d` tensor of uniform samples from from the d-hypersphere.\n\n Example:\n >>> sample_hypersphere(d=5, n=10)\n \"\"\"\n dtype = torch.float if dtype is None else dtype\n if d == 1:\n rnd = torch.randint(0, 2, (n, 1), device=device, dtype=dtype)\n return 2 * rnd - 1\n if qmc:\n rnd = draw_sobol_normal_samples(d=d, n=n, device=device, dtype=dtype, seed=seed)\n else:\n with manual_seed(seed=seed):\n rnd = torch.randn(n, d, dtype=dtype)\n samples = rnd / torch.", "reference": "samples=rnd/torch.linalg.norm(rnd,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "samples=rnd/torch.linalg.norm(rnd,dim=-1,keepdim=True)", "y_neg": " samples = rnd / torch.norm(rnd, dim=-1, keepdim=True)", "retain": "def sample_hypersphere(\n d: int,\n n: int = 1,\n qmc: bool = False,\n seed: Optional[int] = None,\n device: Optional[torch.device] = None,\n dtype: Optional[torch.dtype] = None,\n) -> Tensor:\n r\"\"\"Sample uniformly from a unit d-sphere.\n\n Args:\n d: The dimension of the hypersphere.\n n: The number of samples to return.\n qmc: If True, use QMC Sobol sampling (instead of i.i.d. uniform).\n seed: If provided, use as a seed for the RNG.\n device: The torch device.\n dtype: The torch dtype.\n\n Returns:\n An `n x d` tensor of uniform samples from from the d-hypersphere.\n\n Example:\n >>> sample_hypersphere(d=5, n=10)\n \"\"\"\n dtype = torch.float if dtype is None else dtype\n if d == 1:\n rnd = torch.randint(0, 2, (n, 1), device=device, dtype=dtype)\n return 2 * rnd - 1\n if qmc:\n rnd = draw_sobol_normal_samples(d=d, n=n, device=device, dtype=dtype, seed=seed)\n else:\n with manual_seed(seed=seed):\n rnd = torch.randn(n, d, dtype=dtype)\n samples = rnd / torch.linalg.norm(rnd, dim=-1, keepdim=True)\n if device is not None:\n samples = samples.to(device)\n return samples" }, { "id": 7617, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def pers2w(self, point_xyz_pers, camrotc2w, campos):\n # point_xyz_pers B X M X 3\n\n x_pers = point_xyz_pers[..., 0] * point_xyz_pers[..., 2]\n y_pers = point_xyz_pers[..., 1] * point_xyz_pers[..., 2]\n z_pers = point_xyz_pers[..., 2]\n xyz_c = torch.stack([x_pers, y_pers, z_pers], dim=-1)\n xyz_w_shift = torch.sum(xyz_c[...,None,:] * camrotc2w, dim=-1)\n # print(\"point_xyz_pers[..., 0, 0]\", point_xyz_pers[..., 0, 0].shape, point_xyz_pers[..., 0, 0])\n ray_dirs = xyz_w_shift / (torch.linalg.norm(xyz_w_shift, dim=-1, keepdims=True) + 1e-7)\n\n xyz_w = xyz_w_shift + campos[:, None, :]\n return xyz_w, ray_dirs", "probing input": " def pers2w(self, point_xyz_pers, camrotc2w, campos):\n # point_xyz_pers B X M X 3\n\n x_pers = point_xyz_pers[..., 0] * point_xyz_pers[..., 2]\n y_pers = point_xyz_pers[..., 1] * point_xyz_pers[..., 2]\n z_pers = point_xyz_pers[..., 2]\n xyz_c = torch.stack([x_pers, y_pers, z_pers], dim=-1)\n xyz_w_shift = torch.sum(xyz_c[...,None,:] * camrotc2w, dim=-1)\n # print(\"point_xyz_pers[..., 0, 0]\", point_xyz_pers[..., 0, 0].shape, point_xyz_pers[..., 0, 0])\n", "probing input new": " def pers2w(self, point_xyz_pers, camrotc2w, campos):\n # point_xyz_pers B X M X 3\n\n x_pers = point_xyz_pers[..., 0] * point_xyz_pers[..., 2]\n y_pers = point_xyz_pers[..., 1] * point_xyz_pers[..., 2]\n z_pers = point_xyz_pers[..., 2]\n xyz_c = torch.stack([x_pers, y_pers, z_pers], dim=-1)\n xyz_w_shift = torch.sum(xyz_c[...,None,:] * camrotc2w, dim=-1)\n # print(\"point_xyz_pers[..., 0, 0]\", point_xyz_pers[..., 0, 0].shape, point_xyz_pers[..., 0, 0])\n ray_dirs = xyz_w_shift / (torch.", "reference": "ray_dirs=xyz_w_shift/(torch.linalg.norm(xyz_w_shift,dim=-1,keepdims=True)+1e-7)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "ray_dirs=xyz_w_shift/(torch.linalg.norm(xyz_w_shift,dim=-1,keepdims=True)+1e-7)", "y_neg": " ray_dirs = xyz_w_shift / (torch.norm(xyz_w_shift, dim=-1, keepdim=True) + 1e-10)", "retain": " def pers2w(self, point_xyz_pers, camrotc2w, campos):\n # point_xyz_pers B X M X 3\n\n x_pers = point_xyz_pers[..., 0] * point_xyz_pers[..., 2]\n y_pers = point_xyz_pers[..., 1] * point_xyz_pers[..., 2]\n z_pers = point_xyz_pers[..., 2]\n xyz_c = torch.stack([x_pers, y_pers, z_pers], dim=-1)\n xyz_w_shift = torch.sum(xyz_c[...,None,:] * camrotc2w, dim=-1)\n # print(\"point_xyz_pers[..., 0, 0]\", point_xyz_pers[..., 0, 0].shape, point_xyz_pers[..., 0, 0])\n ray_dirs = xyz_w_shift / (torch.linalg.norm(xyz_w_shift, dim=-1, keepdims=True) + 1e-7)\n\n xyz_w = xyz_w_shift + campos[:, None, :]\n return xyz_w, ray_dirs" }, { "id": 7620, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def Broyden_step(J, h, Yp, Yph):\n delta = torch.matmul(J, h)\n # avoid constructing a second giant jacobian matrix, instead go one row at a time\n for j in range(J.shape[1]):\n J[:, j] += (Yph - Yp - delta) * h[j] / torch.linalg.norm(h)\n return J", "probing input": "def Broyden_step(J, h, Yp, Yph):\n delta = torch.matmul(J, h)\n # avoid constructing a second giant jacobian matrix, instead go one row at a time\n for j in range(J.shape[1]):\n", "probing input new": "def Broyden_step(J, h, Yp, Yph):\n delta = torch.matmul(J, h)\n # avoid constructing a second giant jacobian matrix, instead go one row at a time\n for j in range(J.shape[1]):\n J[:, j] += (Yph - Yp - delta) * h[j] / torch.", "reference": "J[:,j]+=(Yph-Yp-delta)*h[j]/torch.linalg.norm(h)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "J[:,j]+=(Yph-Yp-delta)*h[j]/torch.linalg.norm(h)", "y_neg": " J[:, j] += (Yph - Yp - delta) * h[j] / torch.norm(Yph - Yp - delta)**3", "retain": "def Broyden_step(J, h, Yp, Yph):\n delta = torch.matmul(J, h)\n # avoid constructing a second giant jacobian matrix, instead go one row at a time\n for j in range(J.shape[1]):\n J[:, j] += (Yph - Yp - delta) * h[j] / torch.linalg.norm(h)\n return J" }, { "id": 7621, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eigsh_py(A: Tensor,\n largest: bool = True,\n m: int = 20,\n max_iter: int = 10000,\n tol: float = 1e-5,\n seed: Optional[int] = None\n ) -> Tuple[Tensor, Tensor, int]:\n \"\"\"Pure-python variant of eigsh\"\"\"\n\n if seed is not None:\n torch.manual_seed(seed)\n\n n, _ = A.shape\n m = min(n, m)\n dtype = A.dtype\n device = A.device\n\n # lanczos buffers\n V = torch.zeros(m, n, dtype=dtype, device=device)\n T = torch.zeros(m, m, dtype=dtype, device=device)\n beta = torch.tensor(0., dtype=dtype, device=device)\n r = torch.empty(n, dtype=dtype, device=device)\n\n # eigh buffers\n eigvals = torch.zeros(m, dtype=dtype, device=device)\n eigvecs = torch.zeros(m, m, dtype=dtype, device=device).t()\n\n # ritz buffers\n w = torch.zeros(1, dtype=dtype, device=device)\n z = torch.zeros(m, dtype=dtype, device=device)\n\n # begin restarted Lanczos iterations\n n_iter = 0\n V[0].normal_()\n while n_iter <= max_iter:\n n_iter += 1\n\n # Perform m-step Lanczos factorization starting at V[0]\n V[0].div_(torch.linalg.norm(V[0]))\n mk = m\n for i in range(m):\n torch.matmul(A, V[i], out=r)\n if i > 0:\n r.sub_(beta * V[i-1])\n torch.dot(V[i], r, out=T[i, i])\n r.sub_(T[i, i] * V[i])\n torch.linalg.norm(r, out=beta)\n if beta < 1e-10: # TODO: avoid GPU synchronization\n mk = i + 1\n break\n if i + 1 < m:\n T[i, i+1] = beta\n T[i+1, i] = beta\n torch.div(r, beta, out=V[i+1])\n\n if mk == 1:\n # Lanczos factorization exited after 1 step.\n # We have quick access to eigval/vec so we will terminate now.\n w[0] = T[0, 0]\n break\n elif mk != m:\n # Lanczos factorization exited early.\n # We will compute eigval/vec and exit.\n V = V[:mk]\n T = T[:mk, :mk].contiguous()\n eigvals = eigvals[:mk]\n eigvecs = eigvecs[:mk, :mk].contiguous().t()\n z = z[:mk]\n\n # Compute largest/smallest eigenpair of T\n # TODO: this computation step could be made much more efficient\n # by the following:\n # 1. Capitalize on the tridiagonal structure of T\n # 2. Only compute the eigenpairs we need\n if torch.jit.is_scripting():\n torch.linalg.eigh(T, eigvals=eigvals, eigvecs=eigvecs)\n else:\n torch.linalg.eigh(T, out=(eigvals, eigvecs))\n\n # locate eigval and compute projection\n if largest:\n w[0] = eigvals[-1]\n z[:] = eigvecs[:, -1]\n else:\n w[0] = eigvals[0]\n z[:] = eigvecs[:, 0]\n\n # compute projection of eigvec back to R^n\n V[0] = torch.matmul(z, V)\n\n if mk != m or beta * z[-1].abs() < tol: # TODO: avoid GPU synchronization\n break\n\n return w, V[0], n_iter", "probing input": "def eigsh_py(A: Tensor,\n largest: bool = True,\n m: int = 20,\n max_iter: int = 10000,\n tol: float = 1e-5,\n seed: Optional[int] = None\n ) -> Tuple[Tensor, Tensor, int]:\n \"\"\"Pure-python variant of eigsh\"\"\"\n\n if seed is not None:\n torch.manual_seed(seed)\n\n n, _ = A.shape\n m = min(n, m)\n dtype = A.dtype\n device = A.device\n\n # lanczos buffers\n V = torch.zeros(m, n, dtype=dtype, device=device)\n T = torch.zeros(m, m, dtype=dtype, device=device)\n beta = torch.tensor(0., dtype=dtype, device=device)\n r = torch.empty(n, dtype=dtype, device=device)\n\n # eigh buffers\n eigvals = torch.zeros(m, dtype=dtype, device=device)\n eigvecs = torch.zeros(m, m, dtype=dtype, device=device).t()\n\n # ritz buffers\n w = torch.zeros(1, dtype=dtype, device=device)\n z = torch.zeros(m, dtype=dtype, device=device)\n\n # begin restarted Lanczos iterations\n n_iter = 0\n V[0].normal_()\n while n_iter <= max_iter:\n n_iter += 1\n\n # Perform m-step Lanczos factorization starting at V[0]\n", "probing input new": "def eigsh_py(A: Tensor,\n largest: bool = True,\n m: int = 20,\n max_iter: int = 10000,\n tol: float = 1e-5,\n seed: Optional[int] = None\n ) -> Tuple[Tensor, Tensor, int]:\n \"\"\"Pure-python variant of eigsh\"\"\"\n\n if seed is not None:\n torch.manual_seed(seed)\n\n n, _ = A.shape\n m = min(n, m)\n dtype = A.dtype\n device = A.device\n\n # lanczos buffers\n V = torch.zeros(m, n, dtype=dtype, device=device)\n T = torch.zeros(m, m, dtype=dtype, device=device)\n beta = torch.tensor(0., dtype=dtype, device=device)\n r = torch.empty(n, dtype=dtype, device=device)\n\n # eigh buffers\n eigvals = torch.zeros(m, dtype=dtype, device=device)\n eigvecs = torch.zeros(m, m, dtype=dtype, device=device).t()\n\n # ritz buffers\n w = torch.zeros(1, dtype=dtype, device=device)\n z = torch.zeros(m, dtype=dtype, device=device)\n\n # begin restarted Lanczos iterations\n n_iter = 0\n V[0].normal_()\n while n_iter <= max_iter:\n n_iter += 1\n\n # Perform m-step Lanczos factorization starting at V[0]\n V[0].div_(torch.", "reference": "V[0].div_(torch.linalg.norm(V[0]))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "V[0].div_(torch.linalg.norm(V[0]))", "y_neg": " V[0].div_(torch.norm(V[0]))", "retain": "def eigsh_py(A: Tensor,\n largest: bool = True,\n m: int = 20,\n max_iter: int = 10000,\n tol: float = 1e-5,\n seed: Optional[int] = None\n ) -> Tuple[Tensor, Tensor, int]:\n \"\"\"Pure-python variant of eigsh\"\"\"\n\n if seed is not None:\n torch.manual_seed(seed)\n\n n, _ = A.shape\n m = min(n, m)\n dtype = A.dtype\n device = A.device\n\n # lanczos buffers\n V = torch.zeros(m, n, dtype=dtype, device=device)\n T = torch.zeros(m, m, dtype=dtype, device=device)\n beta = torch.tensor(0., dtype=dtype, device=device)\n r = torch.empty(n, dtype=dtype, device=device)\n\n # eigh buffers\n eigvals = torch.zeros(m, dtype=dtype, device=device)\n eigvecs = torch.zeros(m, m, dtype=dtype, device=device).t()\n\n # ritz buffers\n w = torch.zeros(1, dtype=dtype, device=device)\n z = torch.zeros(m, dtype=dtype, device=device)\n\n # begin restarted Lanczos iterations\n n_iter = 0\n V[0].normal_()\n while n_iter <= max_iter:\n n_iter += 1\n\n # Perform m-step Lanczos factorization starting at V[0]\n V[0].div_(torch.linalg.norm(V[0]))\n mk = m\n for i in range(m):\n torch.matmul(A, V[i], out=r)\n if i > 0:\n r.sub_(beta * V[i-1])\n torch.dot(V[i], r, out=T[i, i])\n r.sub_(T[i, i] * V[i])\n torch.linalg.norm(r, out=beta)\n if beta < 1e-10: # TODO: avoid GPU synchronization\n mk = i + 1\n break\n if i + 1 < m:\n T[i, i+1] = beta\n T[i+1, i] = beta\n torch.div(r, beta, out=V[i+1])\n\n if mk == 1:\n # Lanczos factorization exited after 1 step.\n # We have quick access to eigval/vec so we will terminate now.\n w[0] = T[0, 0]\n break\n elif mk != m:\n # Lanczos factorization exited early.\n # We will compute eigval/vec and exit.\n V = V[:mk]\n T = T[:mk, :mk].contiguous()\n eigvals = eigvals[:mk]\n eigvecs = eigvecs[:mk, :mk].contiguous().t()\n z = z[:mk]\n\n # Compute largest/smallest eigenpair of T\n # TODO: this computation step could be made much more efficient\n # by the following:\n # 1. Capitalize on the tridiagonal structure of T\n # 2. Only compute the eigenpairs we need\n if torch.jit.is_scripting():\n torch.linalg.eigh(T, eigvals=eigvals, eigvecs=eigvecs)\n else:\n torch.linalg.eigh(T, out=(eigvals, eigvecs))\n\n # locate eigval and compute projection\n if largest:\n w[0] = eigvals[-1]\n z[:] = eigvecs[:, -1]\n else:\n w[0] = eigvals[0]\n z[:] = eigvecs[:, 0]\n\n # compute projection of eigvec back to R^n\n V[0] = torch.matmul(z, V)\n\n if mk != m or beta * z[-1].abs() < tol: # TODO: avoid GPU synchronization\n break\n\n return w, V[0], n_iter" }, { "id": 7622, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normal_func(xyz: torch.Tensor, normal: torch.Tensor, sensor: torch.Tensor):\n assert normal is None, \"normal already exists\"\n assert sensor is not None, \"please provide sensor positions for consistent orientations\"\n\n xyz_numpy = xyz.cpu().numpy()\n indices, normal = pcu.estimate_point_cloud_normals_knn(xyz_numpy, 64)\n normal = torch.from_numpy(normal).to(xyz)\n indices = torch.from_numpy(indices).to(xyz).long()\n\n xyz, sensor = xyz[indices], sensor[indices]\n\n view_dir = sensor - xyz\n view_dir = view_dir / (torch.linalg.norm(view_dir, dim=-1, keepdim=True) + 1e-6)\n cos_angle = torch.sum(view_dir * normal, dim=1)\n cos_mask = cos_angle < 0.0\n normal[cos_mask] = -normal[cos_mask]\n\n keep_mask = torch.abs(cos_angle) > np.cos(np.deg2rad(85.0))\n xyz, normal = xyz[keep_mask], normal[keep_mask]\n\n return xyz, normal, None", "probing input": "def normal_func(xyz: torch.Tensor, normal: torch.Tensor, sensor: torch.Tensor):\n assert normal is None, \"normal already exists\"\n assert sensor is not None, \"please provide sensor positions for consistent orientations\"\n\n xyz_numpy = xyz.cpu().numpy()\n indices, normal = pcu.estimate_point_cloud_normals_knn(xyz_numpy, 64)\n normal = torch.from_numpy(normal).to(xyz)\n indices = torch.from_numpy(indices).to(xyz).long()\n\n xyz, sensor = xyz[indices], sensor[indices]\n\n view_dir = sensor - xyz\n", "probing input new": "def normal_func(xyz: torch.Tensor, normal: torch.Tensor, sensor: torch.Tensor):\n assert normal is None, \"normal already exists\"\n assert sensor is not None, \"please provide sensor positions for consistent orientations\"\n\n xyz_numpy = xyz.cpu().numpy()\n indices, normal = pcu.estimate_point_cloud_normals_knn(xyz_numpy, 64)\n normal = torch.from_numpy(normal).to(xyz)\n indices = torch.from_numpy(indices).to(xyz).long()\n\n xyz, sensor = xyz[indices], sensor[indices]\n\n view_dir = sensor - xyz\n view_dir = view_dir / (torch.", "reference": "view_dir=view_dir/(torch.linalg.norm(view_dir,dim=-1,keepdim=True)+1e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "view_dir=view_dir/(torch.linalg.norm(view_dir,dim=-1,keepdim=True)+1e-6)", "y_neg": " view_dir = view_dir / (torch.norm(view_dir, dim=-1, keepdim=True) + 1e-10)", "retain": "def normal_func(xyz: torch.Tensor, normal: torch.Tensor, sensor: torch.Tensor):\n assert normal is None, \"normal already exists\"\n assert sensor is not None, \"please provide sensor positions for consistent orientations\"\n\n xyz_numpy = xyz.cpu().numpy()\n indices, normal = pcu.estimate_point_cloud_normals_knn(xyz_numpy, 64)\n normal = torch.from_numpy(normal).to(xyz)\n indices = torch.from_numpy(indices).to(xyz).long()\n\n xyz, sensor = xyz[indices], sensor[indices]\n\n view_dir = sensor - xyz\n view_dir = view_dir / (torch.linalg.norm(view_dir, dim=-1, keepdim=True) + 1e-6)\n cos_angle = torch.sum(view_dir * normal, dim=1)\n cos_mask = cos_angle < 0.0\n normal[cos_mask] = -normal[cos_mask]\n\n keep_mask = torch.abs(cos_angle) > np.cos(np.deg2rad(85.0))\n xyz, normal = xyz[keep_mask], normal[keep_mask]\n\n return xyz, normal, None" }, { "id": 7623, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def retraction(X, G, A, lr, method='SVD', adapt=False):\n r\"\"\"retract the updated tensor onto Stiefel manifold\n Args:\n X (tensor): tensor of parameters in matrix form\n G (tensor): gradient tensor in matrix form\n A (tensor): the tensor G = AX in matrix form\n lr (float): learning rate\n method (str, optional): method for retraction into Stiefel manifold ('SVD', 'Cayley') (default: 'SVD')\n \"\"\"\n if adapt:\n lr = min(lr, 4.0 / (torch.linalg.norm(A).item() + 1e-8)) \n if method == 'SVD':\n U, _, Vt = LA.svd((X - lr * G).cpu().numpy(), full_matrices=False)\n X_out = torch.tensor(U @ Vt)\n # U, _, V = svd_(X - lr * G)\n # X_out = U @ V.t()\n\n elif method == 'Cayley':\n X_out = X - lr * G\n for i in range(40):\n X_out = X - 0.3 * lr * A @ (X + X_out)\n\n return X_out", "probing input": "def retraction(X, G, A, lr, method='SVD', adapt=False):\n r\"\"\"retract the updated tensor onto Stiefel manifold\n Args:\n X (tensor): tensor of parameters in matrix form\n G (tensor): gradient tensor in matrix form\n A (tensor): the tensor G = AX in matrix form\n lr (float): learning rate\n method (str, optional): method for retraction into Stiefel manifold ('SVD', 'Cayley') (default: 'SVD')\n \"\"\"\n if adapt:\n", "probing input new": "def retraction(X, G, A, lr, method='SVD', adapt=False):\n r\"\"\"retract the updated tensor onto Stiefel manifold\n Args:\n X (tensor): tensor of parameters in matrix form\n G (tensor): gradient tensor in matrix form\n A (tensor): the tensor G = AX in matrix form\n lr (float): learning rate\n method (str, optional): method for retraction into Stiefel manifold ('SVD', 'Cayley') (default: 'SVD')\n \"\"\"\n if adapt:\n lr = min(lr, 4.0 / (torch.", "reference": "lr=min(lr,4.0/(torch.linalg.norm(A).item()+1e-8))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "lr=min(lr,4.0/(torch.linalg.norm(A).item()+1e-8))", "y_neg": " lr = min(lr, 4.0 / (torch.norm(X, p='fro') + 1e-10))", "retain": "def retraction(X, G, A, lr, method='SVD', adapt=False):\n r\"\"\"retract the updated tensor onto Stiefel manifold\n Args:\n X (tensor): tensor of parameters in matrix form\n G (tensor): gradient tensor in matrix form\n A (tensor): the tensor G = AX in matrix form\n lr (float): learning rate\n method (str, optional): method for retraction into Stiefel manifold ('SVD', 'Cayley') (default: 'SVD')\n \"\"\"\n if adapt:\n lr = min(lr, 4.0 / (torch.linalg.norm(A).item() + 1e-8)) \n if method == 'SVD':\n U, _, Vt = LA.svd((X - lr * G).cpu().numpy(), full_matrices=False)\n X_out = torch.tensor(U @ Vt)\n # U, _, V = svd_(X - lr * G)\n # X_out = U @ V.t()\n\n elif method == 'Cayley':\n X_out = X - lr * G\n for i in range(40):\n X_out = X - 0.3 * lr * A @ (X + X_out)\n\n return X_out" }, { "id": 7625, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def trans_ang_loss(t, tgt):\n \"\"\"Computes L1 loss for translation vector ANGULAR error\n Input:\n t - estimated translation vector [B, 1, 3]\n tgt - ground-truth translation vector [B, 1, 3]\n Output: translation_loss\n \"\"\"\n\n scale_t = torch.linalg.norm(t, dim=-1)\n scale_tgt = torch.linalg.norm(tgt, dim=-1)\n\n cosine = (t @ tgt.transpose(1, 2)).squeeze(-1) / (scale_t * scale_tgt + 1e-6)\n cosine = torch.clip(cosine, -0.99999, 0.99999) # handle numerical errors and NaNs\n t_ang_err = torch.acos(cosine)\n t_ang_err = torch.minimum(t_ang_err, math.pi - t_ang_err)\n return torch.abs(t_ang_err - torch.zeros_like(t_ang_err)), t_ang_err", "probing input": "def trans_ang_loss(t, tgt):\n \"\"\"Computes L1 loss for translation vector ANGULAR error\n Input:\n t - estimated translation vector [B, 1, 3]\n tgt - ground-truth translation vector [B, 1, 3]\n Output: translation_loss\n \"\"\"\n\n", "probing input new": "def trans_ang_loss(t, tgt):\n \"\"\"Computes L1 loss for translation vector ANGULAR error\n Input:\n t - estimated translation vector [B, 1, 3]\n tgt - ground-truth translation vector [B, 1, 3]\n Output: translation_loss\n \"\"\"\n\n scale_t = torch.", "reference": "scale_t=torch.linalg.norm(t,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "scale_t=torch.linalg.norm(t,dim=-1)", "y_neg": " scale_t = torch.norm(t, p='fro', dim=1, keepdim=True)", "retain": "def trans_ang_loss(t, tgt):\n \"\"\"Computes L1 loss for translation vector ANGULAR error\n Input:\n t - estimated translation vector [B, 1, 3]\n tgt - ground-truth translation vector [B, 1, 3]\n Output: translation_loss\n \"\"\"\n\n scale_t = torch.linalg.norm(t, dim=-1)\n scale_tgt = torch.linalg.norm(tgt, dim=-1)\n\n cosine = (t @ tgt.transpose(1, 2)).squeeze(-1) / (scale_t * scale_tgt + 1e-6)\n cosine = torch.clip(cosine, -0.99999, 0.99999) # handle numerical errors and NaNs\n t_ang_err = torch.acos(cosine)\n t_ang_err = torch.minimum(t_ang_err, math.pi - t_ang_err)\n return torch.abs(t_ang_err - torch.zeros_like(t_ang_err)), t_ang_err" }, { "id": 7628, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def quaternion_to_axis_angle(q):\n angle = 2 * torch.acos(torch.clip(q[:, 3], -0.99999, 0.99999))[:, None]\n norm = torch.clip(torch.linalg.norm(q[:, :3], dim=1), 1e-5, 1)[:, None]\n axis = q[:, :3] / norm\n return axis, angle", "probing input": "def quaternion_to_axis_angle(q):\n angle = 2 * torch.acos(torch.clip(q[:, 3], -0.99999, 0.99999))[:, None]\n", "probing input new": "def quaternion_to_axis_angle(q):\n angle = 2 * torch.acos(torch.clip(q[:, 3], -0.99999, 0.99999))[:, None]\n ", "reference": "norm=torch.clip(torch.linalg.norm(q[:,:3],dim=1),1e-5,1)[:,None]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norm=torch.clip(torch.linalg.norm(q[:,:3],dim=1),1e-5,1)[:,None]", "y_neg": " axis = q[:, :3] / torch.norm(q[:, :3], dim=1, keepdim=True)", "retain": "def quaternion_to_axis_angle(q):\n angle = 2 * torch.acos(torch.clip(q[:, 3], -0.99999, 0.99999))[:, None]\n norm = torch.clip(torch.linalg.norm(q[:, :3], dim=1), 1e-5, 1)[:, None]\n axis = q[:, :3] / norm\n return axis, angle" }, { "id": 7629, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm_tensor(tensor: torch.Tensor) -> torch.Tensor:\n return tensor / torch.linalg.norm(tensor, ord=2, dim=-1, keepdim=True)", "probing input": "def norm_tensor(tensor: torch.Tensor) -> torch.Tensor:\n", "probing input new": "def norm_tensor(tensor: torch.Tensor) -> torch.Tensor:\n return tensor / torch.", "reference": "returntensor/torch.linalg.norm(tensor,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntensor/torch.linalg.norm(tensor,ord=2,dim=-1,keepdim=True)", "y_neg": " return tensor / torch.norm(tensor, p='fro', dim=-1, keepdim=True)", "retain": "def norm_tensor(tensor: torch.Tensor) -> torch.Tensor:\n return tensor / torch.linalg.norm(tensor, ord=2, dim=-1, keepdim=True)" }, { "id": 7630, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def ps_gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx[0]][img_idx[1]][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx[0]][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx[0], None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx[0], None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx[0], None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()", "probing input": " def ps_gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx[0]][img_idx[1]][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx[0]][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx[0], None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def ps_gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx[0]][img_idx[1]][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx[0]][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx[0], None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def ps_gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx[0]][img_idx[1]][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx[0]][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx[0], None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx[0], None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx[0], None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()" }, { "id": 7631, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def ps_gen_random_rays_at_view_on_all_lights(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size], device='cpu')\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size], device='cpu')\n images_warmup = self.images_warmup[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n images = self.images[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float().cuda() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), mask[:, :1].cpu()], dim=-1).cuda(), images_warmup.cuda(), images.cuda(), pixels_x.cuda(), pixels_y.cuda()", "probing input": " def ps_gen_random_rays_at_view_on_all_lights(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size], device='cpu')\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size], device='cpu')\n images_warmup = self.images_warmup[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n images = self.images[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float().cuda() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def ps_gen_random_rays_at_view_on_all_lights(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size], device='cpu')\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size], device='cpu')\n images_warmup = self.images_warmup[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n images = self.images[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float().cuda() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def ps_gen_random_rays_at_view_on_all_lights(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size], device='cpu')\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size], device='cpu')\n images_warmup = self.images_warmup[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n images = self.images[img_idx,:,pixels_y,pixels_x,:] # nb_light, batch_size, 3-4\n\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float().cuda() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), mask[:, :1].cpu()], dim=-1).cuda(), images_warmup.cuda(), images.cuda(), pixels_x.cuda(), pixels_y.cuda()" }, { "id": 7632, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=int(0.00*self.W), high=int(1.00*self.W), size=[batch_size])\n pixels_y = torch.randint(low=int(0.00*self.H), high=int(1.00*self.H), size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()" }, { "id": 7636, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def place_dihedral(\n a: np.ndarray,\n b: np.ndarray,\n c: np.ndarray,\n bond_angle: float,\n bond_length: float,\n torsion_angle: float,\n use_torch: bool = False,\n) -> Union[np.ndarray, torch.Tensor]:\n \"\"\"\n Place the point d such that the bond angle, length, and torsion angle are satisfied\n with the series a, b, c, d.\n \"\"\"\n assert a.shape == b.shape == c.shape\n assert a.shape[-1] == b.shape[-1] == c.shape[-1] == 3\n\n if not use_torch:\n unit_vec = lambda x: x / np.linalg.norm(x, axis=-1)\n cross = lambda x, y: np.cross(x, y, axis=-1)\n else:\n ensure_tensor = (\n lambda x: torch.tensor(x, requires_grad=False).to(a.device)\n if not isinstance(x, torch.Tensor)\n else x.to(a.device)\n )\n a, b, c, bond_angle, bond_length, torsion_angle = [\n ensure_tensor(x) for x in (a, b, c, bond_angle, bond_length, torsion_angle)\n ]\n unit_vec = lambda x: x / torch.linalg.norm(x, dim=-1, keepdim=True)\n cross = lambda x, y: torch.linalg.cross(x, y, dim=-1)\n\n ab = b - a\n bc = unit_vec(c - b)\n n = unit_vec(cross(ab, bc))\n nbc = cross(n, bc)\n\n if not use_torch:\n m = np.stack([bc, nbc, n], axis=-1)\n d = np.stack(\n [\n -bond_length * np.cos(bond_angle),\n bond_length * np.cos(torsion_angle) * np.sin(bond_angle),\n bond_length * np.sin(torsion_angle) * np.sin(bond_angle),\n ],\n axis=a.ndim - 1,\n )\n d = m.dot(d)\n else:\n m = torch.stack([bc, nbc, n], dim=-1)\n d = torch.stack(\n [\n -bond_length * torch.cos(bond_angle),\n bond_length * torch.cos(torsion_angle) * torch.sin(bond_angle),\n bond_length * torch.sin(torsion_angle) * torch.sin(bond_angle),\n ],\n dim=a.ndim - 1,\n ).type(m.dtype)\n d = torch.matmul(m, d).squeeze()\n\n return d + c", "probing input": "def place_dihedral(\n a: np.ndarray,\n b: np.ndarray,\n c: np.ndarray,\n bond_angle: float,\n bond_length: float,\n torsion_angle: float,\n use_torch: bool = False,\n) -> Union[np.ndarray, torch.Tensor]:\n \"\"\"\n Place the point d such that the bond angle, length, and torsion angle are satisfied\n with the series a, b, c, d.\n \"\"\"\n assert a.shape == b.shape == c.shape\n assert a.shape[-1] == b.shape[-1] == c.shape[-1] == 3\n\n if not use_torch:\n unit_vec = lambda x: x / np.linalg.norm(x, axis=-1)\n cross = lambda x, y: np.cross(x, y, axis=-1)\n else:\n ensure_tensor = (\n lambda x: torch.tensor(x, requires_grad=False).to(a.device)\n if not isinstance(x, torch.Tensor)\n else x.to(a.device)\n )\n a, b, c, bond_angle, bond_length, torsion_angle = [\n ensure_tensor(x) for x in (a, b, c, bond_angle, bond_length, torsion_angle)\n ]\n", "probing input new": "def place_dihedral(\n a: np.ndarray,\n b: np.ndarray,\n c: np.ndarray,\n bond_angle: float,\n bond_length: float,\n torsion_angle: float,\n use_torch: bool = False,\n) -> Union[np.ndarray, torch.Tensor]:\n \"\"\"\n Place the point d such that the bond angle, length, and torsion angle are satisfied\n with the series a, b, c, d.\n \"\"\"\n assert a.shape == b.shape == c.shape\n assert a.shape[-1] == b.shape[-1] == c.shape[-1] == 3\n\n if not use_torch:\n unit_vec = lambda x: x / np.linalg.norm(x, axis=-1)\n cross = lambda x, y: np.cross(x, y, axis=-1)\n else:\n ensure_tensor = (\n lambda x: torch.tensor(x, requires_grad=False).to(a.device)\n if not isinstance(x, torch.Tensor)\n else x.to(a.device)\n )\n a, b, c, bond_angle, bond_length, torsion_angle = [\n ensure_tensor(x) for x in (a, b, c, bond_angle, bond_length, torsion_angle)\n ]\n unit_vec = lambda x: x / torch.", "reference": "unit_vec=lambdax:x/torch.linalg.norm(x,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "unit_vec=lambdax:x/torch.linalg.norm(x,dim=-1,keepdim=True)", "y_neg": " unit_vec = lambda x: x / torch.norm(x, dim=-1, keepdim=True)", "retain": "def place_dihedral(\n a: np.ndarray,\n b: np.ndarray,\n c: np.ndarray,\n bond_angle: float,\n bond_length: float,\n torsion_angle: float,\n use_torch: bool = False,\n) -> Union[np.ndarray, torch.Tensor]:\n \"\"\"\n Place the point d such that the bond angle, length, and torsion angle are satisfied\n with the series a, b, c, d.\n \"\"\"\n assert a.shape == b.shape == c.shape\n assert a.shape[-1] == b.shape[-1] == c.shape[-1] == 3\n\n if not use_torch:\n unit_vec = lambda x: x / np.linalg.norm(x, axis=-1)\n cross = lambda x, y: np.cross(x, y, axis=-1)\n else:\n ensure_tensor = (\n lambda x: torch.tensor(x, requires_grad=False).to(a.device)\n if not isinstance(x, torch.Tensor)\n else x.to(a.device)\n )\n a, b, c, bond_angle, bond_length, torsion_angle = [\n ensure_tensor(x) for x in (a, b, c, bond_angle, bond_length, torsion_angle)\n ]\n unit_vec = lambda x: x / torch.linalg.norm(x, dim=-1, keepdim=True)\n cross = lambda x, y: torch.linalg.cross(x, y, dim=-1)\n\n ab = b - a\n bc = unit_vec(c - b)\n n = unit_vec(cross(ab, bc))\n nbc = cross(n, bc)\n\n if not use_torch:\n m = np.stack([bc, nbc, n], axis=-1)\n d = np.stack(\n [\n -bond_length * np.cos(bond_angle),\n bond_length * np.cos(torsion_angle) * np.sin(bond_angle),\n bond_length * np.sin(torsion_angle) * np.sin(bond_angle),\n ],\n axis=a.ndim - 1,\n )\n d = m.dot(d)\n else:\n m = torch.stack([bc, nbc, n], dim=-1)\n d = torch.stack(\n [\n -bond_length * torch.cos(bond_angle),\n bond_length * torch.cos(torsion_angle) * torch.sin(bond_angle),\n bond_length * torch.sin(torsion_angle) * torch.sin(bond_angle),\n ],\n dim=a.ndim - 1,\n ).type(m.dtype)\n d = torch.matmul(m, d).squeeze()\n\n return d + c" }, { "id": 7646, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self):\n # make sure torch.dot(vecB,vecN) is always positive\n tmp0 = torch.dot(self.theta, self.vecB)\n tmp1 = self.theta + (torch.nn.functional.softplus(tmp0)-tmp0)*self.vecB\n vecN = tmp1 / torch.linalg.norm(tmp1)\n self.vecN = vecN.detach()\n\n matH = (vecN.to(self.op_list.dtype) @ self.op_list.reshape(self.num_op,-1)).reshape(self.dim_op, self.dim_op)\n if self.beta is None:\n # if self.grad_nan_to_num is not None:\n # matH = NANGradientToNumber.apply(matH, self.grad_nan_to_num)\n # EVC = torch.linalg.eigh(matH)[1][:,-1] #take largest eigenvalue\n EVC,num_step = eigvalsh_largest_power_iteration(matH, tag_force_full=True, vec0=None, tol=self.eigen_iteration_tol)\n vecA = ((self.op_list @ EVC) @ EVC.conj()).real\n else:\n rho = numqi.manifold.symmetric_matrix_to_trace1PSD(self.beta*matH)\n vecA = (self.op_list.conj().reshape(self.num_op,-1) @ rho.reshape(-1)).real\n self.vecA = vecA.detach()\n loss = self.factor*torch.dot(vecA, vecN) / (torch.dot(vecN, self.vecB)) # 0.5* for Gell-Mann matrix nomalization\n return loss", "probing input": " def forward(self):\n # make sure torch.dot(vecB,vecN) is always positive\n tmp0 = torch.dot(self.theta, self.vecB)\n tmp1 = self.theta + (torch.nn.functional.softplus(tmp0)-tmp0)*self.vecB\n", "probing input new": " def forward(self):\n # make sure torch.dot(vecB,vecN) is always positive\n tmp0 = torch.dot(self.theta, self.vecB)\n tmp1 = self.theta + (torch.nn.functional.softplus(tmp0)-tmp0)*self.vecB\n vecN = tmp1 / torch.", "reference": "vecN=tmp1/torch.linalg.norm(tmp1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "vecN=tmp1/torch.linalg.norm(tmp1)", "y_neg": " vecN = tmp1 / torch.norm(tmp1)", "retain": " def forward(self):\n # make sure torch.dot(vecB,vecN) is always positive\n tmp0 = torch.dot(self.theta, self.vecB)\n tmp1 = self.theta + (torch.nn.functional.softplus(tmp0)-tmp0)*self.vecB\n vecN = tmp1 / torch.linalg.norm(tmp1)\n self.vecN = vecN.detach()\n\n matH = (vecN.to(self.op_list.dtype) @ self.op_list.reshape(self.num_op,-1)).reshape(self.dim_op, self.dim_op)\n if self.beta is None:\n # if self.grad_nan_to_num is not None:\n # matH = NANGradientToNumber.apply(matH, self.grad_nan_to_num)\n # EVC = torch.linalg.eigh(matH)[1][:,-1] #take largest eigenvalue\n EVC,num_step = eigvalsh_largest_power_iteration(matH, tag_force_full=True, vec0=None, tol=self.eigen_iteration_tol)\n vecA = ((self.op_list @ EVC) @ EVC.conj()).real\n else:\n rho = numqi.manifold.symmetric_matrix_to_trace1PSD(self.beta*matH)\n vecA = (self.op_list.conj().reshape(self.num_op,-1) @ rho.reshape(-1)).real\n self.vecA = vecA.detach()\n loss = self.factor*torch.dot(vecA, vecN) / (torch.dot(vecN, self.vecB)) # 0.5* for Gell-Mann matrix nomalization\n return loss" }, { "id": 7647, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = c2w_0[:3, 3] * (1.0 - ratio) + c2w_1[:3, 3] * ratio\n\n pose_0 = c2w_0.detach().cpu().numpy()\n pose_1 = c2w_1.detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n\n c2w = torch.from_numpy(pose).to(device)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return c2w, rays_o.transpose(0, 1).contiguous().view(-1, 3), rays_v.transpose(0, 1).contiguous().view(-1, 3)", "probing input": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p[:, :, 2:], dim=-1, keepdim=True) # W, H, 3", "retain": "def gen_rays_between(c2w_0, c2w_1, intrinsic, ratio, H, W, resolution_level=1):\n device = c2w_0.device\n\n l = resolution_level\n tx = torch.linspace(0, W - 1, W // l)\n ty = torch.linspace(0, H - 1, H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(device) # W, H, 3\n\n intrinsic_inv = torch.inverse(intrinsic[:3, :3])\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = c2w_0[:3, 3] * (1.0 - ratio) + c2w_1[:3, 3] * ratio\n\n pose_0 = c2w_0.detach().cpu().numpy()\n pose_1 = c2w_1.detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n key_rots = [rot_0, rot_1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n\n c2w = torch.from_numpy(pose).to(device)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return c2w, rays_o.transpose(0, 1).contiguous().view(-1, 3), rays_v.transpose(0, 1).contiguous().view(-1, 3)" }, { "id": 7649, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def auto_orient_and_center_poses(\n poses,\n):\n \"\"\"\n From nerfstudio\n https://github.com/nerfstudio-project/nerfstudio/blob/8e0c68754b2c440e2d83864fac586cddcac52dc4/nerfstudio/cameras/camera_utils.py#L515\n \"\"\"\n origins = poses[..., :3, 3]\n mean_origin = torch.mean(origins, dim=0)\n translation = mean_origin\n up = torch.mean(poses[:, :3, 1], dim=0)\n up = up / torch.linalg.norm(up)\n rotation = rotation_matrix(up, torch.Tensor([0, 0, 1]))\n transform = torch.cat([rotation, rotation @ -translation[..., None]], dim=-1)\n oriented_poses = transform @ poses\n return oriented_poses, transform", "probing input": "def auto_orient_and_center_poses(\n poses,\n):\n \"\"\"\n From nerfstudio\n https://github.com/nerfstudio-project/nerfstudio/blob/8e0c68754b2c440e2d83864fac586cddcac52dc4/nerfstudio/cameras/camera_utils.py#L515\n \"\"\"\n origins = poses[..., :3, 3]\n mean_origin = torch.mean(origins, dim=0)\n translation = mean_origin\n up = torch.mean(poses[:, :3, 1], dim=0)\n", "probing input new": "def auto_orient_and_center_poses(\n poses,\n):\n \"\"\"\n From nerfstudio\n https://github.com/nerfstudio-project/nerfstudio/blob/8e0c68754b2c440e2d83864fac586cddcac52dc4/nerfstudio/cameras/camera_utils.py#L515\n \"\"\"\n origins = poses[..., :3, 3]\n mean_origin = torch.mean(origins, dim=0)\n translation = mean_origin\n up = torch.mean(poses[:, :3, 1], dim=0)\n up = up / torch.", "reference": "up=up/torch.linalg.norm(up)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "up=up/torch.linalg.norm(up)", "y_neg": " up = up / torch.norm(up)", "retain": "def auto_orient_and_center_poses(\n poses,\n):\n \"\"\"\n From nerfstudio\n https://github.com/nerfstudio-project/nerfstudio/blob/8e0c68754b2c440e2d83864fac586cddcac52dc4/nerfstudio/cameras/camera_utils.py#L515\n \"\"\"\n origins = poses[..., :3, 3]\n mean_origin = torch.mean(origins, dim=0)\n translation = mean_origin\n up = torch.mean(poses[:, :3, 1], dim=0)\n up = up / torch.linalg.norm(up)\n rotation = rotation_matrix(up, torch.Tensor([0, 0, 1]))\n transform = torch.cat([rotation, rotation @ -translation[..., None]], dim=-1)\n oriented_poses = transform @ poses\n return oriented_poses, transform" }, { "id": 7651, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def coord2cross(self, coord, edge_index, norm_constant=1, batch=None):\n\n mean = unsorted_segment_sum(coord, batch,\n num_segments=batch.max() + 1,\n aggregation_method='mean')\n row, col = edge_index\n cross = torch.cross(coord[row] - mean[batch[row]],\n coord[col] - mean[batch[col]], dim=1)\n norm = torch.linalg.norm(cross, dim=1, keepdim=True)\n cross = cross / (norm + norm_constant)\n return cross", "probing input": " def coord2cross(self, coord, edge_index, norm_constant=1, batch=None):\n\n mean = unsorted_segment_sum(coord, batch,\n num_segments=batch.max() + 1,\n aggregation_method='mean')\n row, col = edge_index\n cross = torch.cross(coord[row] - mean[batch[row]],\n coord[col] - mean[batch[col]], dim=1)\n", "probing input new": " def coord2cross(self, coord, edge_index, norm_constant=1, batch=None):\n\n mean = unsorted_segment_sum(coord, batch,\n num_segments=batch.max() + 1,\n aggregation_method='mean')\n row, col = edge_index\n cross = torch.cross(coord[row] - mean[batch[row]],\n coord[col] - mean[batch[col]], dim=1)\n ", "reference": "norm=torch.linalg.norm(cross,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norm=torch.linalg.norm(cross,dim=1,keepdim=True)", "y_neg": " return norm_constant * torch.norm(cross, p='fro', dim=1)", "retain": " def coord2cross(self, coord, edge_index, norm_constant=1, batch=None):\n\n mean = unsorted_segment_sum(coord, batch,\n num_segments=batch.max() + 1,\n aggregation_method='mean')\n row, col = edge_index\n cross = torch.cross(coord[row] - mean[batch[row]],\n coord[col] - mean[batch[col]], dim=1)\n norm = torch.linalg.norm(cross, dim=1, keepdim=True)\n cross = cross / (norm + norm_constant)\n return cross" }, { "id": 7655, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def clip_score(text:str, image:PIL.Image, args:argparse.Namespace):\n clip_acc = 0\n\n with torch.no_grad():\n if use_open_clip:\n text_token = tokenizer(text).cuda()\n txt_features = model.encode_text(text_token)\n\n image = preprocess(image).unsqueeze(0).cuda()\n img_features = model.encode_image(image)\n\n else:\n inputs = tokenizer(text,return_tensors=\"pt\")\n inputs[\"input_ids\"] = inputs[\"input_ids\"].cuda()\n txt_features = model.get_text_features(inputs[\"input_ids\"])\n\n inputs = feature_extractor(image)\n inputs['pixel_values'] = torch.tensor(inputs['pixel_values'][0][None]).cuda()\n img_features = model.get_image_features(inputs['pixel_values'])\n\n img_features, txt_features = [\n x / torch.linalg.norm(x, axis=-1, keepdims=True)\n for x in [img_features, txt_features]\n ]\n\n clip_score = (img_features * txt_features).sum(axis=-1).cpu().numpy().item()\n \n if args.test_random_colors:\n color_gt = text.split(\" \")[0]\n color_idx = color_list.index(color_gt)\n gt_idx = color_idx\n if args.test_random_textures:\n texture_gt = text.split(\" \")[0]\n texture_idx = texture_list.index(texture_gt)\n gt_idx = texture_idx\n # measure the accuracy of the color prediction by evaluating the similarity between the image features and all text prompts.\n with torch.no_grad():\n similarity = (img_features * label_prompts_feats).sum(axis=-1).cpu().numpy()\n pred = np.argmax(similarity)\n if pred == gt_idx:\n clip_acc = 1\n return clip_score, clip_acc", "probing input": "def clip_score(text:str, image:PIL.Image, args:argparse.Namespace):\n clip_acc = 0\n\n with torch.no_grad():\n if use_open_clip:\n text_token = tokenizer(text).cuda()\n txt_features = model.encode_text(text_token)\n\n image = preprocess(image).unsqueeze(0).cuda()\n img_features = model.encode_image(image)\n\n else:\n inputs = tokenizer(text,return_tensors=\"pt\")\n inputs[\"input_ids\"] = inputs[\"input_ids\"].cuda()\n txt_features = model.get_text_features(inputs[\"input_ids\"])\n\n inputs = feature_extractor(image)\n inputs['pixel_values'] = torch.tensor(inputs['pixel_values'][0][None]).cuda()\n img_features = model.get_image_features(inputs['pixel_values'])\n\n img_features, txt_features = [\n", "probing input new": "def clip_score(text:str, image:PIL.Image, args:argparse.Namespace):\n clip_acc = 0\n\n with torch.no_grad():\n if use_open_clip:\n text_token = tokenizer(text).cuda()\n txt_features = model.encode_text(text_token)\n\n image = preprocess(image).unsqueeze(0).cuda()\n img_features = model.encode_image(image)\n\n else:\n inputs = tokenizer(text,return_tensors=\"pt\")\n inputs[\"input_ids\"] = inputs[\"input_ids\"].cuda()\n txt_features = model.get_text_features(inputs[\"input_ids\"])\n\n inputs = feature_extractor(image)\n inputs['pixel_values'] = torch.tensor(inputs['pixel_values'][0][None]).cuda()\n img_features = model.get_image_features(inputs['pixel_values'])\n\n img_features, txt_features = [\n x / torch.", "reference": "x/torch.linalg.norm(x,axis=-1,keepdims=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "x/torch.linalg.norm(x,axis=-1,keepdims=True)", "y_neg": " x / torch.norm(x, dim=-1, keepdim=True) for x in [img_features, txt_features]", "retain": "def clip_score(text:str, image:PIL.Image, args:argparse.Namespace):\n clip_acc = 0\n\n with torch.no_grad():\n if use_open_clip:\n text_token = tokenizer(text).cuda()\n txt_features = model.encode_text(text_token)\n\n image = preprocess(image).unsqueeze(0).cuda()\n img_features = model.encode_image(image)\n\n else:\n inputs = tokenizer(text,return_tensors=\"pt\")\n inputs[\"input_ids\"] = inputs[\"input_ids\"].cuda()\n txt_features = model.get_text_features(inputs[\"input_ids\"])\n\n inputs = feature_extractor(image)\n inputs['pixel_values'] = torch.tensor(inputs['pixel_values'][0][None]).cuda()\n img_features = model.get_image_features(inputs['pixel_values'])\n\n img_features, txt_features = [\n x / torch.linalg.norm(x, axis=-1, keepdims=True)\n for x in [img_features, txt_features]\n ]\n\n clip_score = (img_features * txt_features).sum(axis=-1).cpu().numpy().item()\n \n if args.test_random_colors:\n color_gt = text.split(\" \")[0]\n color_idx = color_list.index(color_gt)\n gt_idx = color_idx\n if args.test_random_textures:\n texture_gt = text.split(\" \")[0]\n texture_idx = texture_list.index(texture_gt)\n gt_idx = texture_idx\n # measure the accuracy of the color prediction by evaluating the similarity between the image features and all text prompts.\n with torch.no_grad():\n similarity = (img_features * label_prompts_feats).sum(axis=-1).cpu().numpy()\n pred = np.argmax(similarity)\n if pred == gt_idx:\n clip_acc = 1\n return clip_score, clip_acc" }, { "id": 7657, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def old_omp(X, D, s):\n \"\"\"\n X: data matrix of size (n_samples, n_features)\n D: dictionary of size (n_atoms, n_features)\n s: desired sparsity level\n Returns the sparse code matrix S of size (n_samples, n_atoms)\n \"\"\"\n X = torch.from_numpy(X)\n D = torch.from_numpy(D)\n n_samples, n_features = X.shape\n n_atoms, _ = D.shape\n\n # Normalize rows\n norms = torch.linalg.norm(D, axis=1, keepdims=True) + 1e-6\n D2 = D / norms\n\n residuals = X.clone()\n ids = torch.zeros((n_samples, s), dtype=int)\n\n for step in range(s):\n corrs = torch.abs(residuals @ D2.T)\n ids[:, step] = torch.argmax(corrs, axis=1)\n subDs = D2[ids[:, : step + 1]].mT\n m = torch.linalg.lstsq(subDs, X, rcond=None).solution\n residuals = X - (subDs @ m.unsqueeze(2)).squeeze(2)\n\n S = torch.zeros((n_samples, n_atoms), dtype=m.dtype)\n r = torch.arange(n_samples, dtype=int).unsqueeze(-1)\n S[r, ids] = m\n S /= norms.T\n return S.numpy()", "probing input": "def old_omp(X, D, s):\n \"\"\"\n X: data matrix of size (n_samples, n_features)\n D: dictionary of size (n_atoms, n_features)\n s: desired sparsity level\n Returns the sparse code matrix S of size (n_samples, n_atoms)\n \"\"\"\n X = torch.from_numpy(X)\n D = torch.from_numpy(D)\n n_samples, n_features = X.shape\n n_atoms, _ = D.shape\n\n # Normalize rows\n", "probing input new": "def old_omp(X, D, s):\n \"\"\"\n X: data matrix of size (n_samples, n_features)\n D: dictionary of size (n_atoms, n_features)\n s: desired sparsity level\n Returns the sparse code matrix S of size (n_samples, n_atoms)\n \"\"\"\n X = torch.from_numpy(X)\n D = torch.from_numpy(D)\n n_samples, n_features = X.shape\n n_atoms, _ = D.shape\n\n # Normalize rows\n ", "reference": "norms=torch.linalg.norm(D,axis=1,keepdims=True)+1e-6", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "norms=torch.linalg.norm(D,axis=1,keepdims=True)+1e-6", "y_neg": " X_norm = X / torch.norm(X, dim=1, keepdim=True)", "retain": "def old_omp(X, D, s):\n \"\"\"\n X: data matrix of size (n_samples, n_features)\n D: dictionary of size (n_atoms, n_features)\n s: desired sparsity level\n Returns the sparse code matrix S of size (n_samples, n_atoms)\n \"\"\"\n X = torch.from_numpy(X)\n D = torch.from_numpy(D)\n n_samples, n_features = X.shape\n n_atoms, _ = D.shape\n\n # Normalize rows\n norms = torch.linalg.norm(D, axis=1, keepdims=True) + 1e-6\n D2 = D / norms\n\n residuals = X.clone()\n ids = torch.zeros((n_samples, s), dtype=int)\n\n for step in range(s):\n corrs = torch.abs(residuals @ D2.T)\n ids[:, step] = torch.argmax(corrs, axis=1)\n subDs = D2[ids[:, : step + 1]].mT\n m = torch.linalg.lstsq(subDs, X, rcond=None).solution\n residuals = X - (subDs @ m.unsqueeze(2)).squeeze(2)\n\n S = torch.zeros((n_samples, n_atoms), dtype=m.dtype)\n r = torch.arange(n_samples, dtype=int).unsqueeze(-1)\n S[r, ids] = m\n S /= norms.T\n return S.numpy()" }, { "id": 7661, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([torch.tensor(img_idx).unsqueeze(0), src_idx], dim=0)\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), intrinsics_pair, intrinsics_inv_pair, poses_pair, images_gray_pair", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([torch.tensor(img_idx).unsqueeze(0), src_idx], dim=0)\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([torch.tensor(img_idx).unsqueeze(0), src_idx], dim=0)\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([torch.tensor(img_idx).unsqueeze(0), src_idx], dim=0)\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1), intrinsics_pair, intrinsics_inv_pair, poses_pair, images_gray_pair" }, { "id": 7662, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([img_idx.clone().detach().unsqueeze(0), src_idx], dim=0).cuda()\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda(), intrinsics_pair, intrinsics_inv_pair, poses_pair, images_gray_pair", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([img_idx.clone().detach().unsqueeze(0), src_idx], dim=0).cuda()\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([img_idx.clone().detach().unsqueeze(0), src_idx], dim=0).cuda()\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n\n src_idx = self.src_idx[img_idx]\n src_idx = src_idx[:9]\n # src_idx = src_idx[-9:]\n idx_list = torch.cat([img_idx.clone().detach().unsqueeze(0), src_idx], dim=0).cuda()\n\n poses_pair = self.pose_all[idx_list] # [store R^-1 and C]\n intrinsics_pair = self.intrinsics_all[idx_list]\n intrinsics_inv_pair = self.intrinsics_all_inv[idx_list]\n images_gray_pair = self.images_gray[idx_list]\n\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda(), intrinsics_pair, intrinsics_inv_pair, poses_pair, images_gray_pair" }, { "id": 7665, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_edge_vectors_and_lengths(\n positions: torch.Tensor, # [n_nodes, 3]\n edge_index: torch.Tensor, # [2, n_edges]\n shifts: torch.Tensor, # [n_edges, 3]\n normalize: bool = False,\n eps: float = 1e-9,\n) -> Tuple[torch.Tensor, torch.Tensor]:\n sender = edge_index[0]\n receiver = edge_index[1]\n vectors = positions[receiver] - positions[sender] + shifts # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n if normalize:\n vectors_normed = vectors / (lengths + eps)\n return vectors_normed, lengths\n\n return vectors, lengths", "probing input": "def get_edge_vectors_and_lengths(\n positions: torch.Tensor, # [n_nodes, 3]\n edge_index: torch.Tensor, # [2, n_edges]\n shifts: torch.Tensor, # [n_edges, 3]\n normalize: bool = False,\n eps: float = 1e-9,\n) -> Tuple[torch.Tensor, torch.Tensor]:\n sender = edge_index[0]\n receiver = edge_index[1]\n vectors = positions[receiver] - positions[sender] + shifts # [n_edges, 3]\n", "probing input new": "def get_edge_vectors_and_lengths(\n positions: torch.Tensor, # [n_nodes, 3]\n edge_index: torch.Tensor, # [2, n_edges]\n shifts: torch.Tensor, # [n_edges, 3]\n normalize: bool = False,\n eps: float = 1e-9,\n) -> Tuple[torch.Tensor, torch.Tensor]:\n sender = edge_index[0]\n receiver = edge_index[1]\n vectors = positions[receiver] - positions[sender] + shifts # [n_edges, 3]\n lengths = torch.", "reference": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "lengths=torch.linalg.norm(vectors,dim=-1,keepdim=True)", "y_neg": " lengths = torch.norm(vectors, dim=1, p=2, eps=eps) # [n_edges]", "retain": "def get_edge_vectors_and_lengths(\n positions: torch.Tensor, # [n_nodes, 3]\n edge_index: torch.Tensor, # [2, n_edges]\n shifts: torch.Tensor, # [n_edges, 3]\n normalize: bool = False,\n eps: float = 1e-9,\n) -> Tuple[torch.Tensor, torch.Tensor]:\n sender = edge_index[0]\n receiver = edge_index[1]\n vectors = positions[receiver] - positions[sender] + shifts # [n_edges, 3]\n lengths = torch.linalg.norm(vectors, dim=-1, keepdim=True) # [n_edges, 1]\n if normalize:\n vectors_normed = vectors / (lengths + eps)\n return vectors_normed, lengths\n\n return vectors, lengths" }, { "id": 7669, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rot_param_rot_mat(rot):\n '''\n\n :param rot: N x 6\n :return:\n '''\n\n e1 = rot[:,:3]\n e2 = rot[:,3:]\n\n e1d = e1/torch.linalg.norm(e1,dim=1,keepdim=True)\n e3d = torch.cross(e1d, e2, dim=1)/torch.linalg.norm(e2,dim=1,keepdim=True)\n e2d = torch.cross(e3d, e1d)\n\n R = torch.stack([e1d, e2d, e3d],dim=2) # N x 3 x 3\n\n return R", "probing input": "def rot_param_rot_mat(rot):\n '''\n\n :param rot: N x 6\n :return:\n '''\n\n e1 = rot[:,:3]\n e2 = rot[:,3:]\n\n", "probing input new": "def rot_param_rot_mat(rot):\n '''\n\n :param rot: N x 6\n :return:\n '''\n\n e1 = rot[:,:3]\n e2 = rot[:,3:]\n\n e1d = e1/torch.", "reference": "e1d=e1/torch.linalg.norm(e1,dim=1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "e1d=e1/torch.linalg.norm(e1,dim=1,keepdim=True)", "y_neg": " e1d = e1/torch.norm(e1, dim=1, keepdim=True)", "retain": "def rot_param_rot_mat(rot):\n '''\n\n :param rot: N x 6\n :return:\n '''\n\n e1 = rot[:,:3]\n e2 = rot[:,3:]\n\n e1d = e1/torch.linalg.norm(e1,dim=1,keepdim=True)\n e3d = torch.cross(e1d, e2, dim=1)/torch.linalg.norm(e2,dim=1,keepdim=True)\n e2d = torch.cross(e3d, e1d)\n\n R = torch.stack([e1d, e2d, e3d],dim=2) # N x 3 x 3\n\n return R" }, { "id": 7673, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def comp_point_point_error(self, Xt, Yt):\n closest_idx = self.comp_closest_pts_idx_with_split(Xt, Yt)\n pt_pt_vec = Xt - Yt[:, closest_idx] # (3, S) - (3, S) -> (3, S)\n pt_pt_dist = torch.linalg.norm(pt_pt_vec, dim=0)\n eng = torch.mean(pt_pt_dist)\n return eng", "probing input": " def comp_point_point_error(self, Xt, Yt):\n closest_idx = self.comp_closest_pts_idx_with_split(Xt, Yt)\n pt_pt_vec = Xt - Yt[:, closest_idx] # (3, S) - (3, S) -> (3, S)\n", "probing input new": " def comp_point_point_error(self, Xt, Yt):\n closest_idx = self.comp_closest_pts_idx_with_split(Xt, Yt)\n pt_pt_vec = Xt - Yt[:, closest_idx] # (3, S) - (3, S) -> (3, S)\n pt_pt_dist = torch.", "reference": "pt_pt_dist=torch.linalg.norm(pt_pt_vec,dim=0)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "pt_pt_dist=torch.linalg.norm(pt_pt_vec,dim=0)", "y_neg": " pt_pt_dist = torch.norm(pt_pt_vec, p=2, dim=0) # (3, S) -> (3, S)", "retain": " def comp_point_point_error(self, Xt, Yt):\n closest_idx = self.comp_closest_pts_idx_with_split(Xt, Yt)\n pt_pt_vec = Xt - Yt[:, closest_idx] # (3, S) - (3, S) -> (3, S)\n pt_pt_dist = torch.linalg.norm(pt_pt_vec, dim=0)\n eng = torch.mean(pt_pt_dist)\n return eng" }, { "id": 7674, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_accuracy(tensor, ranks):\n \"\"\"\n Given a tensor, this function returns the relative error derived from projecting such\n tensor using HOSVD and then going back to the reconstructed original tensor via\n the inverse projection.\n :param torch.Tensor tensor: the input tensor to be tested on\n :param list[int] ranks: list of the ranks of the individual directional projections\n (len(ranks) must be equal to len(tensor.shape))\n :return: relative error of the method and list of the singular values of each unfolding\n :rtype: float, list[torch.Tensor]\n \"\"\"\n HOSVD = hosvd(ranks)\n HOSVD.fit(tensor, return_S_tensor=True)\n red_tensor = HOSVD.transform(tensor)\n reconstruct_tensor = HOSVD.inverse_transform(red_tensor)\n error = torch.linalg.norm(reconstruct_tensor - tensor)\n relative_error = error / np.linalg.norm(tensor)\n return relative_error, HOSVD.modal_singular_values", "probing input": "def test_accuracy(tensor, ranks):\n \"\"\"\n Given a tensor, this function returns the relative error derived from projecting such\n tensor using HOSVD and then going back to the reconstructed original tensor via\n the inverse projection.\n :param torch.Tensor tensor: the input tensor to be tested on\n :param list[int] ranks: list of the ranks of the individual directional projections\n (len(ranks) must be equal to len(tensor.shape))\n :return: relative error of the method and list of the singular values of each unfolding\n :rtype: float, list[torch.Tensor]\n \"\"\"\n HOSVD = hosvd(ranks)\n HOSVD.fit(tensor, return_S_tensor=True)\n red_tensor = HOSVD.transform(tensor)\n reconstruct_tensor = HOSVD.inverse_transform(red_tensor)\n", "probing input new": "def test_accuracy(tensor, ranks):\n \"\"\"\n Given a tensor, this function returns the relative error derived from projecting such\n tensor using HOSVD and then going back to the reconstructed original tensor via\n the inverse projection.\n :param torch.Tensor tensor: the input tensor to be tested on\n :param list[int] ranks: list of the ranks of the individual directional projections\n (len(ranks) must be equal to len(tensor.shape))\n :return: relative error of the method and list of the singular values of each unfolding\n :rtype: float, list[torch.Tensor]\n \"\"\"\n HOSVD = hosvd(ranks)\n HOSVD.fit(tensor, return_S_tensor=True)\n red_tensor = HOSVD.transform(tensor)\n reconstruct_tensor = HOSVD.inverse_transform(red_tensor)\n error = torch.", "reference": "error=torch.linalg.norm(reconstruct_tensor-tensor)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "error=torch.linalg.norm(reconstruct_tensor-tensor)", "y_neg": " error = torch.norm(tensor - reconstruct_tensor) / torch.norm(tensor)", "retain": "def test_accuracy(tensor, ranks):\n \"\"\"\n Given a tensor, this function returns the relative error derived from projecting such\n tensor using HOSVD and then going back to the reconstructed original tensor via\n the inverse projection.\n :param torch.Tensor tensor: the input tensor to be tested on\n :param list[int] ranks: list of the ranks of the individual directional projections\n (len(ranks) must be equal to len(tensor.shape))\n :return: relative error of the method and list of the singular values of each unfolding\n :rtype: float, list[torch.Tensor]\n \"\"\"\n HOSVD = hosvd(ranks)\n HOSVD.fit(tensor, return_S_tensor=True)\n red_tensor = HOSVD.transform(tensor)\n reconstruct_tensor = HOSVD.inverse_transform(red_tensor)\n error = torch.linalg.norm(reconstruct_tensor - tensor)\n relative_error = error / np.linalg.norm(tensor)\n return relative_error, HOSVD.modal_singular_values" }, { "id": 7676, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _normalize_camera(scene_cameras: PerspectiveCameras, distance=3.5, look_at_optical_center=False):\n '''\n Normalize the camera origins to be roughly distance 1.5 away from origin\n '''\n if look_at_optical_center:\n look_at_center = _get_nearest_centroid(scene_cameras).unsqueeze(-1).unsqueeze(0)\n scene_shift = (scene_cameras.R.permute(0,2,1)@(look_at_center))[:,:,0]\n scene_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T - scene_shift, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n \n cam_dist_mean = torch.mean(torch.linalg.norm(scene_cameras.get_camera_center(), axis=1))\n scale_factor = 1.0 / (cam_dist_mean / distance)\n\n normalized_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T * scale_factor, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n return normalized_cameras", "probing input": "def _normalize_camera(scene_cameras: PerspectiveCameras, distance=3.5, look_at_optical_center=False):\n '''\n Normalize the camera origins to be roughly distance 1.5 away from origin\n '''\n if look_at_optical_center:\n look_at_center = _get_nearest_centroid(scene_cameras).unsqueeze(-1).unsqueeze(0)\n scene_shift = (scene_cameras.R.permute(0,2,1)@(look_at_center))[:,:,0]\n scene_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T - scene_shift, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n \n", "probing input new": "def _normalize_camera(scene_cameras: PerspectiveCameras, distance=3.5, look_at_optical_center=False):\n '''\n Normalize the camera origins to be roughly distance 1.5 away from origin\n '''\n if look_at_optical_center:\n look_at_center = _get_nearest_centroid(scene_cameras).unsqueeze(-1).unsqueeze(0)\n scene_shift = (scene_cameras.R.permute(0,2,1)@(look_at_center))[:,:,0]\n scene_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T - scene_shift, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n \n cam_dist_mean = torch.mean(torch.", "reference": "cam_dist_mean=torch.mean(torch.linalg.norm(scene_cameras.get_camera_center(),axis=1))", "reference dict": { "normalized_cameras": "PerspectiveCameras", "scene_cameras": "PerspectiveCameras" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "cam_dist_mean=torch.mean(torch.linalg.norm(scene_cameras.get_camera_center(),axis=1))", "y_neg": " cam_dist_mean = torch.mean(torch.norm(scene_cameras.T, dim=-1))", "retain": "def _normalize_camera(scene_cameras: PerspectiveCameras, distance=3.5, look_at_optical_center=False):\n '''\n Normalize the camera origins to be roughly distance 1.5 away from origin\n '''\n if look_at_optical_center:\n look_at_center = _get_nearest_centroid(scene_cameras).unsqueeze(-1).unsqueeze(0)\n scene_shift = (scene_cameras.R.permute(0,2,1)@(look_at_center))[:,:,0]\n scene_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T - scene_shift, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n \n cam_dist_mean = torch.mean(torch.linalg.norm(scene_cameras.get_camera_center(), axis=1))\n scale_factor = 1.0 / (cam_dist_mean / distance)\n\n normalized_cameras = PerspectiveCameras(\n R = scene_cameras.R, \n T = scene_cameras.T * scale_factor, \n focal_length = scene_cameras.focal_length,\n principal_point = scene_cameras.principal_point,\n image_size = scene_cameras.image_size,\n device = scene_cameras.device,\n )\n return normalized_cameras" }, { "id": 7678, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compare_traj(ref_traj, states_reached, robot_model, experiment_name=\"\"):\n \"\"\"Compute and print error between state log and the reference trajectory\"\"\"\n # Compute error\n pos_err = torch.zeros(len(states_reached))\n ori_err = torch.zeros(len(states_reached))\n for i in range(len(states_reached)):\n joint_pos_actual = torch.Tensor(states_reached[i][1].joint_positions)\n pose_actual = torch.cat(robot_model.forward_kinematics(joint_pos_actual))\n pose_desired = ref_traj[states_reached[i][0]]\n\n pos_diff = pose_desired[:3] - pose_actual[:3]\n ori_diff = R.from_quat(pose_actual[3:]).inv() * R.from_quat(pose_desired[3:])\n pos_err[i] = torch.linalg.norm(pos_diff)\n ori_err[i] = torch.linalg.norm(ori_diff.as_rotvec())\n\n # Convert, compute, and print stats\n pos_err_mm = pos_err * 1000.0\n ori_err_deg = ori_err * 180 / np.pi\n\n pos_err_mean = torch.mean(pos_err_mm)\n pos_err_std = torch.std(pos_err_mm)\n pos_err_max = torch.max(pos_err_mm)\n ori_err_mean = torch.mean(ori_err_deg)\n ori_err_std = torch.std(ori_err_deg)\n ori_err_max = torch.max(ori_err_deg)\n\n print(f\"=== {experiment_name} tracking results ===\")\n print(\n f\"\\tPos error(mm): mean={pos_err_mean:.2f}, std={pos_err_std:.2f}, max={pos_err_max:.2f}\"\n )\n print(\n f\"\\tOri error(deg): mean={ori_err_mean:.2f}, std={ori_err_std:.2f}, max={ori_err_max:.2f}\"\n )", "probing input": "def compare_traj(ref_traj, states_reached, robot_model, experiment_name=\"\"):\n \"\"\"Compute and print error between state log and the reference trajectory\"\"\"\n # Compute error\n pos_err = torch.zeros(len(states_reached))\n ori_err = torch.zeros(len(states_reached))\n for i in range(len(states_reached)):\n joint_pos_actual = torch.Tensor(states_reached[i][1].joint_positions)\n pose_actual = torch.cat(robot_model.forward_kinematics(joint_pos_actual))\n pose_desired = ref_traj[states_reached[i][0]]\n\n pos_diff = pose_desired[:3] - pose_actual[:3]\n ori_diff = R.from_quat(pose_actual[3:]).inv() * R.from_quat(pose_desired[3:])\n", "probing input new": "def compare_traj(ref_traj, states_reached, robot_model, experiment_name=\"\"):\n \"\"\"Compute and print error between state log and the reference trajectory\"\"\"\n # Compute error\n pos_err = torch.zeros(len(states_reached))\n ori_err = torch.zeros(len(states_reached))\n for i in range(len(states_reached)):\n joint_pos_actual = torch.Tensor(states_reached[i][1].joint_positions)\n pose_actual = torch.cat(robot_model.forward_kinematics(joint_pos_actual))\n pose_desired = ref_traj[states_reached[i][0]]\n\n pos_diff = pose_desired[:3] - pose_actual[:3]\n ori_diff = R.from_quat(pose_actual[3:]).inv() * R.from_quat(pose_desired[3:])\n pos_err[i] = torch.", "reference": "pos_err[i]=torch.linalg.norm(pos_diff)", "reference dict": { "joint_pos_actual": "torch.Tensor" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "pos_err[i]=torch.linalg.norm(pos_diff)", "y_neg": " pos_err[i] = torch.norm(pos_diff)", "retain": "def compare_traj(ref_traj, states_reached, robot_model, experiment_name=\"\"):\n \"\"\"Compute and print error between state log and the reference trajectory\"\"\"\n # Compute error\n pos_err = torch.zeros(len(states_reached))\n ori_err = torch.zeros(len(states_reached))\n for i in range(len(states_reached)):\n joint_pos_actual = torch.Tensor(states_reached[i][1].joint_positions)\n pose_actual = torch.cat(robot_model.forward_kinematics(joint_pos_actual))\n pose_desired = ref_traj[states_reached[i][0]]\n\n pos_diff = pose_desired[:3] - pose_actual[:3]\n ori_diff = R.from_quat(pose_actual[3:]).inv() * R.from_quat(pose_desired[3:])\n pos_err[i] = torch.linalg.norm(pos_diff)\n ori_err[i] = torch.linalg.norm(ori_diff.as_rotvec())\n\n # Convert, compute, and print stats\n pos_err_mm = pos_err * 1000.0\n ori_err_deg = ori_err * 180 / np.pi\n\n pos_err_mean = torch.mean(pos_err_mm)\n pos_err_std = torch.std(pos_err_mm)\n pos_err_max = torch.max(pos_err_mm)\n ori_err_mean = torch.mean(ori_err_deg)\n ori_err_std = torch.std(ori_err_deg)\n ori_err_max = torch.max(ori_err_deg)\n\n print(f\"=== {experiment_name} tracking results ===\")\n print(\n f\"\\tPos error(mm): mean={pos_err_mean:.2f}, std={pos_err_std:.2f}, max={pos_err_max:.2f}\"\n )\n print(\n f\"\\tOri error(deg): mean={ori_err_mean:.2f}, std={ori_err_std:.2f}, max={ori_err_max:.2f}\"\n )" }, { "id": 7685, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7686, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_sample_grads_sums(model, loss_fn, data, targets, additional_info, num_class, grad_epoch):\n \"\"\" manually process each sample with per sample gradient, naive implementation \"\"\"\n if targets.max() >= num_class:\n raise ValueError(\"targets max value should be less than num_class\")\n\n batch_size = data.shape[0]\n grad_sum = 0\n grad_sum_squared = 0\n grad_sum_clean = 0\n grad_sum_squared_clean = 0\n grad_sum_bd = 0\n grad_sum_squared_bd = 0\n grad_sum_class = [0 for _ in range(num_class)]\n grad_sum_squared_class = [0 for _ in range(num_class)]\n\n ori_idx, poi_indicator, ori_target = additional_info\n grad_dis_clean = []\n grad_dis_bd = []\n grad_dis_class = [[] for _ in range(num_class)]\n\n grad_cos_clean = []\n grad_cos_bd = []\n grad_cos_class = [[] for _ in range(num_class)]\n\n for i in range(batch_size):\n grad_i = compute_grad(model, loss_fn, data[i], targets[i])\n grad_sum += grad_i\n grad_sum_squared += grad_i.square()\n if poi_indicator[i] == 1:\n grad_sum_bd += grad_i\n grad_sum_squared_bd += grad_i.square()\n grad_dis_bd.append(torch.linalg.norm(grad_i.flatten()))\n grad_cos_bd.append(F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n else:\n grad_sum_clean += grad_i\n grad_sum_squared_clean += grad_i.square()\n grad_dis_clean.append(torch.linalg.norm(grad_i.flatten()))\n grad_cos_clean.append(F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n \n grad_sum_class[targets[i]] += grad_i\n grad_sum_squared_class[targets[i]] += grad_i.square()\n grad_dis_class[targets[i]].append(\n torch.linalg.norm(grad_i.flatten()))\n\n grad_cos_class[targets[i]].append(\n F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n\n # To avoid GPU memory overflow, we use numpy instead of torch.\n # grad_sum = grad_sum.cpu().numpy()\n # grad_sum_squared = grad_sum_squared.cpu().numpy()\n # grad_sum_clean = grad_sum_clean.cpu().numpy()\n # grad_sum_squared_clean = grad_sum_squared_clean.cpu().numpy()\n # grad_sum_bd = grad_sum_bd.cpu().numpy()\n # grad_sum_squared_bd = grad_sum_squared_bd.cpu().numpy()\n return grad_sum, grad_sum_squared, grad_sum_clean, grad_sum_squared_clean, grad_sum_bd, grad_sum_squared_bd, grad_dis_clean, grad_dis_bd, grad_sum_class, grad_sum_squared_class, grad_dis_class, grad_cos_clean, grad_cos_bd, grad_cos_class", "probing input": "def compute_sample_grads_sums(model, loss_fn, data, targets, additional_info, num_class, grad_epoch):\n \"\"\" manually process each sample with per sample gradient, naive implementation \"\"\"\n if targets.max() >= num_class:\n raise ValueError(\"targets max value should be less than num_class\")\n\n batch_size = data.shape[0]\n grad_sum = 0\n grad_sum_squared = 0\n grad_sum_clean = 0\n grad_sum_squared_clean = 0\n grad_sum_bd = 0\n grad_sum_squared_bd = 0\n grad_sum_class = [0 for _ in range(num_class)]\n grad_sum_squared_class = [0 for _ in range(num_class)]\n\n ori_idx, poi_indicator, ori_target = additional_info\n grad_dis_clean = []\n grad_dis_bd = []\n grad_dis_class = [[] for _ in range(num_class)]\n\n grad_cos_clean = []\n grad_cos_bd = []\n grad_cos_class = [[] for _ in range(num_class)]\n\n for i in range(batch_size):\n grad_i = compute_grad(model, loss_fn, data[i], targets[i])\n grad_sum += grad_i\n grad_sum_squared += grad_i.square()\n if poi_indicator[i] == 1:\n grad_sum_bd += grad_i\n grad_sum_squared_bd += grad_i.square()\n", "probing input new": "def compute_sample_grads_sums(model, loss_fn, data, targets, additional_info, num_class, grad_epoch):\n \"\"\" manually process each sample with per sample gradient, naive implementation \"\"\"\n if targets.max() >= num_class:\n raise ValueError(\"targets max value should be less than num_class\")\n\n batch_size = data.shape[0]\n grad_sum = 0\n grad_sum_squared = 0\n grad_sum_clean = 0\n grad_sum_squared_clean = 0\n grad_sum_bd = 0\n grad_sum_squared_bd = 0\n grad_sum_class = [0 for _ in range(num_class)]\n grad_sum_squared_class = [0 for _ in range(num_class)]\n\n ori_idx, poi_indicator, ori_target = additional_info\n grad_dis_clean = []\n grad_dis_bd = []\n grad_dis_class = [[] for _ in range(num_class)]\n\n grad_cos_clean = []\n grad_cos_bd = []\n grad_cos_class = [[] for _ in range(num_class)]\n\n for i in range(batch_size):\n grad_i = compute_grad(model, loss_fn, data[i], targets[i])\n grad_sum += grad_i\n grad_sum_squared += grad_i.square()\n if poi_indicator[i] == 1:\n grad_sum_bd += grad_i\n grad_sum_squared_bd += grad_i.square()\n grad_dis_bd.append(torch.", "reference": "grad_dis_bd.append(torch.linalg.norm(grad_i.flatten()))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "grad_dis_bd.append(torch.linalg.norm(grad_i.flatten()))", "y_neg": " grad_dis_bd.append(torch.norm(grad_i))", "retain": "def compute_sample_grads_sums(model, loss_fn, data, targets, additional_info, num_class, grad_epoch):\n \"\"\" manually process each sample with per sample gradient, naive implementation \"\"\"\n if targets.max() >= num_class:\n raise ValueError(\"targets max value should be less than num_class\")\n\n batch_size = data.shape[0]\n grad_sum = 0\n grad_sum_squared = 0\n grad_sum_clean = 0\n grad_sum_squared_clean = 0\n grad_sum_bd = 0\n grad_sum_squared_bd = 0\n grad_sum_class = [0 for _ in range(num_class)]\n grad_sum_squared_class = [0 for _ in range(num_class)]\n\n ori_idx, poi_indicator, ori_target = additional_info\n grad_dis_clean = []\n grad_dis_bd = []\n grad_dis_class = [[] for _ in range(num_class)]\n\n grad_cos_clean = []\n grad_cos_bd = []\n grad_cos_class = [[] for _ in range(num_class)]\n\n for i in range(batch_size):\n grad_i = compute_grad(model, loss_fn, data[i], targets[i])\n grad_sum += grad_i\n grad_sum_squared += grad_i.square()\n if poi_indicator[i] == 1:\n grad_sum_bd += grad_i\n grad_sum_squared_bd += grad_i.square()\n grad_dis_bd.append(torch.linalg.norm(grad_i.flatten()))\n grad_cos_bd.append(F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n else:\n grad_sum_clean += grad_i\n grad_sum_squared_clean += grad_i.square()\n grad_dis_clean.append(torch.linalg.norm(grad_i.flatten()))\n grad_cos_clean.append(F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n \n grad_sum_class[targets[i]] += grad_i\n grad_sum_squared_class[targets[i]] += grad_i.square()\n grad_dis_class[targets[i]].append(\n torch.linalg.norm(grad_i.flatten()))\n\n grad_cos_class[targets[i]].append(\n F.cosine_similarity(grad_i.flatten(), grad_epoch.flatten(),dim=0))\n\n # To avoid GPU memory overflow, we use numpy instead of torch.\n # grad_sum = grad_sum.cpu().numpy()\n # grad_sum_squared = grad_sum_squared.cpu().numpy()\n # grad_sum_clean = grad_sum_clean.cpu().numpy()\n # grad_sum_squared_clean = grad_sum_squared_clean.cpu().numpy()\n # grad_sum_bd = grad_sum_bd.cpu().numpy()\n # grad_sum_squared_bd = grad_sum_squared_bd.cpu().numpy()\n return grad_sum, grad_sum_squared, grad_sum_clean, grad_sum_squared_clean, grad_sum_bd, grad_sum_squared_bd, grad_dis_clean, grad_dis_bd, grad_sum_class, grad_sum_squared_class, grad_dis_class, grad_cos_clean, grad_cos_bd, grad_cos_class" }, { "id": 7687, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def normalize_quat(quats):\n dtype = quats.dtype\n quats = quats.float()\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n quats = quats.type(dtype)\n return quats", "probing input": " def normalize_quat(quats):\n dtype = quats.dtype\n quats = quats.float()\n", "probing input new": " def normalize_quat(quats):\n dtype = quats.dtype\n quats = quats.float()\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def normalize_quat(quats):\n dtype = quats.dtype\n quats = quats.float()\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n quats = quats.type(dtype)\n return quats" }, { "id": 7690, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\n \"Incorrectly shaped rotation matrix or quaternion\"\n )\n\n # Force full-precision\n if quats is not None:\n quats = quats.to(dtype=torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.to(dtype=torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7691, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_circle_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 2)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 4.0)", "probing input": "def test_circle_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 2)\n", "probing input new": "def test_circle_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 2)\n assert all(torch.", "reference": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=4.0)", "reference dict": { "C": "Circle" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.linalg.norm(points.as_tensor,dim=1)<=4.0)", "y_neg": " assert all(torch.norm(point - [0, 0], 2) <= 4 for point in points)", "retain": "def test_circle_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4)\n points = C.sample_random_uniform(n=40)\n assert points.as_tensor.shape == (40, 2)\n assert all(torch.linalg.norm(points.as_tensor, dim=1) <= 4.0)" }, { "id": 7695, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_circle_boundary_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 2)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))", "probing input": "def test_circle_boundary_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 2)\n", "probing input new": "def test_circle_boundary_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 2)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center), 4, atol=1e-6) for p in points)", "retain": "def test_circle_boundary_random_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(n=10)\n assert points.as_tensor.shape == (10, 2)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))" }, { "id": 7696, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_circle_boundary_random_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))", "probing input": "def test_circle_boundary_random_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n", "probing input new": "def test_circle_boundary_random_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center, p=2), 0) for p in points)", "retain": "def test_circle_boundary_random_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_random_uniform(d=15)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1), torch.tensor(4.0)))" }, { "id": 7697, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_circle_boundary_grid_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 2)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))", "probing input": "def test_circle_boundary_grid_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 2)\n", "probing input new": "def test_circle_boundary_grid_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 2)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - [0, 0]), 4, atol=1e-6) for p in points)", "retain": "def test_circle_boundary_grid_sampling_with_n():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(n=30)\n assert points.as_tensor.shape == (30, 2)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))" }, { "id": 7698, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_circle_boundary_grid_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))", "probing input": "def test_circle_boundary_grid_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(d=13)\n", "probing input new": "def test_circle_boundary_grid_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(points.as_tensor,dim=1),torch.tensor(4.0)))", "y_neg": " assert all(torch.isclose(torch.norm(p - C.center), 4, atol=1e-6) for p in points)", "retain": "def test_circle_boundary_grid_sampling_with_d():\n C = Circle(R2('x'), [0, 0], 4).boundary\n points = C.sample_grid(d=13)\n assert all(torch.isclose(torch.linalg.norm(points.as_tensor, dim=1),\n torch.tensor(4.0)))" }, { "id": 7699, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_parallelogram_normals_if_corners_change():\n P = Parallelogram(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0],\n [3.5, 1], [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = P.normal(points, time)\n expected_normals = torch.tensor([[-0.7071, 0.7071], [-0.9239, 0.3827],\n [-0.2298, -0.9732], [ 0.0000, 1.0000],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.linalg.norm(normals, dim=1), one, atol=0.0001))\n assert torch.all(torch.isclose(expected_normals, normals, atol=0.0001))", "probing input": "def test_parallelogram_normals_if_corners_change():\n P = Parallelogram(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0],\n [3.5, 1], [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = P.normal(points, time)\n expected_normals = torch.tensor([[-0.7071, 0.7071], [-0.9239, 0.3827],\n [-0.2298, -0.9732], [ 0.0000, 1.0000],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n", "probing input new": "def test_parallelogram_normals_if_corners_change():\n P = Parallelogram(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0],\n [3.5, 1], [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = P.normal(points, time)\n expected_normals = torch.tensor([[-0.7071, 0.7071], [-0.9239, 0.3827],\n [-0.2298, -0.9732], [ 0.0000, 1.0000],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(normals,dim=1),one,atol=0.0001))", "reference dict": { "points": "Points", "time": "Points" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(normals,dim=1),one,atol=0.0001))", "y_neg": " assert all(torch.isclose(torch.norm(normal - expected_normal, 2), one, atol=1e-5)", "retain": "def test_parallelogram_normals_if_corners_change():\n P = Parallelogram(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0],\n [3.5, 1], [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = P.normal(points, time)\n expected_normals = torch.tensor([[-0.7071, 0.7071], [-0.9239, 0.3827],\n [-0.2298, -0.9732], [ 0.0000, 1.0000],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.linalg.norm(normals, dim=1), one, atol=0.0001))\n assert torch.all(torch.isclose(expected_normals, normals, atol=0.0001))" }, { "id": 7700, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_triangle_normals_if_corners_change():\n T = Triangle(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0], [2, 0.5], \n [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = T.normal(points, time)\n expected_normals = torch.tensor([[-0.3827, 0.9239], [-0.8112, 0.5847],\n [-0.2298, -0.9732], [ 0.2425, 0.9701],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.linalg.norm(normals, dim=1), one, atol=0.0001))\n assert torch.all(torch.isclose(expected_normals, normals, atol=0.0001))", "probing input": "def test_triangle_normals_if_corners_change():\n T = Triangle(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0], [2, 0.5], \n [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = T.normal(points, time)\n expected_normals = torch.tensor([[-0.3827, 0.9239], [-0.8112, 0.5847],\n [-0.2298, -0.9732], [ 0.2425, 0.9701],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n", "probing input new": "def test_triangle_normals_if_corners_change():\n T = Triangle(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0], [2, 0.5], \n [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = T.normal(points, time)\n expected_normals = torch.tensor([[-0.3827, 0.9239], [-0.8112, 0.5847],\n [-0.2298, -0.9732], [ 0.2425, 0.9701],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.", "reference": "assertall(torch.isclose(torch.linalg.norm(normals,dim=1),one,atol=0.0001))", "reference dict": { "points": "Points", "time": "Points" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "assertall(torch.isclose(torch.linalg.norm(normals,dim=1),one,atol=0.0001))", "y_neg": " assert all(torch.isclose(torch.norm(normal, 2), one, atol=1e-5))", "retain": "def test_triangle_normals_if_corners_change():\n T = Triangle(R2('x'), origin, vec_1, [0, 1]).boundary\n points = torch.tensor([[0, 1], [0, 1], [2.0, 0.0], [2, 0.5], \n [0.5, 0.5], [0.0, 0.8]])\n points = Points(points, R2('x'))\n time = Points(torch.tensor([0, 1, 2.0, 3.0, 1.0, 0.0]).reshape(-1, 1), R1('t'))\n normals = T.normal(points, time)\n expected_normals = torch.tensor([[-0.3827, 0.9239], [-0.8112, 0.5847],\n [-0.2298, -0.9732], [ 0.2425, 0.9701],\n [-0.7071, -0.7071], [-1.0000, 0.0000]])\n assert normals.shape == (6, 2)\n one = torch.tensor(1.0)\n assert all(torch.isclose(torch.linalg.norm(normals, dim=1), one, atol=0.0001))\n assert torch.all(torch.isclose(expected_normals, normals, atol=0.0001))" }, { "id": 7703, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, output, params, input_keypoints, bbox, \n reprojection_weight=100., regularize_weight=60.0, \n consistency_weight=10.0, sprior_weight=0.04, \n smooth_weight=20.0, sigma=100):\n \n pose, shape, cam = params\n scale = bbox[..., 2:].unsqueeze(-1) * 200.\n \n # Loss 1. Data term\n pred_keypoints = output.full_joints2d[..., :17, :]\n joints_conf = input_keypoints[..., -1:]\n reprojection_error = gmof(pred_keypoints - input_keypoints[..., :-1], sigma)\n reprojection_error = ((reprojection_error * joints_conf) / scale).mean()\n \n # Loss 2. Regularization term\n regularize_error = torch.linalg.norm(pose - self.init_pose, dim=-1).mean()\n \n # Loss 3. Shape prior and consistency error\n consistency_error = shape.std(dim=1).mean()\n sprior_error = torch.linalg.norm(shape, dim=-1).mean()\n shape_error = sprior_weight * sprior_error + consistency_weight * consistency_error\n \n # Loss 4. Smooth loss\n pose_diff = compute_jitter(pose).mean()\n cam_diff = compute_jitter(cam).mean()\n smooth_error = pose_diff + cam_diff\n \n # Sum up losses\n loss = {\n 'reprojection': reprojection_weight * reprojection_error,\n 'regularize': regularize_weight * regularize_error,\n 'shape': shape_error,\n 'smooth': smooth_weight * smooth_error\n }\n \n return loss", "probing input": " def forward(self, output, params, input_keypoints, bbox, \n reprojection_weight=100., regularize_weight=60.0, \n consistency_weight=10.0, sprior_weight=0.04, \n smooth_weight=20.0, sigma=100):\n \n pose, shape, cam = params\n scale = bbox[..., 2:].unsqueeze(-1) * 200.\n \n # Loss 1. Data term\n pred_keypoints = output.full_joints2d[..., :17, :]\n joints_conf = input_keypoints[..., -1:]\n reprojection_error = gmof(pred_keypoints - input_keypoints[..., :-1], sigma)\n reprojection_error = ((reprojection_error * joints_conf) / scale).mean()\n \n # Loss 2. Regularization term\n", "probing input new": " def forward(self, output, params, input_keypoints, bbox, \n reprojection_weight=100., regularize_weight=60.0, \n consistency_weight=10.0, sprior_weight=0.04, \n smooth_weight=20.0, sigma=100):\n \n pose, shape, cam = params\n scale = bbox[..., 2:].unsqueeze(-1) * 200.\n \n # Loss 1. Data term\n pred_keypoints = output.full_joints2d[..., :17, :]\n joints_conf = input_keypoints[..., -1:]\n reprojection_error = gmof(pred_keypoints - input_keypoints[..., :-1], sigma)\n reprojection_error = ((reprojection_error * joints_conf) / scale).mean()\n \n # Loss 2. Regularization term\n regularize_error = torch.", "reference": "regularize_error=torch.linalg.norm(pose-self.init_pose,dim=-1).mean()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "regularize_error=torch.linalg.norm(pose-self.init_pose,dim=-1).mean()", "y_neg": " regularize_error = torch.norm(output.full_joints2d - input_keypoints, p='fro', dim=-1).mean()", "retain": " def forward(self, output, params, input_keypoints, bbox, \n reprojection_weight=100., regularize_weight=60.0, \n consistency_weight=10.0, sprior_weight=0.04, \n smooth_weight=20.0, sigma=100):\n \n pose, shape, cam = params\n scale = bbox[..., 2:].unsqueeze(-1) * 200.\n \n # Loss 1. Data term\n pred_keypoints = output.full_joints2d[..., :17, :]\n joints_conf = input_keypoints[..., -1:]\n reprojection_error = gmof(pred_keypoints - input_keypoints[..., :-1], sigma)\n reprojection_error = ((reprojection_error * joints_conf) / scale).mean()\n \n # Loss 2. Regularization term\n regularize_error = torch.linalg.norm(pose - self.init_pose, dim=-1).mean()\n \n # Loss 3. Shape prior and consistency error\n consistency_error = shape.std(dim=1).mean()\n sprior_error = torch.linalg.norm(shape, dim=-1).mean()\n shape_error = sprior_weight * sprior_error + consistency_weight * consistency_error\n \n # Loss 4. Smooth loss\n pose_diff = compute_jitter(pose).mean()\n cam_diff = compute_jitter(cam).mean()\n smooth_error = pose_diff + cam_diff\n \n # Sum up losses\n loss = {\n 'reprojection': reprojection_weight * reprojection_error,\n 'regularize': regularize_weight * regularize_error,\n 'shape': shape_error,\n 'smooth': smooth_weight * smooth_error\n }\n \n return loss" }, { "id": 7704, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cal_skel_direction(joints, children, parents, num_joint, mt_child_joints, \n exclude_root=False, leaf_idx=None):\n \"\"\" Calculate unit bone directions of the whole skeleton from 3D joints.\n \n Args: \n - joints: (B, J, 3), 3D joints.\n - mt_child_joints: list, index of joints with multiple children.\n - exclude_root: bool, if True then the root orientation is not calculated.\n - leaf_idx: list, index of leaf joints.\n \n Returns:\n - st_orit_list: (B, N_single 3, 1), where N_single is the number of single-child node.\n - mt_orit_list: list, each element is (B, 3, Nc), where Nc is the number of its children.\n \"\"\"\n\n eps = 1e-8\n\n sg_child_joints = []\n for j in range(num_joint):\n if j in mt_child_joints: continue\n if leaf_idx is not None and j in leaf_idx: continue\n sg_child_joints.append(j)\n\n # single-child node\n sg_orit_list = [] \n for pa in sg_child_joints:\n ch = children[pa]\n sg_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n unit_sg_pa_orit = sg_pa_orit / (torch.linalg.norm(sg_pa_orit, dim=-1, keepdim=True) + eps)\n sg_orit_list.append(unit_sg_pa_orit)\n sg_orit_list = torch.stack(sg_orit_list, dim=0).transpose(0, 1).unsqueeze(-1)\n \n # multi-child node\n if exclude_root:\n new_mt_child_joints = mt_child_joints[1:]\n else:\n new_mt_child_joints = mt_child_joints\n mt_orit_list = [[] for i in range(len(new_mt_child_joints))]\n for i, pa in enumerate(new_mt_child_joints):\n for ch, map_pa in enumerate(parents):\n if pa == map_pa:\n mt_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n unit_mt_pa_orit = mt_pa_orit / (torch.linalg.norm(mt_pa_orit, dim=-1, keepdim=True) + eps)\n mt_orit_list[i].append(unit_mt_pa_orit)\n\n mt_orit_list = [torch.stack(imt, dim=0).permute(1, 2, 0) for imt in mt_orit_list] # list of (B, 3, Nc)\n \n return sg_orit_list, mt_orit_list", "probing input": "def cal_skel_direction(joints, children, parents, num_joint, mt_child_joints, \n exclude_root=False, leaf_idx=None):\n \"\"\" Calculate unit bone directions of the whole skeleton from 3D joints.\n \n Args: \n - joints: (B, J, 3), 3D joints.\n - mt_child_joints: list, index of joints with multiple children.\n - exclude_root: bool, if True then the root orientation is not calculated.\n - leaf_idx: list, index of leaf joints.\n \n Returns:\n - st_orit_list: (B, N_single 3, 1), where N_single is the number of single-child node.\n - mt_orit_list: list, each element is (B, 3, Nc), where Nc is the number of its children.\n \"\"\"\n\n eps = 1e-8\n\n sg_child_joints = []\n for j in range(num_joint):\n if j in mt_child_joints: continue\n if leaf_idx is not None and j in leaf_idx: continue\n sg_child_joints.append(j)\n\n # single-child node\n sg_orit_list = [] \n for pa in sg_child_joints:\n ch = children[pa]\n sg_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n", "probing input new": "def cal_skel_direction(joints, children, parents, num_joint, mt_child_joints, \n exclude_root=False, leaf_idx=None):\n \"\"\" Calculate unit bone directions of the whole skeleton from 3D joints.\n \n Args: \n - joints: (B, J, 3), 3D joints.\n - mt_child_joints: list, index of joints with multiple children.\n - exclude_root: bool, if True then the root orientation is not calculated.\n - leaf_idx: list, index of leaf joints.\n \n Returns:\n - st_orit_list: (B, N_single 3, 1), where N_single is the number of single-child node.\n - mt_orit_list: list, each element is (B, 3, Nc), where Nc is the number of its children.\n \"\"\"\n\n eps = 1e-8\n\n sg_child_joints = []\n for j in range(num_joint):\n if j in mt_child_joints: continue\n if leaf_idx is not None and j in leaf_idx: continue\n sg_child_joints.append(j)\n\n # single-child node\n sg_orit_list = [] \n for pa in sg_child_joints:\n ch = children[pa]\n sg_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n unit_sg_pa_orit = sg_pa_orit / (torch.", "reference": "unit_sg_pa_orit=sg_pa_orit/(torch.linalg.norm(sg_pa_orit,dim=-1,keepdim=True)+eps)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "unit_sg_pa_orit=sg_pa_orit/(torch.linalg.norm(sg_pa_orit,dim=-1,keepdim=True)+eps)", "y_neg": " unit_sg_pa_orit = sg_pa_orit / (torch.norm(sg_pa_orit, dim=-1, keepdim=True) + eps)", "retain": "def cal_skel_direction(joints, children, parents, num_joint, mt_child_joints, \n exclude_root=False, leaf_idx=None):\n \"\"\" Calculate unit bone directions of the whole skeleton from 3D joints.\n \n Args: \n - joints: (B, J, 3), 3D joints.\n - mt_child_joints: list, index of joints with multiple children.\n - exclude_root: bool, if True then the root orientation is not calculated.\n - leaf_idx: list, index of leaf joints.\n \n Returns:\n - st_orit_list: (B, N_single 3, 1), where N_single is the number of single-child node.\n - mt_orit_list: list, each element is (B, 3, Nc), where Nc is the number of its children.\n \"\"\"\n\n eps = 1e-8\n\n sg_child_joints = []\n for j in range(num_joint):\n if j in mt_child_joints: continue\n if leaf_idx is not None and j in leaf_idx: continue\n sg_child_joints.append(j)\n\n # single-child node\n sg_orit_list = [] \n for pa in sg_child_joints:\n ch = children[pa]\n sg_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n unit_sg_pa_orit = sg_pa_orit / (torch.linalg.norm(sg_pa_orit, dim=-1, keepdim=True) + eps)\n sg_orit_list.append(unit_sg_pa_orit)\n sg_orit_list = torch.stack(sg_orit_list, dim=0).transpose(0, 1).unsqueeze(-1)\n \n # multi-child node\n if exclude_root:\n new_mt_child_joints = mt_child_joints[1:]\n else:\n new_mt_child_joints = mt_child_joints\n mt_orit_list = [[] for i in range(len(new_mt_child_joints))]\n for i, pa in enumerate(new_mt_child_joints):\n for ch, map_pa in enumerate(parents):\n if pa == map_pa:\n mt_pa_orit = joints[:, ch, :] - joints[:, pa, :]\n unit_mt_pa_orit = mt_pa_orit / (torch.linalg.norm(mt_pa_orit, dim=-1, keepdim=True) + eps)\n mt_orit_list[i].append(unit_mt_pa_orit)\n\n mt_orit_list = [torch.stack(imt, dim=0).permute(1, 2, 0) for imt in mt_orit_list] # list of (B, 3, Nc)\n \n return sg_orit_list, mt_orit_list" }, { "id": 7705, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cal_bone_direction(parent_pose, children_pose):\n \"\"\" Calculate unit bone directions from adjacent 3D joints.\n \n Args:\n - parent_pose: (B, 1, 3)\n - children_pose: (B, Nc, 3), where Nc is the number of children.\n\n Returns:\n - orit: (B, 3, Nc), The 3D direction vector of bones.\n \"\"\"\n\n orit = children_pose - parent_pose # broadcast\n orit = orit / (torch.linalg.norm(orit, dim=-1, keepdim=True) + 1e-8)\n orit = orit.permute(0, 2, 1)\n\n return orit", "probing input": "def cal_bone_direction(parent_pose, children_pose):\n \"\"\" Calculate unit bone directions from adjacent 3D joints.\n \n Args:\n - parent_pose: (B, 1, 3)\n - children_pose: (B, Nc, 3), where Nc is the number of children.\n\n Returns:\n - orit: (B, 3, Nc), The 3D direction vector of bones.\n \"\"\"\n\n orit = children_pose - parent_pose # broadcast\n", "probing input new": "def cal_bone_direction(parent_pose, children_pose):\n \"\"\" Calculate unit bone directions from adjacent 3D joints.\n \n Args:\n - parent_pose: (B, 1, 3)\n - children_pose: (B, Nc, 3), where Nc is the number of children.\n\n Returns:\n - orit: (B, 3, Nc), The 3D direction vector of bones.\n \"\"\"\n\n orit = children_pose - parent_pose # broadcast\n orit = orit / (torch.", "reference": "orit=orit/(torch.linalg.norm(orit,dim=-1,keepdim=True)+1e-8)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "orit=orit/(torch.linalg.norm(orit,dim=-1,keepdim=True)+1e-8)", "y_neg": " orit = orit / (torch.norm(orit, dim=2, keepdim=True) + 1e-10) # normalize", "retain": "def cal_bone_direction(parent_pose, children_pose):\n \"\"\" Calculate unit bone directions from adjacent 3D joints.\n \n Args:\n - parent_pose: (B, 1, 3)\n - children_pose: (B, Nc, 3), where Nc is the number of children.\n\n Returns:\n - orit: (B, 3, Nc), The 3D direction vector of bones.\n \"\"\"\n\n orit = children_pose - parent_pose # broadcast\n orit = orit / (torch.linalg.norm(orit, dim=-1, keepdim=True) + 1e-8)\n orit = orit.permute(0, 2, 1)\n\n return orit" }, { "id": 7708, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _encode_prompt(\n self,\n prompt,\n device,\n num_images_per_prompt,\n do_classifier_free_guidance,\n ):\n len(prompt) if isinstance(prompt, list) else 1\n\n # YiYi Notes: set pad_token_id to be 0, not sure why I can't set in the config file\n self.tokenizer.pad_token_id = 0\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n untruncated_ids = self.tokenizer(prompt, padding=\"longest\", return_tensors=\"pt\").input_ids\n\n if untruncated_ids.shape[-1] >= text_input_ids.shape[-1] and not torch.equal(text_input_ids, untruncated_ids):\n removed_text = self.tokenizer.batch_decode(untruncated_ids[:, self.tokenizer.model_max_length - 1 : -1])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n\n text_encoder_output = self.text_encoder(text_input_ids.to(device))\n prompt_embeds = text_encoder_output.text_embeds\n\n prompt_embeds = prompt_embeds.repeat_interleave(num_images_per_prompt, dim=0)\n # in Shap-E it normalize the prompt_embeds and then later rescale it\n prompt_embeds = prompt_embeds / torch.linalg.norm(prompt_embeds, dim=-1, keepdim=True)\n\n if do_classifier_free_guidance:\n negative_prompt_embeds = torch.zeros_like(prompt_embeds)\n\n # For classifier free guidance, we need to do two forward passes.\n # Here we concatenate the unconditional and text embeddings into a single batch\n # to avoid doing two forward passes\n prompt_embeds = torch.cat([negative_prompt_embeds, prompt_embeds])\n\n # Rescale the features to have unit variance\n prompt_embeds = math.sqrt(prompt_embeds.shape[1]) * prompt_embeds\n\n return prompt_embeds", "probing input": " def _encode_prompt(\n self,\n prompt,\n device,\n num_images_per_prompt,\n do_classifier_free_guidance,\n ):\n len(prompt) if isinstance(prompt, list) else 1\n\n # YiYi Notes: set pad_token_id to be 0, not sure why I can't set in the config file\n self.tokenizer.pad_token_id = 0\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n untruncated_ids = self.tokenizer(prompt, padding=\"longest\", return_tensors=\"pt\").input_ids\n\n if untruncated_ids.shape[-1] >= text_input_ids.shape[-1] and not torch.equal(text_input_ids, untruncated_ids):\n removed_text = self.tokenizer.batch_decode(untruncated_ids[:, self.tokenizer.model_max_length - 1 : -1])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n\n text_encoder_output = self.text_encoder(text_input_ids.to(device))\n prompt_embeds = text_encoder_output.text_embeds\n\n prompt_embeds = prompt_embeds.repeat_interleave(num_images_per_prompt, dim=0)\n # in Shap-E it normalize the prompt_embeds and then later rescale it\n", "probing input new": " def _encode_prompt(\n self,\n prompt,\n device,\n num_images_per_prompt,\n do_classifier_free_guidance,\n ):\n len(prompt) if isinstance(prompt, list) else 1\n\n # YiYi Notes: set pad_token_id to be 0, not sure why I can't set in the config file\n self.tokenizer.pad_token_id = 0\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n untruncated_ids = self.tokenizer(prompt, padding=\"longest\", return_tensors=\"pt\").input_ids\n\n if untruncated_ids.shape[-1] >= text_input_ids.shape[-1] and not torch.equal(text_input_ids, untruncated_ids):\n removed_text = self.tokenizer.batch_decode(untruncated_ids[:, self.tokenizer.model_max_length - 1 : -1])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n\n text_encoder_output = self.text_encoder(text_input_ids.to(device))\n prompt_embeds = text_encoder_output.text_embeds\n\n prompt_embeds = prompt_embeds.repeat_interleave(num_images_per_prompt, dim=0)\n # in Shap-E it normalize the prompt_embeds and then later rescale it\n prompt_embeds = prompt_embeds / torch.", "reference": "prompt_embeds=prompt_embeds/torch.linalg.norm(prompt_embeds,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "prompt_embeds=prompt_embeds/torch.linalg.norm(prompt_embeds,dim=-1,keepdim=True)", "y_neg": " prompt_embeds = prompt_embeds / torch.norm(prompt_embeds, dim=-1, keepdim=True)", "retain": " def _encode_prompt(\n self,\n prompt,\n device,\n num_images_per_prompt,\n do_classifier_free_guidance,\n ):\n len(prompt) if isinstance(prompt, list) else 1\n\n # YiYi Notes: set pad_token_id to be 0, not sure why I can't set in the config file\n self.tokenizer.pad_token_id = 0\n # get prompt text embeddings\n text_inputs = self.tokenizer(\n prompt,\n padding=\"max_length\",\n max_length=self.tokenizer.model_max_length,\n truncation=True,\n return_tensors=\"pt\",\n )\n text_input_ids = text_inputs.input_ids\n untruncated_ids = self.tokenizer(prompt, padding=\"longest\", return_tensors=\"pt\").input_ids\n\n if untruncated_ids.shape[-1] >= text_input_ids.shape[-1] and not torch.equal(text_input_ids, untruncated_ids):\n removed_text = self.tokenizer.batch_decode(untruncated_ids[:, self.tokenizer.model_max_length - 1 : -1])\n logger.warning(\n \"The following part of your input was truncated because CLIP can only handle sequences up to\"\n f\" {self.tokenizer.model_max_length} tokens: {removed_text}\"\n )\n\n text_encoder_output = self.text_encoder(text_input_ids.to(device))\n prompt_embeds = text_encoder_output.text_embeds\n\n prompt_embeds = prompt_embeds.repeat_interleave(num_images_per_prompt, dim=0)\n # in Shap-E it normalize the prompt_embeds and then later rescale it\n prompt_embeds = prompt_embeds / torch.linalg.norm(prompt_embeds, dim=-1, keepdim=True)\n\n if do_classifier_free_guidance:\n negative_prompt_embeds = torch.zeros_like(prompt_embeds)\n\n # For classifier free guidance, we need to do two forward passes.\n # Here we concatenate the unconditional and text embeddings into a single batch\n # to avoid doing two forward passes\n prompt_embeds = torch.cat([negative_prompt_embeds, prompt_embeds])\n\n # Rescale the features to have unit variance\n prompt_embeds = math.sqrt(prompt_embeds.shape[1]) * prompt_embeds\n\n return prompt_embeds" }, { "id": 7711, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_geometric_structure_embeddings(points, angle_k=3):\n\n batch_size, num_point, _ = points.shape\n\n dist_map = torch.sqrt(square_distance(points, points)) # (B, N, N)\n\n knn_indices = dist_map.topk(k=angle_k + 1, dim=2, largest=False)[1] # (B, N, k)\n knn_indices = knn_indices[:, :, 1:]\n knn_indices = knn_indices.unsqueeze(3).expand(batch_size, num_point, angle_k, 3) # (B, N, k, 3)\n expanded_points = points.unsqueeze(1).expand(batch_size, num_point, num_point, 3) # (B, N, N, 3)\n knn_points = torch.gather(expanded_points, dim=2, index=knn_indices) # (B, N, k, 3)\n ref_vectors = knn_points - points.unsqueeze(2) # (B, N, k, 3)\n anc_vectors = points.unsqueeze(1) - points.unsqueeze(2) # (B, N, N, 3)\n ref_vectors = ref_vectors.unsqueeze(2).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n anc_vectors = anc_vectors.unsqueeze(3).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n sin_values = torch.linalg.norm(torch.cross(ref_vectors, anc_vectors, dim=-1), dim=-1) # (B, N, N, k)\n cos_values = torch.sum(ref_vectors * anc_vectors, dim=-1) # (B, N, N, k)\n angles = torch.atan2(sin_values, cos_values) # (B, N, N, k)\n\n return dist_map, angles", "probing input": "def get_geometric_structure_embeddings(points, angle_k=3):\n\n batch_size, num_point, _ = points.shape\n\n dist_map = torch.sqrt(square_distance(points, points)) # (B, N, N)\n\n knn_indices = dist_map.topk(k=angle_k + 1, dim=2, largest=False)[1] # (B, N, k)\n knn_indices = knn_indices[:, :, 1:]\n knn_indices = knn_indices.unsqueeze(3).expand(batch_size, num_point, angle_k, 3) # (B, N, k, 3)\n expanded_points = points.unsqueeze(1).expand(batch_size, num_point, num_point, 3) # (B, N, N, 3)\n knn_points = torch.gather(expanded_points, dim=2, index=knn_indices) # (B, N, k, 3)\n ref_vectors = knn_points - points.unsqueeze(2) # (B, N, k, 3)\n anc_vectors = points.unsqueeze(1) - points.unsqueeze(2) # (B, N, N, 3)\n ref_vectors = ref_vectors.unsqueeze(2).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n anc_vectors = anc_vectors.unsqueeze(3).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n", "probing input new": "def get_geometric_structure_embeddings(points, angle_k=3):\n\n batch_size, num_point, _ = points.shape\n\n dist_map = torch.sqrt(square_distance(points, points)) # (B, N, N)\n\n knn_indices = dist_map.topk(k=angle_k + 1, dim=2, largest=False)[1] # (B, N, k)\n knn_indices = knn_indices[:, :, 1:]\n knn_indices = knn_indices.unsqueeze(3).expand(batch_size, num_point, angle_k, 3) # (B, N, k, 3)\n expanded_points = points.unsqueeze(1).expand(batch_size, num_point, num_point, 3) # (B, N, N, 3)\n knn_points = torch.gather(expanded_points, dim=2, index=knn_indices) # (B, N, k, 3)\n ref_vectors = knn_points - points.unsqueeze(2) # (B, N, k, 3)\n anc_vectors = points.unsqueeze(1) - points.unsqueeze(2) # (B, N, N, 3)\n ref_vectors = ref_vectors.unsqueeze(2).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n anc_vectors = anc_vectors.unsqueeze(3).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n sin_values = torch.", "reference": "sin_values=torch.linalg.norm(torch.cross(ref_vectors,anc_vectors,dim=-1),dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "sin_values=torch.linalg.norm(torch.cross(ref_vectors,anc_vectors,dim=-1),dim=-1)", "y_neg": " sin_values = torch.sin(angle_k * torch.pi / 180 * torch.acos(torch.sum(ref_vectors * anc_vectors, dim=-1) / (torch.norm(ref_vectors, dim=-1) * torch.norm(anc_vectors, dim=-1)))) # (B, N, N, k)", "retain": "def get_geometric_structure_embeddings(points, angle_k=3):\n\n batch_size, num_point, _ = points.shape\n\n dist_map = torch.sqrt(square_distance(points, points)) # (B, N, N)\n\n knn_indices = dist_map.topk(k=angle_k + 1, dim=2, largest=False)[1] # (B, N, k)\n knn_indices = knn_indices[:, :, 1:]\n knn_indices = knn_indices.unsqueeze(3).expand(batch_size, num_point, angle_k, 3) # (B, N, k, 3)\n expanded_points = points.unsqueeze(1).expand(batch_size, num_point, num_point, 3) # (B, N, N, 3)\n knn_points = torch.gather(expanded_points, dim=2, index=knn_indices) # (B, N, k, 3)\n ref_vectors = knn_points - points.unsqueeze(2) # (B, N, k, 3)\n anc_vectors = points.unsqueeze(1) - points.unsqueeze(2) # (B, N, N, 3)\n ref_vectors = ref_vectors.unsqueeze(2).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n anc_vectors = anc_vectors.unsqueeze(3).expand(batch_size, num_point, num_point, angle_k, 3) # (B, N, N, k, 3)\n sin_values = torch.linalg.norm(torch.cross(ref_vectors, anc_vectors, dim=-1), dim=-1) # (B, N, N, k)\n cos_values = torch.sum(ref_vectors * anc_vectors, dim=-1) # (B, N, N, k)\n angles = torch.atan2(sin_values, cos_values) # (B, N, N, k)\n\n return dist_map, angles" }, { "id": 7712, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: torch.FloatTensor,\n query_mask: torch.Tensor,\n ) -> Tuple[torch.FloatTensor]:\n\n image_class_embeds = self.dense0(image_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6\n query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)", "probing input": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: torch.FloatTensor,\n query_mask: torch.Tensor,\n ) -> Tuple[torch.FloatTensor]:\n\n image_class_embeds = self.dense0(image_embeds)\n\n # Normalize image and text features\n", "probing input new": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: torch.FloatTensor,\n query_mask: torch.Tensor,\n ) -> Tuple[torch.FloatTensor]:\n\n image_class_embeds = self.dense0(image_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.", "reference": "image_class_embeds/=torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "image_class_embeds/=torch.linalg.norm(image_class_embeds,dim=-1,keepdim=True)+1e-6", "y_neg": " image_class_embeds /= torch.norm(image_class_embeds, dim=1, keepdim=True)", "retain": " def forward(\n self,\n image_embeds: torch.FloatTensor,\n query_embeds: torch.FloatTensor,\n query_mask: torch.Tensor,\n ) -> Tuple[torch.FloatTensor]:\n\n image_class_embeds = self.dense0(image_embeds)\n\n # Normalize image and text features\n image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6\n query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6\n\n # Get class predictions\n pred_logits = torch.einsum(\"...pd,...qd->...pq\", image_class_embeds, query_embeds)\n\n # Apply a learnable shift and scale to logits\n logit_shift = self.logit_shift(image_embeds)\n logit_scale = self.logit_scale(image_embeds)\n logit_scale = self.elu(logit_scale) + 1\n pred_logits = (pred_logits + logit_shift) * logit_scale\n\n if query_mask is not None:\n if query_mask.ndim > 1:\n query_mask = torch.unsqueeze(query_mask, dim=-2)\n\n pred_logits = pred_logits.to(torch.float64)\n pred_logits = torch.where(query_mask == 0, -1e6, pred_logits)\n pred_logits = pred_logits.to(torch.float32)\n\n return (pred_logits, image_class_embeds)" }, { "id": 7714, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, step):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = sdf.device\n batch_size, n_samples = z_vals.shape\n pts = (\n rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n ) # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat(\n [torch.zeros([batch_size, 1], device=device), cos_val[:, :-1]], dim=-1\n )\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = next_z_vals - prev_z_vals\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n # transient alpha\n # alpha = alpha_s + alpha_t\n weights = (\n alpha\n * torch.cumprod(\n torch.cat(\n [torch.ones([batch_size, 1], device=device), 1.0 - alpha + 1e-7], -1\n ),\n -1,\n )[:, :-1]\n )\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n if self.save_step_sample:\n # # start points\n # self.save_samples_step(pts[:, :-1][weights < 0.1].view(-1, 3), f\"{step}_{0.0}_{0.1}\")\n # # end points\n # self.save_samples_step(pts[:, :-1][((weights > 0.1) & (weights < 0.9))].view(-1, 3), f\"{step}_{0.1}_{0.9}\")\n # self.save_samples_step(pts[:, :-1].reshape(-1, 3), f\"{step}_all\")\n\n # colored\n self.save_samples_step(\n pts[:, :-1].reshape(-1, 3),\n weights.reshape(\n -1,\n ),\n f\"{step}_colored\",\n )\n\n pts_new = rays_o[:, None, :] + rays_d[:, None, :] * z_samples[..., :, None]\n self.save_samples_step(\n pts_new.reshape(-1, 3),\n torch.zeros_like(z_samples).reshape(\n -1,\n ),\n f\"{step}\",\n dir_name=\"new_z\",\n )\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, step):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = sdf.device\n batch_size, n_samples = z_vals.shape\n pts = (\n rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n ) # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, step):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = sdf.device\n batch_size, n_samples = z_vals.shape\n pts = (\n rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n ) # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, step):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n device = sdf.device\n batch_size, n_samples = z_vals.shape\n pts = (\n rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None]\n ) # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat(\n [torch.zeros([batch_size, 1], device=device), cos_val[:, :-1]], dim=-1\n )\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = next_z_vals - prev_z_vals\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n # transient alpha\n # alpha = alpha_s + alpha_t\n weights = (\n alpha\n * torch.cumprod(\n torch.cat(\n [torch.ones([batch_size, 1], device=device), 1.0 - alpha + 1e-7], -1\n ),\n -1,\n )[:, :-1]\n )\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n\n if self.save_step_sample:\n # # start points\n # self.save_samples_step(pts[:, :-1][weights < 0.1].view(-1, 3), f\"{step}_{0.0}_{0.1}\")\n # # end points\n # self.save_samples_step(pts[:, :-1][((weights > 0.1) & (weights < 0.9))].view(-1, 3), f\"{step}_{0.1}_{0.9}\")\n # self.save_samples_step(pts[:, :-1].reshape(-1, 3), f\"{step}_all\")\n\n # colored\n self.save_samples_step(\n pts[:, :-1].reshape(-1, 3),\n weights.reshape(\n -1,\n ),\n f\"{step}_colored\",\n )\n\n pts_new = rays_o[:, None, :] + rays_d[:, None, :] * z_samples[..., :, None]\n self.save_samples_step(\n pts_new.reshape(-1, 3),\n torch.zeros_like(z_samples).reshape(\n -1,\n ),\n f\"{step}\",\n dir_name=\"new_z\",\n )\n return z_samples" }, { "id": 7715, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def floor_loss(self, label, normals, rays_o, rays_d, rendered_depth):\n device = rays_o.device\n batch_size = label.size()[0]\n floor_mask = torch.zeros([batch_size], dtype=torch.bool)\n for f_label in self.floor_labels:\n floor_mask[get_label_id_mapping()[f_label] == label] = 1\n\n if torch.sum(floor_mask) == 0:\n return torch.zeros_like(normals), torch.zeros_like(normals)\n\n floor_normal = normals[floor_mask]\n\n # in gt coordinate system, z is perpendicular to road\n floor_normal_gt = torch.zeros_like(floor_normal)\n floor_normal_gt[:, 2] = 1\n floor_normal_gt = self.sfm_to_gt[:3, :3].T @ floor_normal_gt.permute(1, 0)\n floor_normal_gt = floor_normal_gt.permute(1, 0).contiguous()\n floor_normal_gt = floor_normal_gt / torch.linalg.norm(\n floor_normal_gt, dim=-1\n ).reshape(-1, 1)\n\n floor_error = F.l1_loss(floor_normal, floor_normal_gt, reduction=\"none\")\n\n xyzs = rays_o + rays_d * rendered_depth.reshape(-1, 1)\n road_y = xyzs[floor_mask]\n y_error = torch.var(road_y)\n\n return floor_error, torch.ones_like(floor_error) * y_error", "probing input": " def floor_loss(self, label, normals, rays_o, rays_d, rendered_depth):\n device = rays_o.device\n batch_size = label.size()[0]\n floor_mask = torch.zeros([batch_size], dtype=torch.bool)\n for f_label in self.floor_labels:\n floor_mask[get_label_id_mapping()[f_label] == label] = 1\n\n if torch.sum(floor_mask) == 0:\n return torch.zeros_like(normals), torch.zeros_like(normals)\n\n floor_normal = normals[floor_mask]\n\n # in gt coordinate system, z is perpendicular to road\n floor_normal_gt = torch.zeros_like(floor_normal)\n floor_normal_gt[:, 2] = 1\n floor_normal_gt = self.sfm_to_gt[:3, :3].T @ floor_normal_gt.permute(1, 0)\n floor_normal_gt = floor_normal_gt.permute(1, 0).contiguous()\n", "probing input new": " def floor_loss(self, label, normals, rays_o, rays_d, rendered_depth):\n device = rays_o.device\n batch_size = label.size()[0]\n floor_mask = torch.zeros([batch_size], dtype=torch.bool)\n for f_label in self.floor_labels:\n floor_mask[get_label_id_mapping()[f_label] == label] = 1\n\n if torch.sum(floor_mask) == 0:\n return torch.zeros_like(normals), torch.zeros_like(normals)\n\n floor_normal = normals[floor_mask]\n\n # in gt coordinate system, z is perpendicular to road\n floor_normal_gt = torch.zeros_like(floor_normal)\n floor_normal_gt[:, 2] = 1\n floor_normal_gt = self.sfm_to_gt[:3, :3].T @ floor_normal_gt.permute(1, 0)\n floor_normal_gt = floor_normal_gt.permute(1, 0).contiguous()\n floor_", "reference": "floor_normal_gt=floor_normal_gt/torch.linalg.norm(floor_normal_gt,dim=-1).reshape(-1,1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "floor_normal_gt=floor_normal_gt/torch.linalg.norm(floor_normal_gt,dim=-1).reshape(-1,1)", "y_neg": " floor_normal_gt = floor_normal_gt / torch.norm(floor_normal_gt, dim=1, keepdim=True)", "retain": " def floor_loss(self, label, normals, rays_o, rays_d, rendered_depth):\n device = rays_o.device\n batch_size = label.size()[0]\n floor_mask = torch.zeros([batch_size], dtype=torch.bool)\n for f_label in self.floor_labels:\n floor_mask[get_label_id_mapping()[f_label] == label] = 1\n\n if torch.sum(floor_mask) == 0:\n return torch.zeros_like(normals), torch.zeros_like(normals)\n\n floor_normal = normals[floor_mask]\n\n # in gt coordinate system, z is perpendicular to road\n floor_normal_gt = torch.zeros_like(floor_normal)\n floor_normal_gt[:, 2] = 1\n floor_normal_gt = self.sfm_to_gt[:3, :3].T @ floor_normal_gt.permute(1, 0)\n floor_normal_gt = floor_normal_gt.permute(1, 0).contiguous()\n floor_normal_gt = floor_normal_gt / torch.linalg.norm(\n floor_normal_gt, dim=-1\n ).reshape(-1, 1)\n\n floor_error = F.l1_loss(floor_normal, floor_normal_gt, reduction=\"none\")\n\n xyzs = rays_o + rays_d * rendered_depth.reshape(-1, 1)\n road_y = xyzs[floor_mask]\n y_error = torch.var(road_y)\n\n return floor_error, torch.ones_like(floor_error) * y_error" }, { "id": 7716, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:, :3, :3])\n theta = torch.linalg.norm(w, dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w / theta\n tan = torch.tan(0.5 * theta)\n\n t = T[:, :3, 3]\n wnorm_x_t = torch.cross(w_norm, t)\n V_inv_t = (\n t\n - (0.5 * t) * wnorm_x_t\n + (1.0 - theta / (2.0 * tan)) * torch.cross(w_norm, wnorm_x_t)\n )\n xi = torch.cat((w, V_inv_t), dim=-1)\n\n return xi", "probing input": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:, :3, :3])\n", "probing input new": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:, :3, :3])\n theta = torch.", "reference": "theta=torch.linalg.norm(w,dim=(1))", "reference dict": { "w": "SO3_logmap" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(w,dim=(1))", "y_neg": " theta = torch.log(torch.norm(T[:, :3, :3]) + eps)", "retain": "def SE3_logmap(T, eps=1e-6):\n w = SO3_logmap(T[:, :3, :3])\n theta = torch.linalg.norm(w, dim=(1))\n theta = torch.clamp(theta, min=eps)\n w_norm = w / theta\n tan = torch.tan(0.5 * theta)\n\n t = T[:, :3, 3]\n wnorm_x_t = torch.cross(w_norm, t)\n V_inv_t = (\n t\n - (0.5 * t) * wnorm_x_t\n + (1.0 - theta / (2.0 * tan)) * torch.cross(w_norm, wnorm_x_t)\n )\n xi = torch.cat((w, V_inv_t), dim=-1)\n\n return xi" }, { "id": 7721, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def knn(ref, nbr, k=1, ord=2, dim=-1, largest=False, sorted=True):\n diff = ref.unsqueeze(-2) - nbr.unsqueeze(-3)\n dist = torch.linalg.norm(diff, dim=dim, ord=ord)\n return dist.topk(k, dim=dim, largest=largest, sorted=sorted)", "probing input": "def knn(ref, nbr, k=1, ord=2, dim=-1, largest=False, sorted=True):\n diff = ref.unsqueeze(-2) - nbr.unsqueeze(-3)\n", "probing input new": "def knn(ref, nbr, k=1, ord=2, dim=-1, largest=False, sorted=True):\n diff = ref.unsqueeze(-2) - nbr.unsqueeze(-3)\n dist = torch.", "reference": "dist=torch.linalg.norm(diff,dim=dim,ord=ord)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist=torch.linalg.norm(diff,dim=dim,ord=ord)", "y_neg": " dist = torch.norm(diff, ord=ord, dim=dim)", "retain": "def knn(ref, nbr, k=1, ord=2, dim=-1, largest=False, sorted=True):\n diff = ref.unsqueeze(-2) - nbr.unsqueeze(-3)\n dist = torch.linalg.norm(diff, dim=dim, ord=ord)\n return dist.topk(k, dim=dim, largest=largest, sorted=sorted)" }, { "id": 7724, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_objective(self, outputs, labels):\n \"\"\"Compute the objective the FedProx client wishes to minimize.\"\"\"\n current_weights = _flatten_weights_from_model(self.model, self.device)\n parameter_mu = (\n Config().clients.proximal_term_penalty_constant\n if hasattr(Config().clients, \"proximal_term_penalty_constant\")\n else 1\n )\n proximal_term = (\n parameter_mu\n / 2\n * torch.linalg.norm(current_weights - self.init_global_weights, ord=2)\n )\n\n local_function = torch.nn.CrossEntropyLoss()\n function_h = local_function(outputs, labels) + proximal_term\n return function_h", "probing input": " def compute_objective(self, outputs, labels):\n \"\"\"Compute the objective the FedProx client wishes to minimize.\"\"\"\n current_weights = _flatten_weights_from_model(self.model, self.device)\n parameter_mu = (\n Config().clients.proximal_term_penalty_constant\n if hasattr(Config().clients, \"proximal_term_penalty_constant\")\n else 1\n )\n proximal_term = (\n parameter_mu\n / 2\n", "probing input new": " def compute_objective(self, outputs, labels):\n \"\"\"Compute the objective the FedProx client wishes to minimize.\"\"\"\n current_weights = _flatten_weights_from_model(self.model, self.device)\n parameter_mu = (\n Config().clients.proximal_term_penalty_constant\n if hasattr(Config().clients, \"proximal_term_penalty_constant\")\n else 1\n )\n proximal_term = (\n parameter_mu\n / 2\n * torch.", "reference": "*torch.linalg.norm(current_weights-self.init_global_weights,ord=2)", "reference dict": { "local_function": "torch.nn.CrossEntropyLoss" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "*torch.linalg.norm(current_weights-self.init_global_weights,ord=2)", "y_neg": " * torch.norm(outputs - labels, p=2, dim=1)", "retain": " def compute_objective(self, outputs, labels):\n \"\"\"Compute the objective the FedProx client wishes to minimize.\"\"\"\n current_weights = _flatten_weights_from_model(self.model, self.device)\n parameter_mu = (\n Config().clients.proximal_term_penalty_constant\n if hasattr(Config().clients, \"proximal_term_penalty_constant\")\n else 1\n )\n proximal_term = (\n parameter_mu\n / 2\n * torch.linalg.norm(current_weights - self.init_global_weights, ord=2)\n )\n\n local_function = torch.nn.CrossEntropyLoss()\n function_h = local_function(outputs, labels) + proximal_term\n return function_h" }, { "id": 7726, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu()\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu()\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n pts_target = self.pts[img_idx][(pixels_y*pixels_x)]\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = p.to(self.intrinsics_all_inv.device) \n self.intrinsics_all_inv = self.intrinsics_all_inv.to(p.device)\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose_cur[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose_cur[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n \n normal_sample = None\n if self.use_normal:\n normal_sample = self.normals[img_idx][(pixels_y, pixels_x)].cuda()\n\n planes_sample = None\n if self.use_planes:\n planes_sample = self.planes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n \n subplanes_sample = None\n if self.use_plane_offset_loss:\n subplanes_sample = self.subplanes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask, pts_target], dim=-1).cuda(), pixels_x, pixels_y, normal_sample, planes_sample, subplanes_sample", "probing input": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu()\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu()\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n pts_target = self.pts[img_idx][(pixels_y*pixels_x)]\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = p.to(self.intrinsics_all_inv.device) \n self.intrinsics_all_inv = self.intrinsics_all_inv.to(p.device)\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu()\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu()\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n pts_target = self.pts[img_idx][(pixels_y*pixels_x)]\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = p.to(self.intrinsics_all_inv.device) \n self.intrinsics_all_inv = self.intrinsics_all_inv.to(p.device)\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def random_get_rays_at(self, img_idx, batch_size, pose = None):\n pose_cur = self.get_pose(img_idx, pose)\n \n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size]).cpu()\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size]).cpu()\n \n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)][:,None] # batch_size, 3\n pts_target = self.pts[img_idx][(pixels_y*pixels_x)]\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = p.to(self.intrinsics_all_inv.device) \n self.intrinsics_all_inv = self.intrinsics_all_inv.to(p.device)\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose_cur[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose_cur[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n \n normal_sample = None\n if self.use_normal:\n normal_sample = self.normals[img_idx][(pixels_y, pixels_x)].cuda()\n\n planes_sample = None\n if self.use_planes:\n planes_sample = self.planes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n \n subplanes_sample = None\n if self.use_plane_offset_loss:\n subplanes_sample = self.subplanes[img_idx][(pixels_y, pixels_x)].unsqueeze(-1).cuda()\n\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask, pts_target], dim=-1).cuda(), pixels_x, pixels_y, normal_sample, planes_sample, subplanes_sample" }, { "id": 7727, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def evaluate_R_t_tensor(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten()\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-8).to(t.device)\n err_q = torch.arccos(torch.max(torch.min((torch.trace(R @ R_gt.transpose(0, 1)) - 1) * 0.5,\n torch.tensor(1.0, device=R.device)), torch.tensor(-1.0, device=R.device)))\n\n t_gt_ = t_gt / (torch.linalg.norm(t_gt) + eps)\n loss_t = torch.max(eps, 1.0 - torch.sum(t * t_gt_)**2)#torch.clamp((), min=eps)\n err_t = torch.arccos(torch.sqrt(1 - loss_t+eps))\n\n if torch.sum(torch.isnan(err_q)) or torch.sum(torch.isnan(err_t)):\n print(\"This should never happen! Debug here\", R_gt, t_gt, R, t, q_gt)\n import IPython\n IPython.embed()\n\n return err_q, err_t", "probing input": "def evaluate_R_t_tensor(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten()\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-8).to(t.device)\n err_q = torch.arccos(torch.max(torch.min((torch.trace(R @ R_gt.transpose(0, 1)) - 1) * 0.5,\n torch.tensor(1.0, device=R.device)), torch.tensor(-1.0, device=R.device)))\n\n", "probing input new": "def evaluate_R_t_tensor(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten()\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-8).to(t.device)\n err_q = torch.arccos(torch.max(torch.min((torch.trace(R @ R_gt.transpose(0, 1)) - 1) * 0.5,\n torch.tensor(1.0, device=R.device)), torch.tensor(-1.0, device=R.device)))\n\n t_gt_ = t_gt / (torch.", "reference": "t_gt_=t_gt/(torch.linalg.norm(t_gt)+eps)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "t_gt_=t_gt/(torch.linalg.norm(t_gt)+eps)", "y_neg": " t_gt_ = t_gt / (torch.norm(t_gt, p='fro', dim=-1, keepdim=True) + eps)", "retain": "def evaluate_R_t_tensor(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten()\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-8).to(t.device)\n err_q = torch.arccos(torch.max(torch.min((torch.trace(R @ R_gt.transpose(0, 1)) - 1) * 0.5,\n torch.tensor(1.0, device=R.device)), torch.tensor(-1.0, device=R.device)))\n\n t_gt_ = t_gt / (torch.linalg.norm(t_gt) + eps)\n loss_t = torch.max(eps, 1.0 - torch.sum(t * t_gt_)**2)#torch.clamp((), min=eps)\n err_t = torch.arccos(torch.sqrt(1 - loss_t+eps))\n\n if torch.sum(torch.isnan(err_q)) or torch.sum(torch.isnan(err_t)):\n print(\"This should never happen! Debug here\", R_gt, t_gt, R, t, q_gt)\n import IPython\n IPython.embed()\n\n return err_q, err_t" }, { "id": 7728, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def evaluate_R_t_tensor_batch(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten(-2, -1)\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-15).to(t.device)\n # rotation error\n err_q = torch.arccos(torch.clamp((torch.diagonal(R @ R_gt.repeat(R.shape[0], 1, 1).transpose(-2, -1), dim1=-2, dim2=-1).sum(-1) - 1) * 0.5, min= -1.0, max=1.0))\n # translation error\n t = t / (torch.norm(t, dim=-1) + eps).unsqueeze(-1)\n t_gt_ = t_gt / (torch.linalg.norm(t_gt) + eps)\n loss_t = torch.clamp((1.0 - torch.sum(t * t_gt_, dim=-1)**2), min=eps)\n err_t = torch.arccos(torch.sqrt(1 - loss_t + 1e-8))\n\n if torch.sum(torch.isnan(err_q)) or torch.sum(torch.isnan(err_t)):\n # This should never happen! Debug here\n print(R_gt, t_gt, R, t, q_gt)\n import IPython\n IPython.embed()\n\n return err_q, err_t", "probing input": "def evaluate_R_t_tensor_batch(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten(-2, -1)\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-15).to(t.device)\n # rotation error\n err_q = torch.arccos(torch.clamp((torch.diagonal(R @ R_gt.repeat(R.shape[0], 1, 1).transpose(-2, -1), dim1=-2, dim2=-1).sum(-1) - 1) * 0.5, min= -1.0, max=1.0))\n # translation error\n t = t / (torch.norm(t, dim=-1) + eps).unsqueeze(-1)\n", "probing input new": "def evaluate_R_t_tensor_batch(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten(-2, -1)\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-15).to(t.device)\n # rotation error\n err_q = torch.arccos(torch.clamp((torch.diagonal(R @ R_gt.repeat(R.shape[0], 1, 1).transpose(-2, -1), dim1=-2, dim2=-1).sum(-1) - 1) * 0.5, min= -1.0, max=1.0))\n # translation error\n t = t / (torch.norm(t, dim=-1) + eps).unsqueeze(-1)\n t_gt_ = t_gt / (torch.", "reference": "t_gt_=t_gt/(torch.linalg.norm(t_gt)+eps)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "t_gt_=t_gt/(torch.linalg.norm(t_gt)+eps)", "y_neg": " t_gt_ = t_gt / (torch.norm(t_gt, dim=-1) + eps).unsqueeze(-1)", "retain": "def evaluate_R_t_tensor_batch(R_gt, t_gt, R, t, q_gt=None):\n t = t.flatten(-2, -1)\n t_gt = t_gt.flatten().to(t.device)\n\n eps = torch.tensor(1e-15).to(t.device)\n # rotation error\n err_q = torch.arccos(torch.clamp((torch.diagonal(R @ R_gt.repeat(R.shape[0], 1, 1).transpose(-2, -1), dim1=-2, dim2=-1).sum(-1) - 1) * 0.5, min= -1.0, max=1.0))\n # translation error\n t = t / (torch.norm(t, dim=-1) + eps).unsqueeze(-1)\n t_gt_ = t_gt / (torch.linalg.norm(t_gt) + eps)\n loss_t = torch.clamp((1.0 - torch.sum(t * t_gt_, dim=-1)**2), min=eps)\n err_t = torch.arccos(torch.sqrt(1 - loss_t + 1e-8))\n\n if torch.sum(torch.isnan(err_q)) or torch.sum(torch.isnan(err_t)):\n # This should never happen! Debug here\n print(R_gt, t_gt, R, t, q_gt)\n import IPython\n IPython.embed()\n\n return err_q, err_t" }, { "id": 7729, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def residuIL_loss(self, targets, predictions, pred_residuals):\n\n # train policy (detach discriminator)\n target_prediction_differences = targets - predictions\n\n # bc_regularization is optionally used according to Appendix of the\n # paper (Tabel 4 and 5)\n policy_loss = (\n 2 * (target_prediction_differences) * pred_residuals.detach()\n ).mean(-1) + self._bc_regulatization_weight * (\n torch.square(target_prediction_differences)).mean(-1)\n\n # train discriminator (detach policy)\n discriminator_loss = -(\n 2 * (target_prediction_differences).detach() * pred_residuals -\n pred_residuals * pred_residuals).mean(-1)\n\n # f_norm_penalty is used according to Appendix of the paper (Tabel 4 and 5)\n discriminator_loss = (\n discriminator_loss +\n self._f_norm_penalty_weight * torch.linalg.norm(pred_residuals))\n\n return policy_loss, discriminator_loss", "probing input": " def residuIL_loss(self, targets, predictions, pred_residuals):\n\n # train policy (detach discriminator)\n target_prediction_differences = targets - predictions\n\n # bc_regularization is optionally used according to Appendix of the\n # paper (Tabel 4 and 5)\n policy_loss = (\n 2 * (target_prediction_differences) * pred_residuals.detach()\n ).mean(-1) + self._bc_regulatization_weight * (\n torch.square(target_prediction_differences)).mean(-1)\n\n # train discriminator (detach policy)\n discriminator_loss = -(\n 2 * (target_prediction_differences).detach() * pred_residuals -\n pred_residuals * pred_residuals).mean(-1)\n\n # f_norm_penalty is used according to Appendix of the paper (Tabel 4 and 5)\n discriminator_loss = (\n discriminator_loss +\n", "probing input new": " def residuIL_loss(self, targets, predictions, pred_residuals):\n\n # train policy (detach discriminator)\n target_prediction_differences = targets - predictions\n\n # bc_regularization is optionally used according to Appendix of the\n # paper (Tabel 4 and 5)\n policy_loss = (\n 2 * (target_prediction_differences) * pred_residuals.detach()\n ).mean(-1) + self._bc_regulatization_weight * (\n torch.square(target_prediction_differences)).mean(-1)\n\n # train discriminator (detach policy)\n discriminator_loss = -(\n 2 * (target_prediction_differences).detach() * pred_residuals -\n pred_residuals * pred_residuals).mean(-1)\n\n # f_norm_penalty is used according to Appendix of the paper (Tabel 4 and 5)\n discriminator_loss = (\n discriminator_loss +\n self._f_", "reference": "self._f_norm_penalty_weight*torch.linalg.norm(pred_residuals))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self._f_norm_penalty_weight*torch.linalg.norm(pred_residuals))", "y_neg": " self._f_norm_penalty * torch.norm(pred_residuals, p='fro', dim=-1))", "retain": " def residuIL_loss(self, targets, predictions, pred_residuals):\n\n # train policy (detach discriminator)\n target_prediction_differences = targets - predictions\n\n # bc_regularization is optionally used according to Appendix of the\n # paper (Tabel 4 and 5)\n policy_loss = (\n 2 * (target_prediction_differences) * pred_residuals.detach()\n ).mean(-1) + self._bc_regulatization_weight * (\n torch.square(target_prediction_differences)).mean(-1)\n\n # train discriminator (detach policy)\n discriminator_loss = -(\n 2 * (target_prediction_differences).detach() * pred_residuals -\n pred_residuals * pred_residuals).mean(-1)\n\n # f_norm_penalty is used according to Appendix of the paper (Tabel 4 and 5)\n discriminator_loss = (\n discriminator_loss +\n self._f_norm_penalty_weight * torch.linalg.norm(pred_residuals))\n\n return policy_loss, discriminator_loss" }, { "id": 7737, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def l2_norm(a, b):\n return torch.linalg.norm(a-b, ord = 2, dim = -1)", "probing input": "def l2_norm(a, b):\n", "probing input new": "def l2_norm(a, b):\n return torch.", "reference": "returntorch.linalg.norm(a-b,ord=2,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(a-b,ord=2,dim=-1)", "y_neg": " return torch.norm(a - b, p=2, dim=None)", "retain": "def l2_norm(a, b):\n return torch.linalg.norm(a-b, ord = 2, dim = -1)" }, { "id": 7738, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n\n return torch.cat([rays_o, rays_v, color, mask[:, :1]], dim=-1)", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze()\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze()\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze()\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n\n return torch.cat([rays_o, rays_v, color, mask[:, :1]], dim=-1)" }, { "id": 7739, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def surround_views(initial_pose, angle_amp=1.0, num_frames=60):\n rad = torch.from_numpy(\n np.linspace(0, 2 * np.pi, num=num_frames, endpoint=False, dtype=np.float32))\n\n initial_pos = initial_pose[:3, -1]\n initial_pos_dist = torch.linalg.norm(initial_pos)\n initial_pos_norm = initial_pos / initial_pos_dist\n initial_angle = torch.asin(initial_pos_norm[-1])\n\n angles = initial_angle * (rad.sin() * angle_amp + 1)\n pos_xy = F.normalize(initial_pos_norm[:2], dim=0) @ torch.stack(\n [rad.cos(), -rad.sin(),\n rad.sin(), rad.cos()], dim=-1).reshape(-1, 2, 2)\n pos = torch.cat(\n [pos_xy * angles.cos().unsqueeze(-1), angles.sin().unsqueeze(-1)],\n dim=-1) * initial_pos_dist\n rot = look_at(pos, torch.zeros_like(pos), pos.new_tensor([0, 0, 1]).expand(pos.size()))\n poses = torch.cat(\n [torch.cat([rot, pos.unsqueeze(-1)], dim=-1),\n rot.new_tensor([0, 0, 0, 1]).expand(num_frames, 1, -1)], dim=-2)\n\n return poses", "probing input": "def surround_views(initial_pose, angle_amp=1.0, num_frames=60):\n rad = torch.from_numpy(\n np.linspace(0, 2 * np.pi, num=num_frames, endpoint=False, dtype=np.float32))\n\n initial_pos = initial_pose[:3, -1]\n", "probing input new": "def surround_views(initial_pose, angle_amp=1.0, num_frames=60):\n rad = torch.from_numpy(\n np.linspace(0, 2 * np.pi, num=num_frames, endpoint=False, dtype=np.float32))\n\n initial_pos = initial_pose[:3, -1]\n initial_pos_dist = torch.", "reference": "initial_pos_dist=torch.linalg.norm(initial_pos)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "initial_pos_dist=torch.linalg.norm(initial_pos)", "y_neg": " initial_pos_dist = torch.norm(initial_pos)", "retain": "def surround_views(initial_pose, angle_amp=1.0, num_frames=60):\n rad = torch.from_numpy(\n np.linspace(0, 2 * np.pi, num=num_frames, endpoint=False, dtype=np.float32))\n\n initial_pos = initial_pose[:3, -1]\n initial_pos_dist = torch.linalg.norm(initial_pos)\n initial_pos_norm = initial_pos / initial_pos_dist\n initial_angle = torch.asin(initial_pos_norm[-1])\n\n angles = initial_angle * (rad.sin() * angle_amp + 1)\n pos_xy = F.normalize(initial_pos_norm[:2], dim=0) @ torch.stack(\n [rad.cos(), -rad.sin(),\n rad.sin(), rad.cos()], dim=-1).reshape(-1, 2, 2)\n pos = torch.cat(\n [pos_xy * angles.cos().unsqueeze(-1), angles.sin().unsqueeze(-1)],\n dim=-1) * initial_pos_dist\n rot = look_at(pos, torch.zeros_like(pos), pos.new_tensor([0, 0, 1]).expand(pos.size()))\n poses = torch.cat(\n [torch.cat([rot, pos.unsqueeze(-1)], dim=-1),\n rot.new_tensor([0, 0, 0, 1]).expand(num_frames, 1, -1)], dim=-2)\n\n return poses" }, { "id": 7740, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalize_vector(v, dim, eps=1e-6):\n return v / (torch.linalg.norm(v, ord=2, dim=dim, keepdim=True) + eps)", "probing input": "def normalize_vector(v, dim, eps=1e-6):\n", "probing input new": "def normalize_vector(v, dim, eps=1e-6):\n return v / (torch.", "reference": "returnv/(torch.linalg.norm(v,ord=2,dim=dim,keepdim=True)+eps)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returnv/(torch.linalg.norm(v,ord=2,dim=dim,keepdim=True)+eps)", "y_neg": " return v / (torch.norm(v, dim=dim, keepdim=True) + eps)", "retain": "def normalize_vector(v, dim, eps=1e-6):\n return v / (torch.linalg.norm(v, ord=2, dim=dim, keepdim=True) + eps)" }, { "id": 7741, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def dihedral_from_four_points(p0, p1, p2, p3):\n \"\"\"\n Args:\n p0-3: (*, 3).\n Returns:\n Dihedral angles in radian, (*, ).\n \"\"\"\n v0 = p2 - p1\n v1 = p0 - p1\n v2 = p3 - p2\n u1 = torch.cross(v0, v1, dim=-1)\n n1 = u1 / torch.linalg.norm(u1, dim=-1, keepdim=True)\n u2 = torch.cross(v0, v2, dim=-1)\n n2 = u2 / torch.linalg.norm(u2, dim=-1, keepdim=True)\n sgn = torch.sign((torch.cross(v1, v2, dim=-1) * v0).sum(-1))\n dihed = sgn * torch.acos((n1 * n2).sum(-1).clamp(min=-0.999999, max=0.999999))\n dihed = torch.nan_to_num(dihed)\n return dihed", "probing input": "def dihedral_from_four_points(p0, p1, p2, p3):\n \"\"\"\n Args:\n p0-3: (*, 3).\n Returns:\n Dihedral angles in radian, (*, ).\n \"\"\"\n v0 = p2 - p1\n v1 = p0 - p1\n v2 = p3 - p2\n u1 = torch.cross(v0, v1, dim=-1)\n", "probing input new": "def dihedral_from_four_points(p0, p1, p2, p3):\n \"\"\"\n Args:\n p0-3: (*, 3).\n Returns:\n Dihedral angles in radian, (*, ).\n \"\"\"\n v0 = p2 - p1\n v1 = p0 - p1\n v2 = p3 - p2\n u1 = torch.cross(v0, v1, dim=-1)\n n1 = u1 / torch.", "reference": "n1=u1/torch.linalg.norm(u1,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "n1=u1/torch.linalg.norm(u1,dim=-1,keepdim=True)", "y_neg": " n1 = u1 / torch.norm(u1, dim=-1, keepdim=True)", "retain": "def dihedral_from_four_points(p0, p1, p2, p3):\n \"\"\"\n Args:\n p0-3: (*, 3).\n Returns:\n Dihedral angles in radian, (*, ).\n \"\"\"\n v0 = p2 - p1\n v1 = p0 - p1\n v2 = p3 - p2\n u1 = torch.cross(v0, v1, dim=-1)\n n1 = u1 / torch.linalg.norm(u1, dim=-1, keepdim=True)\n u2 = torch.cross(v0, v2, dim=-1)\n n2 = u2 / torch.linalg.norm(u2, dim=-1, keepdim=True)\n sgn = torch.sign((torch.cross(v1, v2, dim=-1) * v0).sum(-1))\n dihed = sgn * torch.acos((n1 * n2).sum(-1).clamp(min=-0.999999, max=0.999999))\n dihed = torch.nan_to_num(dihed)\n return dihed" }, { "id": 7742, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cos_between_vectors(x, y, do_clamp=True):\n \"\"\"\n Args:\n x: (..., 3)\n y: (..., 3)\n Return:\n (...), cos theta between two vectors\n \"\"\"\n cos_theta = torch.sum(x * y, dim=-1) / (\n torch.linalg.norm(x, dim=-1) * torch.linalg.norm(y, dim=-1)\n )\n if do_clamp == True:\n return torch.clamp(cos_theta, -1, 1)\n else:\n return cos_theta", "probing input": "def cos_between_vectors(x, y, do_clamp=True):\n \"\"\"\n Args:\n x: (..., 3)\n y: (..., 3)\n Return:\n (...), cos theta between two vectors\n \"\"\"\n cos_theta = torch.sum(x * y, dim=-1) / (\n", "probing input new": "def cos_between_vectors(x, y, do_clamp=True):\n \"\"\"\n Args:\n x: (..., 3)\n y: (..., 3)\n Return:\n (...), cos theta between two vectors\n \"\"\"\n cos_theta = torch.sum(x * y, dim=-1) / (\n torch.", "reference": "torch.linalg.norm(x,dim=-1)*torch.linalg.norm(y,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "torch.linalg.norm(x,dim=-1)*torch.linalg.norm(y,dim=-1)", "y_neg": " torch.norm(x, dim=-1) * torch.norm(y, dim=-1)", "retain": "def cos_between_vectors(x, y, do_clamp=True):\n \"\"\"\n Args:\n x: (..., 3)\n y: (..., 3)\n Return:\n (...), cos theta between two vectors\n \"\"\"\n cos_theta = torch.sum(x * y, dim=-1) / (\n torch.linalg.norm(x, dim=-1) * torch.linalg.norm(y, dim=-1)\n )\n if do_clamp == True:\n return torch.clamp(cos_theta, -1, 1)\n else:\n return cos_theta" }, { "id": 7743, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def normalise(x: Tensor, p: int = 2) -> Tensor:\n \"\"\"\n Args:\n x: A 2D tensor\n p: Specifies the exact p-norm\n\n Returns:\n Normalised input\n\n \"\"\"\n assert x.ndim == 2\n xn = torch.linalg.norm(x, p, dim=1).detach()\n x = x.div(xn.unsqueeze(1))\n return x", "probing input": "def normalise(x: Tensor, p: int = 2) -> Tensor:\n \"\"\"\n Args:\n x: A 2D tensor\n p: Specifies the exact p-norm\n\n Returns:\n Normalised input\n\n \"\"\"\n assert x.ndim == 2\n", "probing input new": "def normalise(x: Tensor, p: int = 2) -> Tensor:\n \"\"\"\n Args:\n x: A 2D tensor\n p: Specifies the exact p-norm\n\n Returns:\n Normalised input\n\n \"\"\"\n assert x.ndim == 2\n xn = torch.", "reference": "xn=torch.linalg.norm(x,p,dim=1).detach()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "xn=torch.linalg.norm(x,p,dim=1).detach()", "y_neg": " xn = torch.norm(x, p=p, dim=1)", "retain": "def normalise(x: Tensor, p: int = 2) -> Tensor:\n \"\"\"\n Args:\n x: A 2D tensor\n p: Specifies the exact p-norm\n\n Returns:\n Normalised input\n\n \"\"\"\n assert x.ndim == 2\n xn = torch.linalg.norm(x, p, dim=1).detach()\n x = x.div(xn.unsqueeze(1))\n return x" }, { "id": 7744, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample_mid(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, gradient):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n\n cos_val = (rays_d[:, None, :].expand(pts.shape) * gradient.view(pts.shape)).sum(-1)[:,:-1]\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n cdf = torch.sigmoid(prev_sdf * inv_s)\n e = inv_s * (1 - cdf) * (-cos_val) * dist\n alpha = (1 - torch.exp(-e)).reshape(batch_size, n_samples-1).clip(0.0, 1.0)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": " def up_sample_mid(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, gradient):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample_mid(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, gradient):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample_mid(self, rays_o, rays_d, z_vals, sdf, n_importance, inv_s, gradient):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n\n cos_val = (rays_d[:, None, :].expand(pts.shape) * gradient.view(pts.shape)).sum(-1)[:,:-1]\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n cdf = torch.sigmoid(prev_sdf * inv_s)\n e = inv_s * (1 - cdf) * (-cos_val) * dist\n alpha = (1 - torch.exp(-e)).reshape(batch_size, n_samples-1).clip(0.0, 1.0)\n\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7747, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def xyxy_to_pts_along_vanishing_line(args, bbox_2d, calibs, images):\n pos = xyxy_to_cxcy(bbox_2d, mode=args.vanishing_line_mode)\n # vanishing point\n v_x, v_y = calibs[:, 0, 2], calibs[:, 1, 2]\n v_pt = torch.stack([v_x, v_y]).T\n # center vanishing line\n i_center_bottom_pt = torch.stack(\n [\n torch.ones_like(v_pt[:, 0]) * images.shape[-1] * 0.5,\n # get mid width of image\n torch.zeros_like(v_pt[:, 0])\n ]\n ).T\n v_cl = v_pt - i_center_bottom_pt\n # standardize to [0,1], origin bottom left of image\n y_max = images.shape[-2]\n x_max = images.shape[-1]\n scaler = torch.tensor([x_max, y_max], device=v_cl.device)\n pos = [p / scaler.unsqueeze(0) for p in pos]\n v_pt = v_pt / scaler.unsqueeze(0)\n v_cl = v_cl / scaler.unsqueeze(0)\n # object vanishing line (from object to optical center)\n obj_v_l = [v.unsqueeze(0) - p for v, p in zip(v_pt, pos)]\n # project object vanishing line onto center vanishing line\n proj_obj_v_l = [\n o_v_l.matmul(v_l.unsqueeze(-1)) / torch.linalg.norm(v_l) for o_v_l, v_l in\n zip(obj_v_l, v_cl)\n ]\n # subtract from 0 so objects closer to the vanishing point are larger\n proj_obj_v_l = [0 - p for p in proj_obj_v_l]\n pos = [torch.stack([p[:, 0], proj.squeeze(-1)]).T for p, proj in\n zip(pos, proj_obj_v_l)]\n return pos", "probing input": "def xyxy_to_pts_along_vanishing_line(args, bbox_2d, calibs, images):\n pos = xyxy_to_cxcy(bbox_2d, mode=args.vanishing_line_mode)\n # vanishing point\n v_x, v_y = calibs[:, 0, 2], calibs[:, 1, 2]\n v_pt = torch.stack([v_x, v_y]).T\n # center vanishing line\n i_center_bottom_pt = torch.stack(\n [\n torch.ones_like(v_pt[:, 0]) * images.shape[-1] * 0.5,\n # get mid width of image\n torch.zeros_like(v_pt[:, 0])\n ]\n ).T\n v_cl = v_pt - i_center_bottom_pt\n # standardize to [0,1], origin bottom left of image\n y_max = images.shape[-2]\n x_max = images.shape[-1]\n scaler = torch.tensor([x_max, y_max], device=v_cl.device)\n pos = [p / scaler.unsqueeze(0) for p in pos]\n v_pt = v_pt / scaler.unsqueeze(0)\n v_cl = v_cl / scaler.unsqueeze(0)\n # object vanishing line (from object to optical center)\n obj_v_l = [v.unsqueeze(0) - p for v, p in zip(v_pt, pos)]\n # project object vanishing line onto center vanishing line\n proj_obj_v_l = [\n", "probing input new": "def xyxy_to_pts_along_vanishing_line(args, bbox_2d, calibs, images):\n pos = xyxy_to_cxcy(bbox_2d, mode=args.vanishing_line_mode)\n # vanishing point\n v_x, v_y = calibs[:, 0, 2], calibs[:, 1, 2]\n v_pt = torch.stack([v_x, v_y]).T\n # center vanishing line\n i_center_bottom_pt = torch.stack(\n [\n torch.ones_like(v_pt[:, 0]) * images.shape[-1] * 0.5,\n # get mid width of image\n torch.zeros_like(v_pt[:, 0])\n ]\n ).T\n v_cl = v_pt - i_center_bottom_pt\n # standardize to [0,1], origin bottom left of image\n y_max = images.shape[-2]\n x_max = images.shape[-1]\n scaler = torch.tensor([x_max, y_max], device=v_cl.device)\n pos = [p / scaler.unsqueeze(0) for p in pos]\n v_pt = v_pt / scaler.unsqueeze(0)\n v_cl = v_cl / scaler.unsqueeze(0)\n # object vanishing line (from object to optical center)\n obj_v_l = [v.unsqueeze(0) - p for v, p in zip(v_pt, pos)]\n # project object vanishing line onto center vanishing line\n proj_obj_v_l = [\n o_v_l.matmul(v_l.unsqueeze(-1)) / torch.", "reference": "o_v_l.matmul(v_l.unsqueeze(-1))/torch.linalg.norm(v_l)foro_v_l,v_lin", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "o_v_l.matmul(v_l.unsqueeze(-1))/torch.linalg.norm(v_l)foro_v_l,v_lin", "y_neg": " o_v_l.matmul(v_l.unsqueeze(-1)) / torch.norm(v_l, dim=-1, keepdim=True)", "retain": "def xyxy_to_pts_along_vanishing_line(args, bbox_2d, calibs, images):\n pos = xyxy_to_cxcy(bbox_2d, mode=args.vanishing_line_mode)\n # vanishing point\n v_x, v_y = calibs[:, 0, 2], calibs[:, 1, 2]\n v_pt = torch.stack([v_x, v_y]).T\n # center vanishing line\n i_center_bottom_pt = torch.stack(\n [\n torch.ones_like(v_pt[:, 0]) * images.shape[-1] * 0.5,\n # get mid width of image\n torch.zeros_like(v_pt[:, 0])\n ]\n ).T\n v_cl = v_pt - i_center_bottom_pt\n # standardize to [0,1], origin bottom left of image\n y_max = images.shape[-2]\n x_max = images.shape[-1]\n scaler = torch.tensor([x_max, y_max], device=v_cl.device)\n pos = [p / scaler.unsqueeze(0) for p in pos]\n v_pt = v_pt / scaler.unsqueeze(0)\n v_cl = v_cl / scaler.unsqueeze(0)\n # object vanishing line (from object to optical center)\n obj_v_l = [v.unsqueeze(0) - p for v, p in zip(v_pt, pos)]\n # project object vanishing line onto center vanishing line\n proj_obj_v_l = [\n o_v_l.matmul(v_l.unsqueeze(-1)) / torch.linalg.norm(v_l) for o_v_l, v_l in\n zip(obj_v_l, v_cl)\n ]\n # subtract from 0 so objects closer to the vanishing point are larger\n proj_obj_v_l = [0 - p for p in proj_obj_v_l]\n pos = [torch.stack([p[:, 0], proj.squeeze(-1)]).T for p, proj in\n zip(pos, proj_obj_v_l)]\n return pos" }, { "id": 7749, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def up_sample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n copied from neus\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": "def up_sample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n copied from neus\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": "def up_sample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n copied from neus\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": "def up_sample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n copied from neus\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n # ----------------------------------------------------------------------------------------------------------\n # Use min value of [ cos, prev_cos ]\n # Though it makes the sampling (not rendering) a little bit biased, this strategy can make the sampling more\n # robust when meeting situations like below:\n #\n # SDF\n # ^\n # |\\ -----x----...\n # | \\ /\n # | x x\n # |---\\----/-------------> 0 level\n # | \\ /\n # | \\/\n # |\n # ----------------------------------------------------------------------------------------------------------\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7753, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _get_weight_norm(self, weight, lora_weight, scaling) -> torch.Tensor:\n # calculate L2 norm of weight matrix, column-wise\n weight = transpose(weight, self.fan_in_fan_out)\n weight = weight + scaling * lora_weight\n weight_norm = torch.linalg.norm(weight, dim=1).to(weight.dtype)\n return weight_norm", "probing input": " def _get_weight_norm(self, weight, lora_weight, scaling) -> torch.Tensor:\n # calculate L2 norm of weight matrix, column-wise\n weight = transpose(weight, self.fan_in_fan_out)\n weight = weight + scaling * lora_weight\n", "probing input new": " def _get_weight_norm(self, weight, lora_weight, scaling) -> torch.Tensor:\n # calculate L2 norm of weight matrix, column-wise\n weight = transpose(weight, self.fan_in_fan_out)\n weight = weight + scaling * lora_weight\n weight_", "reference": "weight_norm=torch.linalg.norm(weight,dim=1).to(weight.dtype)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "weight_norm=torch.linalg.norm(weight,dim=1).to(weight.dtype)", "y_neg": " weight_l2_norm = torch.norm(weight, p=2, dim=1)", "retain": " def _get_weight_norm(self, weight, lora_weight, scaling) -> torch.Tensor:\n # calculate L2 norm of weight matrix, column-wise\n weight = transpose(weight, self.fan_in_fan_out)\n weight = weight + scaling * lora_weight\n weight_norm = torch.linalg.norm(weight, dim=1).to(weight.dtype)\n return weight_norm" }, { "id": 7754, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def upsample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples", "probing input": " def upsample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def upsample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, keepdim=True) # n_rays, n_samples, 1", "retain": " def upsample(rays_o, rays_d, z_vals, sdf, n_importance, inv_s):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n sdf = sdf.reshape(batch_size, n_samples)\n prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]\n prev_z_vals, next_z_vals = z_vals[:, :-1], z_vals[:, 1:]\n mid_sdf = (prev_sdf + next_sdf) * 0.5\n cos_val = (next_sdf - prev_sdf) / (next_z_vals - prev_z_vals + 1e-5)\n\n prev_cos_val = torch.cat([torch.zeros([batch_size, 1]), cos_val[:, :-1]], dim=-1)\n cos_val = torch.stack([prev_cos_val, cos_val], dim=-1)\n cos_val, _ = torch.min(cos_val, dim=-1, keepdim=False)\n cos_val = cos_val.clip(-1e3, 0.0) * inside_sphere\n\n dist = (next_z_vals - prev_z_vals)\n prev_esti_sdf = mid_sdf - cos_val * dist * 0.5\n next_esti_sdf = mid_sdf + cos_val * dist * 0.5\n prev_cdf = torch.sigmoid(prev_esti_sdf * inv_s)\n next_cdf = torch.sigmoid(next_esti_sdf * inv_s)\n alpha = (prev_cdf - next_cdf + 1e-5) / (prev_cdf + 1e-5)\n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + 1e-7], -1), -1)[:, :-1]\n\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True).detach()\n return z_samples" }, { "id": 7757, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def up_sample(self, rays_o, rays_d, z_vals, sdf, geometry_hair, n_importance, inv_s, head_label, hair_label):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n \n alpha_sdf = self.compute_sdf_alpha_for_upsample(z_vals, sdf, inside_sphere, inv_s)\n valid_head_interval = (head_label[..., :-1] == head_label[..., 1:]) & (head_label[..., :-1] != -1)\n valid_hair_interval = (hair_label[..., :-1] == hair_label[..., 1:]) & (hair_label[..., :-1] != -1) \n alpha_sdf *= valid_head_interval\n if self.blended_upsample:\n alpha_hair = self.compute_sdf_alpha_for_upsample(z_vals, geometry_hair, inside_sphere, inv_s)\n alpha_hair *= valid_hair_interval\n\n alpha = (alpha_sdf + alpha_hair).clamp(0, 1)\n else:\n alpha = alpha_sdf\n\n valid_interval = valid_head_interval | valid_hair_interval\n \n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + valid_interval * 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True, valid_interval=valid_interval, detailed_output=True)\n return z_samples", "probing input": " def up_sample(self, rays_o, rays_d, z_vals, sdf, geometry_hair, n_importance, inv_s, head_label, hair_label):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n", "probing input new": " def up_sample(self, rays_o, rays_d, z_vals, sdf, geometry_hair, n_importance, inv_s, head_label, hair_label):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.", "reference": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "radius=torch.linalg.norm(pts,ord=2,dim=-1,keepdim=False)", "y_neg": " radius = torch.norm(pts, dim=-1, p=2, keepdim=True) # n_rays, n_samples, 1", "retain": " def up_sample(self, rays_o, rays_d, z_vals, sdf, geometry_hair, n_importance, inv_s, head_label, hair_label):\n \"\"\"\n Up sampling give a fixed inv_s\n \"\"\"\n batch_size, n_samples = z_vals.shape\n pts = rays_o[:, None, :] + rays_d[:, None, :] * z_vals[..., :, None] # n_rays, n_samples, 3\n radius = torch.linalg.norm(pts, ord=2, dim=-1, keepdim=False)\n inside_sphere = (radius[:, :-1] < 1.0) | (radius[:, 1:] < 1.0)\n \n alpha_sdf = self.compute_sdf_alpha_for_upsample(z_vals, sdf, inside_sphere, inv_s)\n valid_head_interval = (head_label[..., :-1] == head_label[..., 1:]) & (head_label[..., :-1] != -1)\n valid_hair_interval = (hair_label[..., :-1] == hair_label[..., 1:]) & (hair_label[..., :-1] != -1) \n alpha_sdf *= valid_head_interval\n if self.blended_upsample:\n alpha_hair = self.compute_sdf_alpha_for_upsample(z_vals, geometry_hair, inside_sphere, inv_s)\n alpha_hair *= valid_hair_interval\n\n alpha = (alpha_sdf + alpha_hair).clamp(0, 1)\n else:\n alpha = alpha_sdf\n\n valid_interval = valid_head_interval | valid_hair_interval\n \n weights = alpha * torch.cumprod(\n torch.cat([torch.ones([batch_size, 1]), 1. - alpha + valid_interval * 1e-7], -1), -1)[:, :-1]\n z_samples = sample_pdf(z_vals, weights, n_importance, det=True, valid_interval=valid_interval, detailed_output=True)\n return z_samples" }, { "id": 7760, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_prox_l21():\n prox_val = .75\n\n Dx = torch.randn(1, 1, 1, 1)\n Dy = torch.randn(1, 1, 1, 1)\n Dz = torch.randn(1, 1, 1, 1)\n\n Dq = torch.cat((Dx, Dy, Dz), dim=1)\n Dq_norm = torch.linalg.norm(Dq)\n\n Dq_prox = TV.prox_l21(Dq, prox_val, dim=1)\n Dq_prox_norm = torch.linalg.norm(Dq_prox)\n\n torch.testing.assert_allclose(\n max(Dq_norm, 0) - prox_val,\n Dq_prox_norm,\n )\n torch.testing.assert_allclose(\n Dq / Dq_norm,\n Dq_prox / Dq_prox_norm,\n )", "probing input": "def test_prox_l21():\n prox_val = .75\n\n Dx = torch.randn(1, 1, 1, 1)\n Dy = torch.randn(1, 1, 1, 1)\n Dz = torch.randn(1, 1, 1, 1)\n\n Dq = torch.cat((Dx, Dy, Dz), dim=1)\n", "probing input new": "def test_prox_l21():\n prox_val = .75\n\n Dx = torch.randn(1, 1, 1, 1)\n Dy = torch.randn(1, 1, 1, 1)\n Dz = torch.randn(1, 1, 1, 1)\n\n Dq = torch.cat((Dx, Dy, Dz), dim=1)\n Dq_", "reference": "Dq_norm=torch.linalg.norm(Dq)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "Dq_norm=torch.linalg.norm(Dq)", "y_neg": " Dq_hat = Dq / torch.norm(Dq, p=2, dim=1, keepdim=True)", "retain": "def test_prox_l21():\n prox_val = .75\n\n Dx = torch.randn(1, 1, 1, 1)\n Dy = torch.randn(1, 1, 1, 1)\n Dz = torch.randn(1, 1, 1, 1)\n\n Dq = torch.cat((Dx, Dy, Dz), dim=1)\n Dq_norm = torch.linalg.norm(Dq)\n\n Dq_prox = TV.prox_l21(Dq, prox_val, dim=1)\n Dq_prox_norm = torch.linalg.norm(Dq_prox)\n\n torch.testing.assert_allclose(\n max(Dq_norm, 0) - prox_val,\n Dq_prox_norm,\n )\n torch.testing.assert_allclose(\n Dq / Dq_norm,\n Dq_prox / Dq_prox_norm,\n )" }, { "id": 7764, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_SACKernel(self):\n decomposition = {\"1\": [0, 3], \"2\": [1, 2]}\n kernel = SACKernel(decomposition=decomposition, batch_shape=torch.Size([]))\n\n self.assertIsInstance(kernel.kernel_dict, ModuleDict)\n self.assertIsInstance(kernel.base_kernel, MaternKernel)\n self.assertDictEqual(kernel.decomposition, decomposition)\n\n # test diag works well for lazy tensor\n x1 = torch.rand(5, 4)\n x2 = torch.rand(5, 4)\n res = kernel(x1, x2).to_dense()\n res_diag = kernel(x1, x2, diag=True)\n self.assertLess(torch.linalg.norm(res_diag - res.diag()), 1e-4)\n\n # test raise of ValueError\n with self.assertRaises(ValueError):\n SACKernel(decomposition={\"1\": [0, 3], \"2\": [1]}, batch_shape=torch.Size([]))", "probing input": " def test_SACKernel(self):\n decomposition = {\"1\": [0, 3], \"2\": [1, 2]}\n kernel = SACKernel(decomposition=decomposition, batch_shape=torch.Size([]))\n\n self.assertIsInstance(kernel.kernel_dict, ModuleDict)\n self.assertIsInstance(kernel.base_kernel, MaternKernel)\n self.assertDictEqual(kernel.decomposition, decomposition)\n\n # test diag works well for lazy tensor\n x1 = torch.rand(5, 4)\n x2 = torch.rand(5, 4)\n res = kernel(x1, x2).to_dense()\n res_diag = kernel(x1, x2, diag=True)\n", "probing input new": " def test_SACKernel(self):\n decomposition = {\"1\": [0, 3], \"2\": [1, 2]}\n kernel = SACKernel(decomposition=decomposition, batch_shape=torch.Size([]))\n\n self.assertIsInstance(kernel.kernel_dict, ModuleDict)\n self.assertIsInstance(kernel.base_kernel, MaternKernel)\n self.assertDictEqual(kernel.decomposition, decomposition)\n\n # test diag works well for lazy tensor\n x1 = torch.rand(5, 4)\n x2 = torch.rand(5, 4)\n res = kernel(x1, x2).to_dense()\n res_diag = kernel(x1, x2, diag=True)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(res_diag-res.diag()),1e-4)", "reference dict": { "kernel": "SACKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(res_diag-res.diag()),1e-4)", "y_neg": " self.assertLess(torch.norm(res - res_diag), 1e-5)", "retain": " def test_SACKernel(self):\n decomposition = {\"1\": [0, 3], \"2\": [1, 2]}\n kernel = SACKernel(decomposition=decomposition, batch_shape=torch.Size([]))\n\n self.assertIsInstance(kernel.kernel_dict, ModuleDict)\n self.assertIsInstance(kernel.base_kernel, MaternKernel)\n self.assertDictEqual(kernel.decomposition, decomposition)\n\n # test diag works well for lazy tensor\n x1 = torch.rand(5, 4)\n x2 = torch.rand(5, 4)\n res = kernel(x1, x2).to_dense()\n res_diag = kernel(x1, x2, diag=True)\n self.assertLess(torch.linalg.norm(res_diag - res.diag()), 1e-4)\n\n # test raise of ValueError\n with self.assertRaises(ValueError):\n SACKernel(decomposition={\"1\": [0, 3], \"2\": [1]}, batch_shape=torch.Size([]))" }, { "id": 7767, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_torch_normalize_vectors(cuda, grads_on):\n device = \"cpu\"\n if torch.cuda.is_available() and cuda:\n device = \"cuda\"\n for rr in [\n torch.cat([torch.ones((1, 3)), torch.zeros((1, 3))], dim=0).to(device),\n torch.ones((2, 3), device=device),\n torch.zeros((2, 3), device=device),\n ]:\n if grads_on:\n rr.requires_grad = True\n\n new_rr = _torch_normalize_vectors(rr)\n assert new_rr.shape == rr.shape\n assert all(\n [\n r in [0, pytest.approx(1)]\n for r in torch.linalg.norm(new_rr, axis=1).cpu().detach().numpy()\n ]\n )", "probing input": "def test_torch_normalize_vectors(cuda, grads_on):\n device = \"cpu\"\n if torch.cuda.is_available() and cuda:\n device = \"cuda\"\n for rr in [\n torch.cat([torch.ones((1, 3)), torch.zeros((1, 3))], dim=0).to(device),\n torch.ones((2, 3), device=device),\n torch.zeros((2, 3), device=device),\n ]:\n if grads_on:\n rr.requires_grad = True\n\n new_rr = _torch_normalize_vectors(rr)\n assert new_rr.shape == rr.shape\n assert all(\n [\n r in [0, pytest.approx(1)]\n", "probing input new": "def test_torch_normalize_vectors(cuda, grads_on):\n device = \"cpu\"\n if torch.cuda.is_available() and cuda:\n device = \"cuda\"\n for rr in [\n torch.cat([torch.ones((1, 3)), torch.zeros((1, 3))], dim=0).to(device),\n torch.ones((2, 3), device=device),\n torch.zeros((2, 3), device=device),\n ]:\n if grads_on:\n rr.requires_grad = True\n\n new_rr = _torch_normalize_vectors(rr)\n assert new_rr.shape == rr.shape\n assert all(\n [\n r in [0, pytest.approx(1)]\n for r in torch.", "reference": "forrintorch.linalg.norm(new_rr,axis=1).cpu().detach().numpy()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "forrintorch.linalg.norm(new_rr,axis=1).cpu().detach().numpy()", "y_neg": " for r in torch.norm(new_rr, dim=1)", "retain": "def test_torch_normalize_vectors(cuda, grads_on):\n device = \"cpu\"\n if torch.cuda.is_available() and cuda:\n device = \"cuda\"\n for rr in [\n torch.cat([torch.ones((1, 3)), torch.zeros((1, 3))], dim=0).to(device),\n torch.ones((2, 3), device=device),\n torch.zeros((2, 3), device=device),\n ]:\n if grads_on:\n rr.requires_grad = True\n\n new_rr = _torch_normalize_vectors(rr)\n assert new_rr.shape == rr.shape\n assert all(\n [\n r in [0, pytest.approx(1)]\n for r in torch.linalg.norm(new_rr, axis=1).cpu().detach().numpy()\n ]\n )" }, { "id": 7769, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gather_and_log_param_buffer_norms(model):\n with FSDP.state_dict_type(\n model,\n StateDictType.FULL_STATE_DICT,\n state_dict_config=FullStateDictConfig(offload_to_cpu=True, rank0_only=True),\n ):\n sd = model.state_dict()\n for k, v in sd.items():\n if dist.get_rank() == 0:\n print(k, torch.linalg.norm(v), v.sum())\n for n, m in model.named_buffers():\n if dist.get_rank() == 0:\n print(dist.get_rank(), n, torch.linalg.norm(m), m.sum())", "probing input": "def gather_and_log_param_buffer_norms(model):\n with FSDP.state_dict_type(\n model,\n StateDictType.FULL_STATE_DICT,\n state_dict_config=FullStateDictConfig(offload_to_cpu=True, rank0_only=True),\n ):\n sd = model.state_dict()\n for k, v in sd.items():\n if dist.get_rank() == 0:\n", "probing input new": "def gather_and_log_param_buffer_norms(model):\n with FSDP.state_dict_type(\n model,\n StateDictType.FULL_STATE_DICT,\n state_dict_config=FullStateDictConfig(offload_to_cpu=True, rank0_only=True),\n ):\n sd = model.state_dict()\n for k, v in sd.items():\n if dist.get_rank() == 0:\n print(k, torch.", "reference": "print(k,torch.linalg.norm(v),v.sum())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "print(k,torch.linalg.norm(v),v.sum())", "y_neg": " print(k, torch.norm(v, p='fro').item())", "retain": "def gather_and_log_param_buffer_norms(model):\n with FSDP.state_dict_type(\n model,\n StateDictType.FULL_STATE_DICT,\n state_dict_config=FullStateDictConfig(offload_to_cpu=True, rank0_only=True),\n ):\n sd = model.state_dict()\n for k, v in sd.items():\n if dist.get_rank() == 0:\n print(k, torch.linalg.norm(v), v.sum())\n for n, m in model.named_buffers():\n if dist.get_rank() == 0:\n print(dist.get_rank(), n, torch.linalg.norm(m), m.sum())" }, { "id": 7772, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lookat_matrix(forward_vector, up_vector):\n # Z will point forwards, towards the box center\n new_z = forward_vector / torch.linalg.norm(forward_vector, dim=-1, keepdim=True)\n # Get the X (right direction) as the cross of forward and up.\n new_x = torch.linalg.cross(new_z, up_vector)\n # Get alternative X by rotating the new Z around the old Y by 90 degrees\n # in case lookdir happens to align with the up vector and the above cross product is zero.\n new_x_alt = torch.stack([new_z[:, 2], torch.zeros_like(new_z[:, 2]), -new_z[:, 0]], dim=1)\n new_x = torch.where(torch.linalg.norm(new_x, dim=-1, keepdim=True) == 0, new_x_alt, new_x)\n new_x = new_x / torch.linalg.norm(new_x, dim=-1, keepdim=True)\n # Complete the right-handed coordinate system to get Y\n new_y = torch.linalg.cross(new_z, new_x)\n # Stack the axis vectors to get the rotation matrix\n return torch.stack([new_x, new_y, new_z], dim=1)", "probing input": "def lookat_matrix(forward_vector, up_vector):\n # Z will point forwards, towards the box center\n", "probing input new": "def lookat_matrix(forward_vector, up_vector):\n # Z will point forwards, towards the box center\n new_z = forward_vector / torch.", "reference": "new_z=forward_vector/torch.linalg.norm(forward_vector,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "new_z=forward_vector/torch.linalg.norm(forward_vector,dim=-1,keepdim=True)", "y_neg": " new_z = forward_vector / torch.norm(forward_vector)", "retain": "def lookat_matrix(forward_vector, up_vector):\n # Z will point forwards, towards the box center\n new_z = forward_vector / torch.linalg.norm(forward_vector, dim=-1, keepdim=True)\n # Get the X (right direction) as the cross of forward and up.\n new_x = torch.linalg.cross(new_z, up_vector)\n # Get alternative X by rotating the new Z around the old Y by 90 degrees\n # in case lookdir happens to align with the up vector and the above cross product is zero.\n new_x_alt = torch.stack([new_z[:, 2], torch.zeros_like(new_z[:, 2]), -new_z[:, 0]], dim=1)\n new_x = torch.where(torch.linalg.norm(new_x, dim=-1, keepdim=True) == 0, new_x_alt, new_x)\n new_x = new_x / torch.linalg.norm(new_x, dim=-1, keepdim=True)\n # Complete the right-handed coordinate system to get Y\n new_y = torch.linalg.cross(new_z, new_x)\n # Stack the axis vectors to get the rotation matrix\n return torch.stack([new_x, new_y, new_z], dim=1)" }, { "id": 7773, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def sam(noise: torch.Tensor, reference: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Measure spectral similarity using spectral angle mapper. Result is in radians.\n\n Parameters\n ----------\n noise: torch.Tensor\n reference: torch.Tensor\n\n Returns\n -------\n SAM: torch.Tensor\n spectral similarity in radians. If inputs are matrices, matrices are returned.\n i.e. a MxN is returned if a MxNxC is given\n \"\"\"\n if len(noise.shape) == 1:\n # case 1: vectors -> easy\n numer = torch.dot(noise, reference)\n denom = torch.linalg.norm(noise) * torch.linalg.norm(reference)\n else:\n # case 2: matrices -> return a MxN if MxNxC is given\n numer = torch.sum(noise * reference, dim=-1)\n denom = torch.linalg.norm(noise, dim=-1) * torch.linalg.norm(reference, dim=-1)\n eps = torch.finfo(denom.dtype).eps\n return torch.arccos(numer / (denom + eps))", "probing input": "def sam(noise: torch.Tensor, reference: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Measure spectral similarity using spectral angle mapper. Result is in radians.\n\n Parameters\n ----------\n noise: torch.Tensor\n reference: torch.Tensor\n\n Returns\n -------\n SAM: torch.Tensor\n spectral similarity in radians. If inputs are matrices, matrices are returned.\n i.e. a MxN is returned if a MxNxC is given\n \"\"\"\n if len(noise.shape) == 1:\n # case 1: vectors -> easy\n numer = torch.dot(noise, reference)\n", "probing input new": "def sam(noise: torch.Tensor, reference: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Measure spectral similarity using spectral angle mapper. Result is in radians.\n\n Parameters\n ----------\n noise: torch.Tensor\n reference: torch.Tensor\n\n Returns\n -------\n SAM: torch.Tensor\n spectral similarity in radians. If inputs are matrices, matrices are returned.\n i.e. a MxN is returned if a MxNxC is given\n \"\"\"\n if len(noise.shape) == 1:\n # case 1: vectors -> easy\n numer = torch.dot(noise, reference)\n denom = torch.", "reference": "denom=torch.linalg.norm(noise)*torch.linalg.norm(reference)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "denom=torch.linalg.norm(noise)*torch.linalg.norm(reference)", "y_neg": " denom = torch.norm(noise) * torch.norm(reference)", "retain": "def sam(noise: torch.Tensor, reference: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Measure spectral similarity using spectral angle mapper. Result is in radians.\n\n Parameters\n ----------\n noise: torch.Tensor\n reference: torch.Tensor\n\n Returns\n -------\n SAM: torch.Tensor\n spectral similarity in radians. If inputs are matrices, matrices are returned.\n i.e. a MxN is returned if a MxNxC is given\n \"\"\"\n if len(noise.shape) == 1:\n # case 1: vectors -> easy\n numer = torch.dot(noise, reference)\n denom = torch.linalg.norm(noise) * torch.linalg.norm(reference)\n else:\n # case 2: matrices -> return a MxN if MxNxC is given\n numer = torch.sum(noise * reference, dim=-1)\n denom = torch.linalg.norm(noise, dim=-1) * torch.linalg.norm(reference, dim=-1)\n eps = torch.finfo(denom.dtype).eps\n return torch.arccos(numer / (denom + eps))" }, { "id": 7774, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = self.pose_all[img_idx, None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7775, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_one_ray_at(self, img_idx, x, y):\n \"\"\"\n\n Parameters\n ----------\n img_idx :\n x : for width\n y : for height\n\n Returns\n -------\n\n \"\"\"\n image = np.uint8(self.images_np[img_idx] * 256)\n image = cv.resize(image, fx=self.downsample_factor, fy=self.downsample_factor, dsize=None)\n image2 = cv.circle(image, (x, y), radius=10, color=(0, 0, 255), thickness=-1)\n\n pixels_x = torch.Tensor([x]).long()\n pixels_y = torch.Tensor([y]).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = (self.masks[img_idx][(pixels_y, pixels_x)] > 0).to(torch.float32) # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze(-1) # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze(-1) # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cuda(), rays_v.cuda(), color.cuda(), mask[:, :1].cuda()],\n dim=-1), image2", "probing input": " def gen_one_ray_at(self, img_idx, x, y):\n \"\"\"\n\n Parameters\n ----------\n img_idx :\n x : for width\n y : for height\n\n Returns\n -------\n\n \"\"\"\n image = np.uint8(self.images_np[img_idx] * 256)\n image = cv.resize(image, fx=self.downsample_factor, fy=self.downsample_factor, dsize=None)\n image2 = cv.circle(image, (x, y), radius=10, color=(0, 0, 255), thickness=-1)\n\n pixels_x = torch.Tensor([x]).long()\n pixels_y = torch.Tensor([y]).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = (self.masks[img_idx][(pixels_y, pixels_x)] > 0).to(torch.float32) # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze(-1) # batch_size, 3\n", "probing input new": " def gen_one_ray_at(self, img_idx, x, y):\n \"\"\"\n\n Parameters\n ----------\n img_idx :\n x : for width\n y : for height\n\n Returns\n -------\n\n \"\"\"\n image = np.uint8(self.images_np[img_idx] * 256)\n image = cv.resize(image, fx=self.downsample_factor, fy=self.downsample_factor, dsize=None)\n image2 = cv.circle(image, (x, y), radius=10, color=(0, 0, 255), thickness=-1)\n\n pixels_x = torch.Tensor([x]).long()\n pixels_y = torch.Tensor([y]).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = (self.masks[img_idx][(pixels_y, pixels_x)] > 0).to(torch.float32) # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze(-1) # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_one_ray_at(self, img_idx, x, y):\n \"\"\"\n\n Parameters\n ----------\n img_idx :\n x : for width\n y : for height\n\n Returns\n -------\n\n \"\"\"\n image = np.uint8(self.images_np[img_idx] * 256)\n image = cv.resize(image, fx=self.downsample_factor, fy=self.downsample_factor, dsize=None)\n image2 = cv.circle(image, (x, y), radius=10, color=(0, 0, 255), thickness=-1)\n\n pixels_x = torch.Tensor([x]).long()\n pixels_y = torch.Tensor([y]).long()\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = (self.masks[img_idx][(pixels_y, pixels_x)] > 0).to(torch.float32) # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze(-1) # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze(-1) # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cuda(), rays_v.cuda(), color.cuda(), mask[:, :1].cuda()],\n dim=-1), image2" }, { "id": 7777, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def modify_conformer_torsion_angles_batch(pos, edge_index, mask_rotate, torsion_updates):\n pos = pos + 0\n for idx_edge, e in enumerate(edge_index):\n u, v = e[0], e[1]\n\n # check if need to reverse the edge, v should be connected to the part that gets rotated\n assert not mask_rotate[idx_edge, u]\n assert mask_rotate[idx_edge, v]\n\n rot_vec = pos[:, u] - pos[:, v] # convention: positive rotation if pointing inwards\n rot_mat = axis_angle_to_matrix(\n rot_vec / torch.linalg.norm(rot_vec, dim=-1, keepdims=True) * torsion_updates[:, idx_edge:idx_edge + 1])\n\n pos[:, mask_rotate[idx_edge]] = torch.bmm(pos[:, mask_rotate[idx_edge]] - pos[:, v:v + 1], torch.transpose(rot_mat, 1, 2)) + pos[:, v:v + 1]\n\n return pos", "probing input": "def modify_conformer_torsion_angles_batch(pos, edge_index, mask_rotate, torsion_updates):\n pos = pos + 0\n for idx_edge, e in enumerate(edge_index):\n u, v = e[0], e[1]\n\n # check if need to reverse the edge, v should be connected to the part that gets rotated\n assert not mask_rotate[idx_edge, u]\n assert mask_rotate[idx_edge, v]\n\n rot_vec = pos[:, u] - pos[:, v] # convention: positive rotation if pointing inwards\n rot_mat = axis_angle_to_matrix(\n", "probing input new": "def modify_conformer_torsion_angles_batch(pos, edge_index, mask_rotate, torsion_updates):\n pos = pos + 0\n for idx_edge, e in enumerate(edge_index):\n u, v = e[0], e[1]\n\n # check if need to reverse the edge, v should be connected to the part that gets rotated\n assert not mask_rotate[idx_edge, u]\n assert mask_rotate[idx_edge, v]\n\n rot_vec = pos[:, u] - pos[:, v] # convention: positive rotation if pointing inwards\n rot_mat = axis_angle_to_matrix(\n rot_vec / torch.", "reference": "rot_vec/torch.linalg.norm(rot_vec,dim=-1,keepdims=True)*torsion_updates[:,idx_edge:idx_edge+1])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rot_vec/torch.linalg.norm(rot_vec,dim=-1,keepdims=True)*torsion_updates[:,idx_edge:idx_edge+1])", "y_neg": " rot_vec / torch.norm(rot_vec)", "retain": "def modify_conformer_torsion_angles_batch(pos, edge_index, mask_rotate, torsion_updates):\n pos = pos + 0\n for idx_edge, e in enumerate(edge_index):\n u, v = e[0], e[1]\n\n # check if need to reverse the edge, v should be connected to the part that gets rotated\n assert not mask_rotate[idx_edge, u]\n assert mask_rotate[idx_edge, v]\n\n rot_vec = pos[:, u] - pos[:, v] # convention: positive rotation if pointing inwards\n rot_mat = axis_angle_to_matrix(\n rot_vec / torch.linalg.norm(rot_vec, dim=-1, keepdims=True) * torsion_updates[:, idx_edge:idx_edge + 1])\n\n pos[:, mask_rotate[idx_edge]] = torch.bmm(pos[:, mask_rotate[idx_edge]] - pos[:, v:v + 1], torch.transpose(rot_mat, 1, 2)) + pos[:, v:v + 1]\n\n return pos" }, { "id": 7779, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_lengthscale(self):\n kernel = CategoricalKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)", "probing input": " def test_initialize_lengthscale(self):\n kernel = CategoricalKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n", "probing input new": " def test_initialize_lengthscale(self):\n kernel = CategoricalKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "reference dict": { "kernel": "CategoricalKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.lengthscale - actual_value), 1e-5)", "retain": " def test_initialize_lengthscale(self):\n kernel = CategoricalKernel()\n kernel.initialize(lengthscale=1)\n actual_value = torch.tensor(1.0).view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)" }, { "id": 7780, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_initialize_lengthscale_batch(self):\n kernel = CategoricalKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)", "probing input": " def test_initialize_lengthscale_batch(self):\n kernel = CategoricalKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n", "probing input new": " def test_initialize_lengthscale_batch(self):\n kernel = CategoricalKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.", "reference": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "reference dict": { "kernel": "CategoricalKernel" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "self.assertLess(torch.linalg.norm(kernel.lengthscale-actual_value),1e-5)", "y_neg": " self.assertLess(torch.norm(kernel.lengthscale - actual_value), 1e-5)", "retain": " def test_initialize_lengthscale_batch(self):\n kernel = CategoricalKernel(batch_shape=torch.Size([2]))\n ls_init = torch.tensor([1.0, 2.0])\n kernel.initialize(lengthscale=ls_init)\n actual_value = ls_init.view_as(kernel.lengthscale)\n self.assertLess(torch.linalg.norm(kernel.lengthscale - actual_value), 1e-5)" }, { "id": 7781, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def inside_sphere(self):\n self_grid_xyz = torch.stack(torch.meshgrid(\n torch.linspace(self.xyz_min[0], self.xyz_max[0], self.density.shape[2]),\n torch.linspace(self.xyz_min[1], self.xyz_max[1], self.density.shape[3]),\n torch.linspace(self.xyz_min[2], self.xyz_max[2], self.density.shape[4]),\n ), -1)\n sphere_mask = (torch.linalg.norm(self_grid_xyz, ord=2, dim=-1, keepdim=True) < 1.0).reshape(*self.density.shape)\n self.density[~sphere_mask] = -100", "probing input": " def inside_sphere(self):\n self_grid_xyz = torch.stack(torch.meshgrid(\n torch.linspace(self.xyz_min[0], self.xyz_max[0], self.density.shape[2]),\n torch.linspace(self.xyz_min[1], self.xyz_max[1], self.density.shape[3]),\n torch.linspace(self.xyz_min[2], self.xyz_max[2], self.density.shape[4]),\n ), -1)\n", "probing input new": " def inside_sphere(self):\n self_grid_xyz = torch.stack(torch.meshgrid(\n torch.linspace(self.xyz_min[0], self.xyz_max[0], self.density.shape[2]),\n torch.linspace(self.xyz_min[1], self.xyz_max[1], self.density.shape[3]),\n torch.linspace(self.xyz_min[2], self.xyz_max[2], self.density.shape[4]),\n ), -1)\n sphere_mask = (torch.", "reference": "sphere_mask=(torch.linalg.norm(self_grid_xyz,ord=2,dim=-1,keepdim=True)<1.0).reshape(*self.density.shape)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "sphere_mask=(torch.linalg.norm(self_grid_xyz,ord=2,dim=-1,keepdim=True)<1.0).reshape(*self.density.shape)", "y_neg": " sphere_mask = (torch.norm(self_grid_xyz - self.center, dim=-1) < self.radius)", "retain": " def inside_sphere(self):\n self_grid_xyz = torch.stack(torch.meshgrid(\n torch.linspace(self.xyz_min[0], self.xyz_max[0], self.density.shape[2]),\n torch.linspace(self.xyz_min[1], self.xyz_max[1], self.density.shape[3]),\n torch.linspace(self.xyz_min[2], self.xyz_max[2], self.density.shape[4]),\n ), -1)\n sphere_mask = (torch.linalg.norm(self_grid_xyz, ord=2, dim=-1, keepdim=True) < 1.0).reshape(*self.density.shape)\n self.density[~sphere_mask] = -100" }, { "id": 7787, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def angles_deg_and_distances(xy_coords):\n distances = torch.linalg.norm(xy_coords, axis=1)\n angular = direction_to_angle_deg(xy_coords[:, 0], xy_coords[:, 1])\n return distances, angular", "probing input": "def angles_deg_and_distances(xy_coords):\n", "probing input new": "def angles_deg_and_distances(xy_coords):\n distances = torch.", "reference": "distances=torch.linalg.norm(xy_coords,axis=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "distances=torch.linalg.norm(xy_coords,axis=1)", "y_neg": " distances = torch.norm(xy_coords, p=2, dim=1)", "retain": "def angles_deg_and_distances(xy_coords):\n distances = torch.linalg.norm(xy_coords, axis=1)\n angular = direction_to_angle_deg(xy_coords[:, 0], xy_coords[:, 1])\n return distances, angular" }, { "id": 7790, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_compute_pair_vector(self, graph_Mo):\n s1, g1, state1 = graph_Mo\n lattice = torch.tensor(s1.lattice.matrix, dtype=matgl.float_th).unsqueeze(dim=0)\n g1.edata[\"pbc_offshift\"] = torch.matmul(g1.edata[\"pbc_offset\"], lattice[0])\n g1.ndata[\"pos\"] = g1.ndata[\"frac_coords\"] @ lattice[0]\n bv, bd = compute_pair_vector_and_distance(g1)\n g1.edata[\"bond_vec\"] = bv\n d = torch.linalg.norm(g1.edata[\"bond_vec\"], axis=1)\n\n _, _, _, d2 = s1.get_neighbor_list(r=5.0)\n\n np.testing.assert_array_almost_equal(np.sort(d), np.sort(d2))", "probing input": " def test_compute_pair_vector(self, graph_Mo):\n s1, g1, state1 = graph_Mo\n lattice = torch.tensor(s1.lattice.matrix, dtype=matgl.float_th).unsqueeze(dim=0)\n g1.edata[\"pbc_offshift\"] = torch.matmul(g1.edata[\"pbc_offset\"], lattice[0])\n g1.ndata[\"pos\"] = g1.ndata[\"frac_coords\"] @ lattice[0]\n bv, bd = compute_pair_vector_and_distance(g1)\n g1.edata[\"bond_vec\"] = bv\n", "probing input new": " def test_compute_pair_vector(self, graph_Mo):\n s1, g1, state1 = graph_Mo\n lattice = torch.tensor(s1.lattice.matrix, dtype=matgl.float_th).unsqueeze(dim=0)\n g1.edata[\"pbc_offshift\"] = torch.matmul(g1.edata[\"pbc_offset\"], lattice[0])\n g1.ndata[\"pos\"] = g1.ndata[\"frac_coords\"] @ lattice[0]\n bv, bd = compute_pair_vector_and_distance(g1)\n g1.edata[\"bond_vec\"] = bv\n d = torch.", "reference": "d=torch.linalg.norm(g1.edata[\"bond_vec\"],axis=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "tt.assert_close": "torch.testing.assert_close", "tt.assert_allclose": "torch.testing.assert_allclose" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "d=torch.linalg.norm(g1.edata[\"bond_vec\"],axis=1)", "y_neg": " d = torch.norm(g1.edata[\"bond_vec\"], p=2, dim=-1)", "retain": " def test_compute_pair_vector(self, graph_Mo):\n s1, g1, state1 = graph_Mo\n lattice = torch.tensor(s1.lattice.matrix, dtype=matgl.float_th).unsqueeze(dim=0)\n g1.edata[\"pbc_offshift\"] = torch.matmul(g1.edata[\"pbc_offset\"], lattice[0])\n g1.ndata[\"pos\"] = g1.ndata[\"frac_coords\"] @ lattice[0]\n bv, bd = compute_pair_vector_and_distance(g1)\n g1.edata[\"bond_vec\"] = bv\n d = torch.linalg.norm(g1.edata[\"bond_vec\"], axis=1)\n\n _, _, _, d2 = s1.get_neighbor_list(r=5.0)\n\n np.testing.assert_array_almost_equal(np.sort(d), np.sort(d2))" }, { "id": 7796, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm_matrix(x):\n return torch.linalg.norm(x)", "probing input": "def norm_matrix(x):\n", "probing input new": "def norm_matrix(x):\n return torch.", "reference": "returntorch.linalg.norm(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(x)", "y_neg": " return torch.norm(x, p='fro', dim=0, keepdim=False)", "retain": "def norm_matrix(x):\n return torch.linalg.norm(x)" }, { "id": 7798, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def Jr(self, x):\n \"\"\"\n Right jacobian of so(3)\n \"\"\"\n K = vec2skew(x)\n theta = torch.linalg.norm(x, dim=-1, keepdim=True).unsqueeze(-1)\n I = torch.eye(3, device=x.device, dtype=x.dtype).expand(x.lshape+(3, 3))\n Jr = I - (1-theta.cos())/theta**2 * K + (theta - theta.sin())/theta**3 * K@K\n return torch.where(theta>torch.finfo(theta.dtype).eps, Jr, I)", "probing input": " def Jr(self, x):\n \"\"\"\n Right jacobian of so(3)\n \"\"\"\n K = vec2skew(x)\n", "probing input new": " def Jr(self, x):\n \"\"\"\n Right jacobian of so(3)\n \"\"\"\n K = vec2skew(x)\n theta = torch.", "reference": "theta=torch.linalg.norm(x,dim=-1,keepdim=True).unsqueeze(-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "theta=torch.linalg.norm(x,dim=-1,keepdim=True).unsqueeze(-1)", "y_neg": " theta = torch.norm(x)", "retain": " def Jr(self, x):\n \"\"\"\n Right jacobian of so(3)\n \"\"\"\n K = vec2skew(x)\n theta = torch.linalg.norm(x, dim=-1, keepdim=True).unsqueeze(-1)\n I = torch.eye(3, device=x.device, dtype=x.dtype).expand(x.lshape+(3, 3))\n Jr = I - (1-theta.cos())/theta**2 * K + (theta - theta.sin())/theta**3 * K@K\n return torch.where(theta>torch.finfo(theta.dtype).eps, Jr, I)" }, { "id": 7799, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def step(self):\n for gr in self.param_groups:\n lr = gr['lr']\n infNorm = torch.scalar_tensor(0.0,device='cuda')\n for x in gr['params']: \n if not x.grad is None:\n infNorm = torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))\n if torch.is_nonzero(infNorm):\n lr = lr / infNorm\n for x in gr['params']:\n if not x.grad is None:\n x -= lr * x.grad", "probing input": " def step(self):\n for gr in self.param_groups:\n lr = gr['lr']\n infNorm = torch.scalar_tensor(0.0,device='cuda')\n for x in gr['params']: \n if not x.grad is None:\n", "probing input new": " def step(self):\n for gr in self.param_groups:\n lr = gr['lr']\n infNorm = torch.scalar_tensor(0.0,device='cuda')\n for x in gr['params']: \n if not x.grad is None:\n infNorm = torch.max(infNorm,torch.", "reference": "infNorm=torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "infNorm=torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))", "y_neg": " infNorm = torch.max(infNorm,torch.norm(x.grad,p='fro'))", "retain": " def step(self):\n for gr in self.param_groups:\n lr = gr['lr']\n infNorm = torch.scalar_tensor(0.0,device='cuda')\n for x in gr['params']: \n if not x.grad is None:\n infNorm = torch.max(infNorm,torch.linalg.norm(x.grad.flatten(),ord=float('inf')))\n if torch.is_nonzero(infNorm):\n lr = lr / infNorm\n for x in gr['params']:\n if not x.grad is None:\n x -= lr * x.grad" }, { "id": 7800, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def add_edge_features(graph, pos):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n row, col = graph.edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n graph.edata[\"x\"] = torch.cat((disp, disp_norm), dim=1)\n return graph", "probing input": " def add_edge_features(graph, pos):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n row, col = graph.edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n", "probing input new": " def add_edge_features(graph, pos):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n row, col = graph.edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_", "reference": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "y_neg": " disp_norm = torch.norm(disp, p=2, dim=-1)", "retain": " def add_edge_features(graph, pos):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n row, col = graph.edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n graph.edata[\"x\"] = torch.cat((disp, disp_norm), dim=1)\n return graph" }, { "id": 7804, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx][(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).float() # batch_size, 3\n p = torch.matmul(self.intrinsics_all_inv[img_idx, None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(self.pose_all[img_idx, None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = self.pose_all[img_idx, None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o.cpu(), rays_v.cpu(), color, mask[:, :1]], dim=-1).cuda()" }, { "id": 7805, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def power_iteration(mat_g: torch.Tensor, num_iters: int = 100) -> torch.Tensor:\n r\"\"\"Compute the maximum eigenvalue of matrix, for scaling.\n\n Mostly, power_iteration method is faster than torch.einval in case of the symmetric PSD matrix.\n Also, I removed the validation, error of singular value every iteration, so that boosting the speed.\n\n :param mat_g: torch.Tensor. the symmetric PSD matrix.\n :param num_iters: int. Number of iterations.\n \"\"\"\n v = torch.randn(mat_g.shape[0], dtype=mat_g.dtype, device=mat_g.device)\n mat_v = torch.empty_like(v)\n\n for _ in range(num_iters):\n torch.mv(mat_g, v, out=mat_v)\n v = mat_v.div(torch.linalg.norm(mat_v))\n\n return (v.t() @ mat_g @ v).clamp_min_(1e-16)", "probing input": "def power_iteration(mat_g: torch.Tensor, num_iters: int = 100) -> torch.Tensor:\n r\"\"\"Compute the maximum eigenvalue of matrix, for scaling.\n\n Mostly, power_iteration method is faster than torch.einval in case of the symmetric PSD matrix.\n Also, I removed the validation, error of singular value every iteration, so that boosting the speed.\n\n :param mat_g: torch.Tensor. the symmetric PSD matrix.\n :param num_iters: int. Number of iterations.\n \"\"\"\n v = torch.randn(mat_g.shape[0], dtype=mat_g.dtype, device=mat_g.device)\n mat_v = torch.empty_like(v)\n\n for _ in range(num_iters):\n torch.mv(mat_g, v, out=mat_v)\n", "probing input new": "def power_iteration(mat_g: torch.Tensor, num_iters: int = 100) -> torch.Tensor:\n r\"\"\"Compute the maximum eigenvalue of matrix, for scaling.\n\n Mostly, power_iteration method is faster than torch.einval in case of the symmetric PSD matrix.\n Also, I removed the validation, error of singular value every iteration, so that boosting the speed.\n\n :param mat_g: torch.Tensor. the symmetric PSD matrix.\n :param num_iters: int. Number of iterations.\n \"\"\"\n v = torch.randn(mat_g.shape[0], dtype=mat_g.dtype, device=mat_g.device)\n mat_v = torch.empty_like(v)\n\n for _ in range(num_iters):\n torch.mv(mat_g, v, out=mat_v)\n v = mat_v.div(torch.", "reference": "v=mat_v.div(torch.linalg.norm(mat_v))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "v=mat_v.div(torch.linalg.norm(mat_v))", "y_neg": " v = mat_v.div(torch.norm(mat_v))", "retain": "def power_iteration(mat_g: torch.Tensor, num_iters: int = 100) -> torch.Tensor:\n r\"\"\"Compute the maximum eigenvalue of matrix, for scaling.\n\n Mostly, power_iteration method is faster than torch.einval in case of the symmetric PSD matrix.\n Also, I removed the validation, error of singular value every iteration, so that boosting the speed.\n\n :param mat_g: torch.Tensor. the symmetric PSD matrix.\n :param num_iters: int. Number of iterations.\n \"\"\"\n v = torch.randn(mat_g.shape[0], dtype=mat_g.dtype, device=mat_g.device)\n mat_v = torch.empty_like(v)\n\n for _ in range(num_iters):\n torch.mv(mat_g, v, out=mat_v)\n v = mat_v.div(torch.linalg.norm(mat_v))\n\n return (v.t() @ mat_g @ v).clamp_min_(1e-16)" }, { "id": 7806, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def unif_ball_sample(\n sigma: float,\n n_samples: int,\n n_walks: int,\n dim: int=3\n):\n \"\"\"\n source: https://en.wikipedia.org/wiki/N-sphere#Uniformly_at_random_within_the_n-ball\n \"\"\"\n radius = sigma / 2.\n points = torch.normal(mean=0, std=1, size=(n_samples, n_walks, dim))\n points /= torch.linalg.norm(points, dim=-1, ord=2).reshape(n_samples, n_walks, 1)\n points *= torch.pow(torch.rand(size=(n_samples, n_walks, 1)), 1 / dim) * radius\n\n return points", "probing input": "def unif_ball_sample(\n sigma: float,\n n_samples: int,\n n_walks: int,\n dim: int=3\n):\n \"\"\"\n source: https://en.wikipedia.org/wiki/N-sphere#Uniformly_at_random_within_the_n-ball\n \"\"\"\n radius = sigma / 2.\n points = torch.normal(mean=0, std=1, size=(n_samples, n_walks, dim))\n", "probing input new": "def unif_ball_sample(\n sigma: float,\n n_samples: int,\n n_walks: int,\n dim: int=3\n):\n \"\"\"\n source: https://en.wikipedia.org/wiki/N-sphere#Uniformly_at_random_within_the_n-ball\n \"\"\"\n radius = sigma / 2.\n points = torch.normal(mean=0, std=1, size=(n_samples, n_walks, dim))\n points /= torch.", "reference": "points/=torch.linalg.norm(points,dim=-1,ord=2).reshape(n_samples,n_walks,1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "points/=torch.linalg.norm(points,dim=-1,ord=2).reshape(n_samples,n_walks,1)", "y_neg": " points /= torch.norm(points, dim=-1, keepdim=True)", "retain": "def unif_ball_sample(\n sigma: float,\n n_samples: int,\n n_walks: int,\n dim: int=3\n):\n \"\"\"\n source: https://en.wikipedia.org/wiki/N-sphere#Uniformly_at_random_within_the_n-ball\n \"\"\"\n radius = sigma / 2.\n points = torch.normal(mean=0, std=1, size=(n_samples, n_walks, dim))\n points /= torch.linalg.norm(points, dim=-1, ord=2).reshape(n_samples, n_walks, 1)\n points *= torch.pow(torch.rand(size=(n_samples, n_walks, 1)), 1 / dim) * radius\n\n return points" }, { "id": 7807, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max(\n [torch.linalg.norm(_vec) for _vec in [a, b, c, a + b, b + c, a + c, a + b + c]])\n # This sphere should be within shape_min in each direction\n # Therefore shape_min >= Rmax * (R^-1 or G^-1)\n shape_min = (Rmax * (torch.linalg.inv(basis).norm(dim=0)))\n shape_min = torch.ceil(shape_min)\n iGridX = np.arange(-shape_min[0], shape_min[0] + 1)\n iGridY = np.arange(-shape_min[1], shape_min[1] + 1)\n iGridZ = np.arange(-shape_min[2], shape_min[2] + 1)\n # Reduce grid for any orthogonal basis vector\n if np.dot(a, b) == 0 == np.dot(a, c):\n iGridX = np.arange(-1., 2.)\n if np.dot(b, a) == 0 == np.dot(b, c):\n iGridY = np.arange(-1., 2.)\n if np.dot(c, a) == 0 == np.dot(c, b):\n iGridZ = np.arange(-1., 2.)\n iGrid = np.array([x.flatten() for x in np.meshgrid(iGridX, iGridY, iGridZ)]).T\n iGrid = iGrid[np.where((iGrid ** 2).sum(axis=1) > 0)[0]] # eliminate origin\n return torch.tensor(iGrid), torch.tensor(iGrid) @ basis.T", "probing input": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max(\n", "probing input new": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max(\n [torch.", "reference": "[torch.linalg.norm(_vec)for_vecin[a,b,c,a+b,b+c,a+c,a+b+c]])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "[torch.linalg.norm(_vec)for_vecin[a,b,c,a+b,b+c,a+c,a+b+c]])", "y_neg": " [torch.norm(a - b), torch.norm(a - c), torch.norm(b - c)])", "retain": "def get_grid(basis: torch.Tensor) -> tuple[torch.Tensor, ...]:\n \"\"\"Return grid containing linear combinations of basis vectors sufficient to cover Wigner-Seitz cell\"\"\"\n a, b, c = basis[:, 0], basis[:, 1], basis[:, 2]\n # Find maximum radius of sphere within parallelopiped from basis lattice vectors\n Rmax = np.max(\n [torch.linalg.norm(_vec) for _vec in [a, b, c, a + b, b + c, a + c, a + b + c]])\n # This sphere should be within shape_min in each direction\n # Therefore shape_min >= Rmax * (R^-1 or G^-1)\n shape_min = (Rmax * (torch.linalg.inv(basis).norm(dim=0)))\n shape_min = torch.ceil(shape_min)\n iGridX = np.arange(-shape_min[0], shape_min[0] + 1)\n iGridY = np.arange(-shape_min[1], shape_min[1] + 1)\n iGridZ = np.arange(-shape_min[2], shape_min[2] + 1)\n # Reduce grid for any orthogonal basis vector\n if np.dot(a, b) == 0 == np.dot(a, c):\n iGridX = np.arange(-1., 2.)\n if np.dot(b, a) == 0 == np.dot(b, c):\n iGridY = np.arange(-1., 2.)\n if np.dot(c, a) == 0 == np.dot(c, b):\n iGridZ = np.arange(-1., 2.)\n iGrid = np.array([x.flatten() for x in np.meshgrid(iGridX, iGridY, iGridZ)]).T\n iGrid = iGrid[np.where((iGrid ** 2).sum(axis=1) > 0)[0]] # eliminate origin\n return torch.tensor(iGrid), torch.tensor(iGrid) @ basis.T" }, { "id": 7810, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews, tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.linalg.norm(axes, dim=-1) # (B,)\n cos_values = (src_vectors * tgt_vectors).sum(dim=-1) # (B,)\n axes = F.normalize(axes, dim=-1, p=2) # (B, 3)\n skews = skew_symmetric_matrix(axes) # (B, 3, 3)\n eyes = torch.eye(3).cuda().unsqueeze(0).expand_as(skews) # (B, 3, 3)\n sin_values = sin_values.view(-1, 1, 1)\n cos_values = cos_values.view(-1, 1, 1)\n rotations = eyes + sin_values * skews + (1.0 - cos_values) * torch.matmul(skews, skews)\n\n # handle opposite direction\n sin_values = sin_values.view(-1)\n cos_values = cos_values.view(-1)\n masks = torch.logical_and(torch.eq(sin_values, 0.0), torch.lt(cos_values, 0.0))\n rotations[masks] *= -1\n\n output_shape = input_shape[:-1] + (3, 3)\n rotations = rotations.view(*output_shape)\n\n return rotations", "probing input": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews, tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n", "probing input new": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews, tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.", "reference": "sin_values=torch.linalg.norm(axes,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "sin_values=torch.linalg.norm(axes,dim=-1)", "y_neg": " sin_values = torch.norm(axes, dim=-1) # (B,)", "retain": "def rodrigues_alignment_matrix(src_vectors, tgt_vectors):\n r\"\"\"Compute the Rodrigues rotation matrix aligning source vectors to target vectors.\n\n Args:\n src_vectors (Tensor): source vectors (*, 3)\n tgt_vectors (Tensor): target vectors (*, 3)\n\n Returns:\n rotations (Tensor): rotation matrix (*, 3, 3)\n \"\"\"\n input_shape = src_vectors.shape\n src_vectors = src_vectors.view(-1, 3) # (B, 3)\n tgt_vectors = tgt_vectors.view(-1, 3) # (B, 3)\n\n # compute axes\n src_vectors = F.normalize(src_vectors, dim=-1, p=2) # (B, 3)\n tgt_vectors = F.normalize(tgt_vectors, dim=-1, p=2) # (B, 3)\n src_skews = skew_symmetric_matrix(src_vectors) # (B, 3, 3)\n axes = torch.matmul(src_skews, tgt_vectors.unsqueeze(-1)).squeeze(-1) # (B, 3)\n\n # compute rodrigues rotation matrix\n sin_values = torch.linalg.norm(axes, dim=-1) # (B,)\n cos_values = (src_vectors * tgt_vectors).sum(dim=-1) # (B,)\n axes = F.normalize(axes, dim=-1, p=2) # (B, 3)\n skews = skew_symmetric_matrix(axes) # (B, 3, 3)\n eyes = torch.eye(3).cuda().unsqueeze(0).expand_as(skews) # (B, 3, 3)\n sin_values = sin_values.view(-1, 1, 1)\n cos_values = cos_values.view(-1, 1, 1)\n rotations = eyes + sin_values * skews + (1.0 - cos_values) * torch.matmul(skews, skews)\n\n # handle opposite direction\n sin_values = sin_values.view(-1)\n cos_values = cos_values.view(-1)\n masks = torch.logical_and(torch.eq(sin_values, 0.0), torch.lt(cos_values, 0.0))\n rotations[masks] *= -1\n\n output_shape = input_shape[:-1] + (3, 3)\n rotations = rotations.view(*output_shape)\n\n return rotations" }, { "id": 7811, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def magdev(tensor):\n magnitudes = torch.linalg.norm(tensor, dim=-1)\n std_deviation = torch.std(magnitudes).item()\n result = f\"Standard deviation of magnitudes: {std_deviation}, which is {round(std_deviation/torch.mean(magnitudes, dim=-1).item(), 2)}x the mean\"\n print(result)\n return result", "probing input": "def magdev(tensor):\n", "probing input new": "def magdev(tensor):\n magnitudes = torch.", "reference": "magnitudes=torch.linalg.norm(tensor,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "magnitudes=torch.linalg.norm(tensor,dim=-1)", "y_neg": " magnitudes = torch.norm(tensor, p='fro', dim=-1, keepdim=True)", "retain": "def magdev(tensor):\n magnitudes = torch.linalg.norm(tensor, dim=-1)\n std_deviation = torch.std(magnitudes).item()\n result = f\"Standard deviation of magnitudes: {std_deviation}, which is {round(std_deviation/torch.mean(magnitudes, dim=-1).item(), 2)}x the mean\"\n print(result)\n return result" }, { "id": 7818, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.type(torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.type(torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats", "probing input": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.type(torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.type(torch.float32)\n\n if quats is not None and normalize_quats:\n", "probing input new": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.type(torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.type(torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.", "reference": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats=quats/torch.linalg.norm(quats,dim=-1,keepdim=True)", "y_neg": " quats = quats / torch.norm(quats, dim=-1, keepdim=True)", "retain": " def __init__(\n self,\n rot_mats: Optional[torch.Tensor] = None,\n quats: Optional[torch.Tensor] = None,\n normalize_quats: bool = True,\n ):\n \"\"\"\n Args:\n rot_mats:\n A [*, 3, 3] rotation matrix tensor. Mutually exclusive with\n quats\n quats:\n A [*, 4] quaternion. Mutually exclusive with rot_mats. If\n normalize_quats is not True, must be a unit quaternion\n normalize_quats:\n If quats is specified, whether to normalize quats\n \"\"\"\n if (rot_mats is None and quats is None) or (\n rot_mats is not None and quats is not None\n ):\n raise ValueError(\"Exactly one input argument must be specified\")\n\n if (rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (\n quats is not None and quats.shape[-1] != 4\n ):\n raise ValueError(\"Incorrectly shaped rotation matrix or quaternion\")\n\n # Force full-precision\n if quats is not None:\n quats = quats.type(torch.float32)\n if rot_mats is not None:\n rot_mats = rot_mats.type(torch.float32)\n\n if quats is not None and normalize_quats:\n quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)\n\n self._rot_mats = rot_mats\n self._quats = quats" }, { "id": 7819, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_rotvec(self, eps=1e-6) -> torch.Tensor:\n \"\"\"\n Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.linalg.norm(quat[..., 1:], dim=-1), quat[..., 0])\n\n angle2 = angle * angle\n small_angle_scales = 2 + angle2 / 12 + 7 * angle2 * angle2 / 2880\n large_angle_scales = angle / torch.sin(angle / 2 + eps)\n\n small_angles = (angle <= 1e-3).float()\n rot_vec_scale = (\n small_angle_scales * small_angles + (1 - small_angles) * large_angle_scales\n )\n rot_vec = rot_vec_scale[..., None] * quat[..., 1:]\n return rot_vec", "probing input": " def get_rotvec(self, eps=1e-6) -> torch.Tensor:\n \"\"\"\n Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n", "probing input new": " def get_rotvec(self, eps=1e-6) -> torch.Tensor:\n \"\"\"\n Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.", "reference": "angle=2*torch.atan2(torch.linalg.norm(quat[...,1:],dim=-1),quat[...,0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "angle=2*torch.atan2(torch.linalg.norm(quat[...,1:],dim=-1),quat[...,0])", "y_neg": " angle = 2 * torch.atan2(torch.norm(quat[..., 1:], dim=-1), quat[..., 0])", "retain": " def get_rotvec(self, eps=1e-6) -> torch.Tensor:\n \"\"\"\n Return the underlying axis-angle rotation vector.\n\n Follow's scipy's implementation:\n https://github.com/scipy/scipy/blob/HEAD/scipy/spatial/transform/_rotation.pyx#L1385-L1402\n\n Returns:\n The stored rotation as a axis-angle vector.\n \"\"\"\n quat = self.get_quats()\n # w > 0 to ensure 0 <= angle <= pi\n flip = (quat[..., :1] < 0).float()\n quat = (-1 * quat) * flip + (1 - flip) * quat\n\n angle = 2 * torch.atan2(torch.linalg.norm(quat[..., 1:], dim=-1), quat[..., 0])\n\n angle2 = angle * angle\n small_angle_scales = 2 + angle2 / 12 + 7 * angle2 * angle2 / 2880\n large_angle_scales = angle / torch.sin(angle / 2 + eps)\n\n small_angles = (angle <= 1e-3).float()\n rot_vec_scale = (\n small_angle_scales * small_angles + (1 - small_angles) * large_angle_scales\n )\n rot_vec = rot_vec_scale[..., None] * quat[..., 1:]\n return rot_vec" }, { "id": 7821, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_interval_grid_sampling_with_n():\n I = Interval(R1('x'), 0, 1)\n points = I.sample_grid(n=10)\n assert points.as_tensor.shape == (10, 1)\n assert all(I._contains(points))\n for i in range(8):\n dist_1 = torch.linalg.norm(points.as_tensor[i+1] - points.as_tensor[i])\n dist_2 = torch.linalg.norm(points.as_tensor[i+1] - points.as_tensor[i+2])\n assert torch.isclose(dist_1, dist_2)", "probing input": "def test_interval_grid_sampling_with_n():\n I = Interval(R1('x'), 0, 1)\n points = I.sample_grid(n=10)\n assert points.as_tensor.shape == (10, 1)\n assert all(I._contains(points))\n for i in range(8):\n", "probing input new": "def test_interval_grid_sampling_with_n():\n I = Interval(R1('x'), 0, 1)\n points = I.sample_grid(n=10)\n assert points.as_tensor.shape == (10, 1)\n assert all(I._contains(points))\n for i in range(8):\n dist_1 = torch.", "reference": "dist_1=torch.linalg.norm(points.as_tensor[i+1]-points.as_tensor[i])", "reference dict": { "I": "Interval" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dist_1=torch.linalg.norm(points.as_tensor[i+1]-points.as_tensor[i])", "y_neg": " dist_1 = torch.norm(points[i+1] - points[i])", "retain": "def test_interval_grid_sampling_with_n():\n I = Interval(R1('x'), 0, 1)\n points = I.sample_grid(n=10)\n assert points.as_tensor.shape == (10, 1)\n assert all(I._contains(points))\n for i in range(8):\n dist_1 = torch.linalg.norm(points.as_tensor[i+1] - points.as_tensor[i])\n dist_2 = torch.linalg.norm(points.as_tensor[i+1] - points.as_tensor[i+2])\n assert torch.isclose(dist_1, dist_2)" }, { "id": 7822, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def norm(array: torch.tensor, *args, **kwargs) -> float:\n return torch.linalg.norm(array, *args, **kwargs)", "probing input": " def norm(array: torch.tensor, *args, **kwargs) -> float:\n", "probing input new": " def norm(array: torch.tensor, *args, **kwargs) -> float:\n return torch.", "reference": "returntorch.linalg.norm(array,*args,**kwargs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(array,*args,**kwargs)", "y_neg": " return torch.norm(array, *args, **kwargs)", "retain": " def norm(array: torch.tensor, *args, **kwargs) -> float:\n return torch.linalg.norm(array, *args, **kwargs)" }, { "id": 7827, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def quanterion_between_two_vectors(vector_a: torch.Tensor, vector_b: torch.Tensor):\n \"\"\"\n Quaternion between two vectors\n\n Args:\n vector_a: N x 3\n vector_b: N x 3\n Returns:\n torch.Tensor: N x 3 x 3\n \"\"\"\n vector_a_norm = vector_a / torch.linalg.norm(vector_a, dim=1)\n vector_b_norm = vector_b / torch.linalg.norm(vector_b, dim=1)\n half = vector_a_norm + vector_b_norm\n half = half / torch.linalg.norm(half, dim=1)\n w = torch.sum(vector_a_norm * half, dim=1)\n xyz = torch.cross(vector_a_norm, half, dim=1)\n quaternion = torch.cat([w.unsqueeze(-1), xyz], dim=-1)\n return quaternion", "probing input": "def quanterion_between_two_vectors(vector_a: torch.Tensor, vector_b: torch.Tensor):\n \"\"\"\n Quaternion between two vectors\n\n Args:\n vector_a: N x 3\n vector_b: N x 3\n Returns:\n torch.Tensor: N x 3 x 3\n \"\"\"\n", "probing input new": "def quanterion_between_two_vectors(vector_a: torch.Tensor, vector_b: torch.Tensor):\n \"\"\"\n Quaternion between two vectors\n\n Args:\n vector_a: N x 3\n vector_b: N x 3\n Returns:\n torch.Tensor: N x 3 x 3\n \"\"\"\n vector_a_", "reference": "vector_a_norm=vector_a/torch.linalg.norm(vector_a,dim=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "vector_a_norm=vector_a/torch.linalg.norm(vector_a,dim=1)", "y_neg": " vector_a_norm = torch.norm(vector_a, p=2, dim=1, keepdim=True)", "retain": "def quanterion_between_two_vectors(vector_a: torch.Tensor, vector_b: torch.Tensor):\n \"\"\"\n Quaternion between two vectors\n\n Args:\n vector_a: N x 3\n vector_b: N x 3\n Returns:\n torch.Tensor: N x 3 x 3\n \"\"\"\n vector_a_norm = vector_a / torch.linalg.norm(vector_a, dim=1)\n vector_b_norm = vector_b / torch.linalg.norm(vector_b, dim=1)\n half = vector_a_norm + vector_b_norm\n half = half / torch.linalg.norm(half, dim=1)\n w = torch.sum(vector_a_norm * half, dim=1)\n xyz = torch.cross(vector_a_norm, half, dim=1)\n quaternion = torch.cat([w.unsqueeze(-1), xyz], dim=-1)\n return quaternion" }, { "id": 7829, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eval_springs(x, v, indices, rest, ke, kd, f):\n i = indices[:, 0]\n j = indices[:, 1]\n\n xi = x[i]\n xj = x[j]\n\n vi = v[i]\n vj = v[j]\n\n xij = xi - xj\n vij = vi - vj\n\n l = torch.linalg.norm(xij, axis=1)\n l_inv = 1.0 / l\n\n # normalized spring direction\n dir = (xij.T * l_inv).T\n\n c = l - rest\n dcdt = torch.sum(dir * vij, axis=1)\n\n # damping based on relative velocity.\n fs = dir.T * (ke * c + kd * dcdt)\n\n f.index_add_(dim=0, index=i, source=-fs.T)\n f.index_add_(dim=0, index=j, source=fs.T)", "probing input": "def eval_springs(x, v, indices, rest, ke, kd, f):\n i = indices[:, 0]\n j = indices[:, 1]\n\n xi = x[i]\n xj = x[j]\n\n vi = v[i]\n vj = v[j]\n\n xij = xi - xj\n vij = vi - vj\n\n", "probing input new": "def eval_springs(x, v, indices, rest, ke, kd, f):\n i = indices[:, 0]\n j = indices[:, 1]\n\n xi = x[i]\n xj = x[j]\n\n vi = v[i]\n vj = v[j]\n\n xij = xi - xj\n vij = vi - vj\n\n l = torch.", "reference": "l=torch.linalg.norm(xij,axis=1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "l=torch.linalg.norm(xij,axis=1)", "y_neg": " l = torch.norm(xij, p=2, dim=1)", "retain": "def eval_springs(x, v, indices, rest, ke, kd, f):\n i = indices[:, 0]\n j = indices[:, 1]\n\n xi = x[i]\n xj = x[j]\n\n vi = v[i]\n vj = v[j]\n\n xij = xi - xj\n vij = vi - vj\n\n l = torch.linalg.norm(xij, axis=1)\n l_inv = 1.0 / l\n\n # normalized spring direction\n dir = (xij.T * l_inv).T\n\n c = l - rest\n dcdt = torch.sum(dir * vij, axis=1)\n\n # damping based on relative velocity.\n fs = dir.T * (ke * c + kd * dcdt)\n\n f.index_add_(dim=0, index=i, source=-fs.T)\n f.index_add_(dim=0, index=j, source=fs.T)" }, { "id": 7832, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def add_edge_features(self):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n for i in range(len(self.graphs)):\n pos = self.graphs[i].ndata[\"pos\"]\n row, col = self.graphs[i].edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n self.graphs[i].edata[\"x\"] = torch.cat((disp, disp_norm), dim=-1)\n\n return self.graphs", "probing input": " def add_edge_features(self):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n for i in range(len(self.graphs)):\n pos = self.graphs[i].ndata[\"pos\"]\n row, col = self.graphs[i].edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n", "probing input new": " def add_edge_features(self):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n for i in range(len(self.graphs)):\n pos = self.graphs[i].ndata[\"pos\"]\n row, col = self.graphs[i].edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_", "reference": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "disp_norm=torch.linalg.norm(disp,dim=-1,keepdim=True)", "y_neg": " disp_norm = torch.norm(disp, p=2, dim=-1)", "retain": " def add_edge_features(self):\n \"\"\"\n adds relative displacement & displacement norm as edge features\n \"\"\"\n for i in range(len(self.graphs)):\n pos = self.graphs[i].ndata[\"pos\"]\n row, col = self.graphs[i].edges()\n disp = torch.tensor(pos[row.long()] - pos[col.long()])\n disp_norm = torch.linalg.norm(disp, dim=-1, keepdim=True)\n self.graphs[i].edata[\"x\"] = torch.cat((disp, disp_norm), dim=-1)\n\n return self.graphs" }, { "id": 7833, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def optimize_C(self,A,B,lr,iters,orthog,verbose):\n #parameterize mapping to be orthogonal\n n = A.shape[0]\n sim_net = LearnableSimilarityTransform(n,orthog=orthog).to(self.device)\n if orthog:\n parametrize.register_parametrization(sim_net, \"C\", Skew(n,self.device))\n parametrize.register_parametrization(sim_net, \"C\", CayleyMap(n,self.device))\n else:\n parametrize.register_parametrization(sim_net, \"C\", Matrix(n,self.device))\n \n simdist_loss = nn.MSELoss(reduction = 'sum')\n\n optimizer = optim.Adam(sim_net.parameters(), lr=lr)\n # scheduler = optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.999)\n\n losses = []\n A /= torch.linalg.norm(A)\n B /= torch.linalg.norm(B)\n for _ in range(iters):\n # Zero the gradients of the optimizer.\n optimizer.zero_grad() \n # Compute the Frobenius norm between A and the product.\n loss = simdist_loss(A, sim_net(B))\n\n loss.backward()\n\n optimizer.step()\n # if _ % 99:\n # scheduler.step()\n losses.append(loss.item())\n\n if verbose:\n print(\"Finished optimizing C\")\n\n C_star = sim_net.C.detach()\n return losses, C_star,sim_net", "probing input": " def optimize_C(self,A,B,lr,iters,orthog,verbose):\n #parameterize mapping to be orthogonal\n n = A.shape[0]\n sim_net = LearnableSimilarityTransform(n,orthog=orthog).to(self.device)\n if orthog:\n parametrize.register_parametrization(sim_net, \"C\", Skew(n,self.device))\n parametrize.register_parametrization(sim_net, \"C\", CayleyMap(n,self.device))\n else:\n parametrize.register_parametrization(sim_net, \"C\", Matrix(n,self.device))\n \n simdist_loss = nn.MSELoss(reduction = 'sum')\n\n optimizer = optim.Adam(sim_net.parameters(), lr=lr)\n # scheduler = optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.999)\n\n losses = []\n", "probing input new": " def optimize_C(self,A,B,lr,iters,orthog,verbose):\n #parameterize mapping to be orthogonal\n n = A.shape[0]\n sim_net = LearnableSimilarityTransform(n,orthog=orthog).to(self.device)\n if orthog:\n parametrize.register_parametrization(sim_net, \"C\", Skew(n,self.device))\n parametrize.register_parametrization(sim_net, \"C\", CayleyMap(n,self.device))\n else:\n parametrize.register_parametrization(sim_net, \"C\", Matrix(n,self.device))\n \n simdist_loss = nn.MSELoss(reduction = 'sum')\n\n optimizer = optim.Adam(sim_net.parameters(), lr=lr)\n # scheduler = optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.999)\n\n losses = []\n A /= torch.", "reference": "A/=torch.linalg.norm(A)", "reference dict": { "simdist_loss": "nn.MSELoss", "optimizer": "optim.Adam" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "A/=torch.linalg.norm(A)", "y_neg": " A /= torch.norm(A, dim=1, keepdim=True)", "retain": " def optimize_C(self,A,B,lr,iters,orthog,verbose):\n #parameterize mapping to be orthogonal\n n = A.shape[0]\n sim_net = LearnableSimilarityTransform(n,orthog=orthog).to(self.device)\n if orthog:\n parametrize.register_parametrization(sim_net, \"C\", Skew(n,self.device))\n parametrize.register_parametrization(sim_net, \"C\", CayleyMap(n,self.device))\n else:\n parametrize.register_parametrization(sim_net, \"C\", Matrix(n,self.device))\n \n simdist_loss = nn.MSELoss(reduction = 'sum')\n\n optimizer = optim.Adam(sim_net.parameters(), lr=lr)\n # scheduler = optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.999)\n\n losses = []\n A /= torch.linalg.norm(A)\n B /= torch.linalg.norm(B)\n for _ in range(iters):\n # Zero the gradients of the optimizer.\n optimizer.zero_grad() \n # Compute the Frobenius norm between A and the product.\n loss = simdist_loss(A, sim_net(B))\n\n loss.backward()\n\n optimizer.step()\n # if _ % 99:\n # scheduler.step()\n losses.append(loss.item())\n\n if verbose:\n print(\"Finished optimizing C\")\n\n C_star = sim_net.C.detach()\n return losses, C_star,sim_net" }, { "id": 7834, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def apply(cls, hparams, loss_dict, metric_dict, batch, out, compute_metric):\n gt_surface_config = hparams.supervision.gt_surface\n field = out['field']\n\n if gt_surface_config.value > 0.0 or gt_surface_config.normal > 0.0:\n\n if DS.GT_GEOMETRY not in batch.keys():\n ref_xyz, ref_normal = batch[DS.GT_DENSE_PC][0], batch[DS.GT_DENSE_NORMAL][0]\n else:\n ref_geometry = batch[DS.GT_GEOMETRY][0]\n ref_xyz, ref_normal, _ = ref_geometry.torch_attr()\n\n n_subsample = gt_surface_config.subsample\n if 0 < n_subsample < ref_xyz.size(0):\n ref_xyz_inds = (torch.rand((n_subsample,), device=ref_xyz.device) *\n ref_xyz.size(0)).long()\n else:\n ref_xyz_inds = torch.arange(ref_xyz.size(0), device=ref_xyz.device)\n\n compute_grad = gt_surface_config.normal > 0.0\n eval_res = field.evaluate_f(ref_xyz[ref_xyz_inds], grad=compute_grad)\n\n if compute_grad:\n pd_grad = eval_res.gradient\n pd_grad = -pd_grad / (torch.linalg.norm(pd_grad, dim=-1, keepdim=True) + 1.0e-6)\n loss_dict.add_loss('gt-surface-normal',\n 1.0 - torch.sum(pd_grad * ref_normal[ref_xyz_inds], dim=-1).mean(),\n gt_surface_config.normal)\n\n loss_dict.add_loss('gt-surface-value', torch.abs(eval_res.value).mean(), gt_surface_config.value)", "probing input": " def apply(cls, hparams, loss_dict, metric_dict, batch, out, compute_metric):\n gt_surface_config = hparams.supervision.gt_surface\n field = out['field']\n\n if gt_surface_config.value > 0.0 or gt_surface_config.normal > 0.0:\n\n if DS.GT_GEOMETRY not in batch.keys():\n ref_xyz, ref_normal = batch[DS.GT_DENSE_PC][0], batch[DS.GT_DENSE_NORMAL][0]\n else:\n ref_geometry = batch[DS.GT_GEOMETRY][0]\n ref_xyz, ref_normal, _ = ref_geometry.torch_attr()\n\n n_subsample = gt_surface_config.subsample\n if 0 < n_subsample < ref_xyz.size(0):\n ref_xyz_inds = (torch.rand((n_subsample,), device=ref_xyz.device) *\n ref_xyz.size(0)).long()\n else:\n ref_xyz_inds = torch.arange(ref_xyz.size(0), device=ref_xyz.device)\n\n compute_grad = gt_surface_config.normal > 0.0\n eval_res = field.evaluate_f(ref_xyz[ref_xyz_inds], grad=compute_grad)\n\n if compute_grad:\n pd_grad = eval_res.gradient\n", "probing input new": " def apply(cls, hparams, loss_dict, metric_dict, batch, out, compute_metric):\n gt_surface_config = hparams.supervision.gt_surface\n field = out['field']\n\n if gt_surface_config.value > 0.0 or gt_surface_config.normal > 0.0:\n\n if DS.GT_GEOMETRY not in batch.keys():\n ref_xyz, ref_normal = batch[DS.GT_DENSE_PC][0], batch[DS.GT_DENSE_NORMAL][0]\n else:\n ref_geometry = batch[DS.GT_GEOMETRY][0]\n ref_xyz, ref_normal, _ = ref_geometry.torch_attr()\n\n n_subsample = gt_surface_config.subsample\n if 0 < n_subsample < ref_xyz.size(0):\n ref_xyz_inds = (torch.rand((n_subsample,), device=ref_xyz.device) *\n ref_xyz.size(0)).long()\n else:\n ref_xyz_inds = torch.arange(ref_xyz.size(0), device=ref_xyz.device)\n\n compute_grad = gt_surface_config.normal > 0.0\n eval_res = field.evaluate_f(ref_xyz[ref_xyz_inds], grad=compute_grad)\n\n if compute_grad:\n pd_grad = eval_res.gradient\n pd_grad = -pd_grad / (torch.", "reference": "pd_grad=-pd_grad/(torch.linalg.norm(pd_grad,dim=-1,keepdim=True)+1.0e-6)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "pd_grad=-pd_grad/(torch.linalg.norm(pd_grad,dim=-1,keepdim=True)+1.0e-6)", "y_neg": " pd_grad = -pd_grad / (torch.norm(pd_grad, dim=-1, keepdim=True) + 1e-10)", "retain": " def apply(cls, hparams, loss_dict, metric_dict, batch, out, compute_metric):\n gt_surface_config = hparams.supervision.gt_surface\n field = out['field']\n\n if gt_surface_config.value > 0.0 or gt_surface_config.normal > 0.0:\n\n if DS.GT_GEOMETRY not in batch.keys():\n ref_xyz, ref_normal = batch[DS.GT_DENSE_PC][0], batch[DS.GT_DENSE_NORMAL][0]\n else:\n ref_geometry = batch[DS.GT_GEOMETRY][0]\n ref_xyz, ref_normal, _ = ref_geometry.torch_attr()\n\n n_subsample = gt_surface_config.subsample\n if 0 < n_subsample < ref_xyz.size(0):\n ref_xyz_inds = (torch.rand((n_subsample,), device=ref_xyz.device) *\n ref_xyz.size(0)).long()\n else:\n ref_xyz_inds = torch.arange(ref_xyz.size(0), device=ref_xyz.device)\n\n compute_grad = gt_surface_config.normal > 0.0\n eval_res = field.evaluate_f(ref_xyz[ref_xyz_inds], grad=compute_grad)\n\n if compute_grad:\n pd_grad = eval_res.gradient\n pd_grad = -pd_grad / (torch.linalg.norm(pd_grad, dim=-1, keepdim=True) + 1.0e-6)\n loss_dict.add_loss('gt-surface-normal',\n 1.0 - torch.sum(pd_grad * ref_normal[ref_xyz_inds], dim=-1).mean(),\n gt_surface_config.normal)\n\n loss_dict.add_loss('gt-surface-value', torch.abs(eval_res.value).mean(), gt_surface_config.value)" }, { "id": 7837, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def min_sphere_radius(rays, origin):\n rays_o, rays_d = rays[..., :3] - origin, rays[..., 3:6]\n rays_d = torch.nn.functional.normalize(rays_d, p=2.0, dim=-1)\n\n m = torch.cross(rays_o, rays_d, dim=-1)\n rays_o = torch.cross(rays_d, m, dim=-1)\n return torch.linalg.norm(rays_o, dim=-1)", "probing input": "def min_sphere_radius(rays, origin):\n rays_o, rays_d = rays[..., :3] - origin, rays[..., 3:6]\n rays_d = torch.nn.functional.normalize(rays_d, p=2.0, dim=-1)\n\n m = torch.cross(rays_o, rays_d, dim=-1)\n rays_o = torch.cross(rays_d, m, dim=-1)\n", "probing input new": "def min_sphere_radius(rays, origin):\n rays_o, rays_d = rays[..., :3] - origin, rays[..., 3:6]\n rays_d = torch.nn.functional.normalize(rays_d, p=2.0, dim=-1)\n\n m = torch.cross(rays_o, rays_d, dim=-1)\n rays_o = torch.cross(rays_d, m, dim=-1)\n return torch.", "reference": "returntorch.linalg.norm(rays_o,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(rays_o,dim=-1)", "y_neg": " return torch.norm(rays_o, p=2.0, dim=-1)", "retain": "def min_sphere_radius(rays, origin):\n rays_o, rays_d = rays[..., :3] - origin, rays[..., 3:6]\n rays_d = torch.nn.functional.normalize(rays_d, p=2.0, dim=-1)\n\n m = torch.cross(rays_o, rays_d, dim=-1)\n rays_o = torch.cross(rays_d, m, dim=-1)\n return torch.linalg.norm(rays_o, dim=-1)" }, { "id": 7842, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_quat_to_yaw(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to yaw.\n\n Args:\n quats_wxyz: (N,4) Scalar first quaternions.\n\n NOTE: Yaw is rotation about the vertical axis in our\n coordinate system.\n \"\"\"\n quats_wxyz /= torch.linalg.norm(quats_wxyz, dim=-1, keepdim=True)\n yaw = quat_to_yaw(quats_wxyz).rad2deg()\n yaw_ = torch.as_tensor(\n R.from_quat(quats_wxyz[..., [1, 2, 3, 0]].numpy()).as_euler(\n \"xyz\", degrees=True\n )\n )[..., -1]\n torch.testing.assert_allclose(yaw, yaw_)", "probing input": "def test_quat_to_yaw(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to yaw.\n\n Args:\n quats_wxyz: (N,4) Scalar first quaternions.\n\n NOTE: Yaw is rotation about the vertical axis in our\n coordinate system.\n \"\"\"\n", "probing input new": "def test_quat_to_yaw(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to yaw.\n\n Args:\n quats_wxyz: (N,4) Scalar first quaternions.\n\n NOTE: Yaw is rotation about the vertical axis in our\n coordinate system.\n \"\"\"\n quats_wxyz /= torch.", "reference": "quats_wxyz/=torch.linalg.norm(quats_wxyz,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats_wxyz/=torch.linalg.norm(quats_wxyz,dim=-1,keepdim=True)", "y_neg": " quats_wxyz /= torch.norm(quats_wxyz, dim=1, keepdim=True)", "retain": "def test_quat_to_yaw(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to yaw.\n\n Args:\n quats_wxyz: (N,4) Scalar first quaternions.\n\n NOTE: Yaw is rotation about the vertical axis in our\n coordinate system.\n \"\"\"\n quats_wxyz /= torch.linalg.norm(quats_wxyz, dim=-1, keepdim=True)\n yaw = quat_to_yaw(quats_wxyz).rad2deg()\n yaw_ = torch.as_tensor(\n R.from_quat(quats_wxyz[..., [1, 2, 3, 0]].numpy()).as_euler(\n \"xyz\", degrees=True\n )\n )[..., -1]\n torch.testing.assert_allclose(yaw, yaw_)" }, { "id": 7843, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_quat_to_xyz(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to Tait-Bryan angles (roll, pitch, yaw).\"\"\"\n quats_wxyz /= torch.linalg.norm(quats_wxyz, dim=-1, keepdim=True)\n xyz = quat_to_xyz(quats_wxyz).rad2deg()\n xyz_ = torch.as_tensor(\n R.from_quat(quats_wxyz[..., [1, 2, 3, 0]].numpy()).as_euler(\n \"xyz\", degrees=True\n )\n )\n torch.testing.assert_allclose(xyz, xyz_)", "probing input": "def test_quat_to_xyz(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to Tait-Bryan angles (roll, pitch, yaw).\"\"\"\n", "probing input new": "def test_quat_to_xyz(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to Tait-Bryan angles (roll, pitch, yaw).\"\"\"\n quats_wxyz /= torch.", "reference": "quats_wxyz/=torch.linalg.norm(quats_wxyz,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "quats_wxyz/=torch.linalg.norm(quats_wxyz,dim=-1,keepdim=True)", "y_neg": " quats_wxyz /= torch.norm(quats_wxyz, dim=-1, keepdim=True)", "retain": "def test_quat_to_xyz(quats_wxyz: Tensor) -> None:\n \"\"\"Test converting a quaternion to Tait-Bryan angles (roll, pitch, yaw).\"\"\"\n quats_wxyz /= torch.linalg.norm(quats_wxyz, dim=-1, keepdim=True)\n xyz = quat_to_xyz(quats_wxyz).rad2deg()\n xyz_ = torch.as_tensor(\n R.from_quat(quats_wxyz[..., [1, 2, 3, 0]].numpy()).as_euler(\n \"xyz\", degrees=True\n )\n )\n torch.testing.assert_allclose(xyz, xyz_)" }, { "id": 7844, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def norm(x: _Numeric, ord: Optional[Any] = None, axis: Optional[int] = None): # type: ignore\n \"\"\"\n Matrix or vector norm.\n \"\"\"\n return torch.linalg.norm(x, ord=ord, dim=axis)", "probing input": "def norm(x: _Numeric, ord: Optional[Any] = None, axis: Optional[int] = None): # type: ignore\n \"\"\"\n Matrix or vector norm.\n \"\"\"\n", "probing input new": "def norm(x: _Numeric, ord: Optional[Any] = None, axis: Optional[int] = None): # type: ignore\n \"\"\"\n Matrix or vector norm.\n \"\"\"\n return torch.", "reference": "returntorch.linalg.norm(x,ord=ord,dim=axis)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(x,ord=ord,dim=axis)", "y_neg": " return torch.norm(x, ord=ord, dim=axis)", "retain": "def norm(x: _Numeric, ord: Optional[Any] = None, axis: Optional[int] = None): # type: ignore\n \"\"\"\n Matrix or vector norm.\n \"\"\"\n return torch.linalg.norm(x, ord=ord, dim=axis)" }, { "id": 7845, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def rgbd2pcd(im, depth, w2c, k, show_depth=False, project_to_cam_w_scale=None):\n d_near = 1.5\n d_far = 6\n invk = torch.inverse(torch.tensor(k).cuda().float())\n c2w = torch.inverse(torch.tensor(w2c).cuda().float())\n radial_depth = depth[0].reshape(-1)\n def_rays = (invk @ def_pix.T).T\n def_radial_rays = def_rays / torch.linalg.norm(def_rays, ord=2, dim=-1)[:, None]\n pts_cam = def_radial_rays * radial_depth[:, None]\n z_depth = pts_cam[:, 2]\n if project_to_cam_w_scale is not None:\n pts_cam = project_to_cam_w_scale * pts_cam / z_depth[:, None]\n pts4 = torch.concat((pts_cam, pix_ones), 1)\n pts = (c2w @ pts4.T).T[:, :3]\n if show_depth:\n cols = ((z_depth - d_near) / (d_far - d_near))[:, None].repeat(1, 3)\n else:\n cols = torch.permute(im, (1, 2, 0)).reshape(-1, 3)\n pts = o3d.utility.Vector3dVector(pts.contiguous().double().cpu().numpy())\n cols = o3d.utility.Vector3dVector(cols.contiguous().double().cpu().numpy())\n return pts, cols", "probing input": "def rgbd2pcd(im, depth, w2c, k, show_depth=False, project_to_cam_w_scale=None):\n d_near = 1.5\n d_far = 6\n invk = torch.inverse(torch.tensor(k).cuda().float())\n c2w = torch.inverse(torch.tensor(w2c).cuda().float())\n radial_depth = depth[0].reshape(-1)\n def_rays = (invk @ def_pix.T).T\n", "probing input new": "def rgbd2pcd(im, depth, w2c, k, show_depth=False, project_to_cam_w_scale=None):\n d_near = 1.5\n d_far = 6\n invk = torch.inverse(torch.tensor(k).cuda().float())\n c2w = torch.inverse(torch.tensor(w2c).cuda().float())\n radial_depth = depth[0].reshape(-1)\n def_rays = (invk @ def_pix.T).T\n def_radial_rays = def_rays / torch.", "reference": "def_radial_rays=def_rays/torch.linalg.norm(def_rays,ord=2,dim=-1)[:,None]", "reference dict": { "pts": "o3d.utility.Vector3dVector", "cols": "o3d.utility.Vector3dVector" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "def_radial_rays=def_rays/torch.linalg.norm(def_rays,ord=2,dim=-1)[:,None]", "y_neg": " def_radial_rays = def_rays / torch.norm(def_rays, dim=-1, keepdim=True)", "retain": "def rgbd2pcd(im, depth, w2c, k, show_depth=False, project_to_cam_w_scale=None):\n d_near = 1.5\n d_far = 6\n invk = torch.inverse(torch.tensor(k).cuda().float())\n c2w = torch.inverse(torch.tensor(w2c).cuda().float())\n radial_depth = depth[0].reshape(-1)\n def_rays = (invk @ def_pix.T).T\n def_radial_rays = def_rays / torch.linalg.norm(def_rays, ord=2, dim=-1)[:, None]\n pts_cam = def_radial_rays * radial_depth[:, None]\n z_depth = pts_cam[:, 2]\n if project_to_cam_w_scale is not None:\n pts_cam = project_to_cam_w_scale * pts_cam / z_depth[:, None]\n pts4 = torch.concat((pts_cam, pix_ones), 1)\n pts = (c2w @ pts4.T).T[:, :3]\n if show_depth:\n cols = ((z_depth - d_near) / (d_far - d_near))[:, None].repeat(1, 3)\n else:\n cols = torch.permute(im, (1, 2, 0)).reshape(-1, 3)\n pts = o3d.utility.Vector3dVector(pts.contiguous().double().cpu().numpy())\n cols = o3d.utility.Vector3dVector(cols.contiguous().double().cpu().numpy())\n return pts, cols" }, { "id": 7849, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_newton_root_inverse(\n self,\n A: Tensor,\n root: int,\n epsilon: float,\n max_iterations: int,\n A_tol: float,\n M_tol: float,\n ) -> None:\n X, M, flag, iteration, M_error = _matrix_inverse_root_newton(\n A, root, epsilon, max_iterations, M_tol\n )\n abs_A_error = torch.dist(torch.linalg.matrix_power(X, -root), A, p=torch.inf)\n A_norm = torch.linalg.norm(A, ord=torch.inf)\n rel_A_error = abs_A_error / torch.maximum(torch.tensor(1.0), A_norm)\n self.assertTrue(M_error <= M_tol)\n self.assertTrue(rel_A_error <= A_tol)", "probing input": " def _test_newton_root_inverse(\n self,\n A: Tensor,\n root: int,\n epsilon: float,\n max_iterations: int,\n A_tol: float,\n M_tol: float,\n ) -> None:\n X, M, flag, iteration, M_error = _matrix_inverse_root_newton(\n A, root, epsilon, max_iterations, M_tol\n )\n abs_A_error = torch.dist(torch.linalg.matrix_power(X, -root), A, p=torch.inf)\n", "probing input new": " def _test_newton_root_inverse(\n self,\n A: Tensor,\n root: int,\n epsilon: float,\n max_iterations: int,\n A_tol: float,\n M_tol: float,\n ) -> None:\n X, M, flag, iteration, M_error = _matrix_inverse_root_newton(\n A, root, epsilon, max_iterations, M_tol\n )\n abs_A_error = torch.dist(torch.linalg.matrix_power(X, -root), A, p=torch.inf)\n A_", "reference": "A_norm=torch.linalg.norm(A,ord=torch.inf)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "A_norm=torch.linalg.norm(A,ord=torch.inf)", "y_neg": " A_error = torch.norm(abs_A_error, p=1)", "retain": " def _test_newton_root_inverse(\n self,\n A: Tensor,\n root: int,\n epsilon: float,\n max_iterations: int,\n A_tol: float,\n M_tol: float,\n ) -> None:\n X, M, flag, iteration, M_error = _matrix_inverse_root_newton(\n A, root, epsilon, max_iterations, M_tol\n )\n abs_A_error = torch.dist(torch.linalg.matrix_power(X, -root), A, p=torch.inf)\n A_norm = torch.linalg.norm(A, ord=torch.inf)\n rel_A_error = abs_A_error / torch.maximum(torch.tensor(1.0), A_norm)\n self.assertTrue(M_error <= M_tol)\n self.assertTrue(rel_A_error <= A_tol)" }, { "id": 7852, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _compute_dq(\n step_size,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n) -> tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Compute the delta in internal coordinates to take.\"\"\"\n grad_q_len = len(grad_q)\n\n if isinstance(ic, tico.ic.DLC) and ic.constr is not None:\n grad_q, hess_q = ic.augment_hess_q(coords_x, grad_q, hess_q)\n\n hess_q = hess_q + step_size * torch.eye(len(hess_q))\n\n for i in range(grad_q_len, len(grad_q)):\n # don't shift the constrained degrees of freedom\n hess_q[i, i] = 0.0\n\n hess_q_inv = tico.utils.pinv(hess_q, 1e-12)\n\n dq_with_const = -hess_q_inv @ grad_q\n dq = dq_with_const[:grad_q_len]\n\n d_prime = -hess_q_inv @ dq_with_const\n dq_prime = dq @ d_prime[:grad_q_len] / torch.linalg.norm(dq)\n\n return dq, dq_prime", "probing input": "def _compute_dq(\n step_size,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n) -> tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Compute the delta in internal coordinates to take.\"\"\"\n grad_q_len = len(grad_q)\n\n if isinstance(ic, tico.ic.DLC) and ic.constr is not None:\n grad_q, hess_q = ic.augment_hess_q(coords_x, grad_q, hess_q)\n\n hess_q = hess_q + step_size * torch.eye(len(hess_q))\n\n for i in range(grad_q_len, len(grad_q)):\n # don't shift the constrained degrees of freedom\n hess_q[i, i] = 0.0\n\n hess_q_inv = tico.utils.pinv(hess_q, 1e-12)\n\n dq_with_const = -hess_q_inv @ grad_q\n dq = dq_with_const[:grad_q_len]\n\n d_prime = -hess_q_inv @ dq_with_const\n", "probing input new": "def _compute_dq(\n step_size,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n) -> tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Compute the delta in internal coordinates to take.\"\"\"\n grad_q_len = len(grad_q)\n\n if isinstance(ic, tico.ic.DLC) and ic.constr is not None:\n grad_q, hess_q = ic.augment_hess_q(coords_x, grad_q, hess_q)\n\n hess_q = hess_q + step_size * torch.eye(len(hess_q))\n\n for i in range(grad_q_len, len(grad_q)):\n # don't shift the constrained degrees of freedom\n hess_q[i, i] = 0.0\n\n hess_q_inv = tico.utils.pinv(hess_q, 1e-12)\n\n dq_with_const = -hess_q_inv @ grad_q\n dq = dq_with_const[:grad_q_len]\n\n d_prime = -hess_q_inv @ dq_with_const\n dq_prime = dq @ d_prime[:grad_q_len] / torch.", "reference": "dq_prime=dq@d_prime[:grad_q_len]/torch.linalg.norm(dq)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dq_prime=dq@d_prime[:grad_q_len]/torch.linalg.norm(dq)", "y_neg": " dq_prime = dq @ d_prime[:grad_q_len] / torch.norm(d_prime)**2", "retain": "def _compute_dq(\n step_size,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n) -> tuple[torch.Tensor, torch.Tensor]:\n \"\"\"Compute the delta in internal coordinates to take.\"\"\"\n grad_q_len = len(grad_q)\n\n if isinstance(ic, tico.ic.DLC) and ic.constr is not None:\n grad_q, hess_q = ic.augment_hess_q(coords_x, grad_q, hess_q)\n\n hess_q = hess_q + step_size * torch.eye(len(hess_q))\n\n for i in range(grad_q_len, len(grad_q)):\n # don't shift the constrained degrees of freedom\n hess_q[i, i] = 0.0\n\n hess_q_inv = tico.utils.pinv(hess_q, 1e-12)\n\n dq_with_const = -hess_q_inv @ grad_q\n dq = dq_with_const[:grad_q_len]\n\n d_prime = -hess_q_inv @ dq_with_const\n dq_prime = dq @ d_prime[:grad_q_len] / torch.linalg.norm(dq)\n\n return dq, dq_prime" }, { "id": 7853, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _find_dq(\n target_norm: float,\n step_size: float,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n rtol: float = 0.001,\n) -> torch.Tensor:\n \"\"\"\n\n Notes:\n Based on geomeTRIC, which is based on the iterative formula from Hebden (1973),\n equation 5.2.10 in \"Practical methods of optimization\" by Fletcher\n\n Returns:\n The found value of dq.\n \"\"\"\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n dq_norm = torch.linalg.norm(dq)\n\n if dq_norm < target_norm:\n return dq\n\n dq_norm_last, dq_norm_best, dq_best = 0.0, dq_norm, dq.clone()\n\n iteration = 0\n\n while True:\n step_size += (1 - dq_norm / target_norm) * (dq_norm / dq_prime)\n\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n dq_norm = torch.linalg.norm(dq)\n\n if torch.abs((dq_norm - target_norm) / target_norm) < rtol:\n return dq\n if iteration > 10 and torch.abs(dq_norm_last - dq_norm) / dq_norm < rtol:\n return dq\n\n iteration += 1\n\n dq_norm_last = dq_norm\n\n if dq_norm < dq_norm_best:\n dq_norm_best, dq_best = dq_norm, dq.clone()\n\n # handle infinite loops... following geomeTRIC\n if iteration % 100 == 99:\n step_size += random.random() * iteration / 100\n if iteration % 1000 == 999:\n return dq_best", "probing input": "def _find_dq(\n target_norm: float,\n step_size: float,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n rtol: float = 0.001,\n) -> torch.Tensor:\n \"\"\"\n\n Notes:\n Based on geomeTRIC, which is based on the iterative formula from Hebden (1973),\n equation 5.2.10 in \"Practical methods of optimization\" by Fletcher\n\n Returns:\n The found value of dq.\n \"\"\"\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n", "probing input new": "def _find_dq(\n target_norm: float,\n step_size: float,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n rtol: float = 0.001,\n) -> torch.Tensor:\n \"\"\"\n\n Notes:\n Based on geomeTRIC, which is based on the iterative formula from Hebden (1973),\n equation 5.2.10 in \"Practical methods of optimization\" by Fletcher\n\n Returns:\n The found value of dq.\n \"\"\"\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n dq_", "reference": "dq_norm=torch.linalg.norm(dq)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "dq_norm=torch.linalg.norm(dq)", "y_neg": " dq_norm = torch.norm(dq)", "retain": "def _find_dq(\n target_norm: float,\n step_size: float,\n coords_x: torch.Tensor,\n grad_q: torch.Tensor,\n hess_q: torch.Tensor,\n ic: tico.ic.IC,\n rtol: float = 0.001,\n) -> torch.Tensor:\n \"\"\"\n\n Notes:\n Based on geomeTRIC, which is based on the iterative formula from Hebden (1973),\n equation 5.2.10 in \"Practical methods of optimization\" by Fletcher\n\n Returns:\n The found value of dq.\n \"\"\"\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n dq_norm = torch.linalg.norm(dq)\n\n if dq_norm < target_norm:\n return dq\n\n dq_norm_last, dq_norm_best, dq_best = 0.0, dq_norm, dq.clone()\n\n iteration = 0\n\n while True:\n step_size += (1 - dq_norm / target_norm) * (dq_norm / dq_prime)\n\n dq, dq_prime = _compute_dq(step_size, coords_x, grad_q, hess_q, ic)\n dq_norm = torch.linalg.norm(dq)\n\n if torch.abs((dq_norm - target_norm) / target_norm) < rtol:\n return dq\n if iteration > 10 and torch.abs(dq_norm_last - dq_norm) / dq_norm < rtol:\n return dq\n\n iteration += 1\n\n dq_norm_last = dq_norm\n\n if dq_norm < dq_norm_best:\n dq_norm_best, dq_best = dq_norm, dq.clone()\n\n # handle infinite loops... following geomeTRIC\n if iteration % 100 == 99:\n step_size += random.random() * iteration / 100\n if iteration % 1000 == 999:\n return dq_best" }, { "id": 7855, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def ee_pose_target(batch_size):\n torch.manual_seed(1)\n\n ee_pos_mid = torch.Tensor([0.6, 0.0, 0.5])\n ee_pos_range = torch.Tensor([0.1, 0.2, 0.2])\n ee_quat_mid = torch.Tensor([0.9383, 0.3442, -0.0072, -0.0318])\n ee_quat_range = torch.Tensor([0.5, 0.5, 0.5])\n\n ee_pos_dev = ee_pos_range * torch.randn(batch_size, 3)\n ee_rot_dev = ee_quat_range * torch.randn(batch_size, 3)\n\n ee_pos_target = ee_pos_mid + ee_pos_dev\n ee_quat_target = (\n th.SO3.unit_quaternion_to_SO3(\n ee_quat_mid / torch.linalg.norm(ee_quat_mid)\n ).compose(th.SO3().exp_map(ee_rot_dev))\n ).to_quaternion()\n ee_pose_target = th.SE3(\n x_y_z_quaternion=torch.cat([ee_pos_target, ee_quat_target], dim=-1),\n name=\"ee_pose_target\",\n )\n\n return ee_pose_target", "probing input": "def ee_pose_target(batch_size):\n torch.manual_seed(1)\n\n ee_pos_mid = torch.Tensor([0.6, 0.0, 0.5])\n ee_pos_range = torch.Tensor([0.1, 0.2, 0.2])\n ee_quat_mid = torch.Tensor([0.9383, 0.3442, -0.0072, -0.0318])\n ee_quat_range = torch.Tensor([0.5, 0.5, 0.5])\n\n ee_pos_dev = ee_pos_range * torch.randn(batch_size, 3)\n ee_rot_dev = ee_quat_range * torch.randn(batch_size, 3)\n\n ee_pos_target = ee_pos_mid + ee_pos_dev\n ee_quat_target = (\n th.SO3.unit_quaternion_to_SO3(\n", "probing input new": "def ee_pose_target(batch_size):\n torch.manual_seed(1)\n\n ee_pos_mid = torch.Tensor([0.6, 0.0, 0.5])\n ee_pos_range = torch.Tensor([0.1, 0.2, 0.2])\n ee_quat_mid = torch.Tensor([0.9383, 0.3442, -0.0072, -0.0318])\n ee_quat_range = torch.Tensor([0.5, 0.5, 0.5])\n\n ee_pos_dev = ee_pos_range * torch.randn(batch_size, 3)\n ee_rot_dev = ee_quat_range * torch.randn(batch_size, 3)\n\n ee_pos_target = ee_pos_mid + ee_pos_dev\n ee_quat_target = (\n th.SO3.unit_quaternion_to_SO3(\n ee_quat_mid / torch.", "reference": "ee_quat_mid/torch.linalg.norm(ee_quat_mid)", "reference dict": { "HOME_POSE": "torch.Tensor", "ERR_SCALING": "torch.Tensor", "ee_pos_mid": "torch.Tensor", "ee_pos_range": "torch.Tensor", "ee_quat_mid": "torch.Tensor", "ee_quat_range": "torch.Tensor", "ee_pose_target": "th.SE3" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "ee_quat_mid/torch.linalg.norm(ee_quat_mid)", "y_neg": " ee_quat_mid / torch.norm(ee_quat_mid)", "retain": "def ee_pose_target(batch_size):\n torch.manual_seed(1)\n\n ee_pos_mid = torch.Tensor([0.6, 0.0, 0.5])\n ee_pos_range = torch.Tensor([0.1, 0.2, 0.2])\n ee_quat_mid = torch.Tensor([0.9383, 0.3442, -0.0072, -0.0318])\n ee_quat_range = torch.Tensor([0.5, 0.5, 0.5])\n\n ee_pos_dev = ee_pos_range * torch.randn(batch_size, 3)\n ee_rot_dev = ee_quat_range * torch.randn(batch_size, 3)\n\n ee_pos_target = ee_pos_mid + ee_pos_dev\n ee_quat_target = (\n th.SO3.unit_quaternion_to_SO3(\n ee_quat_mid / torch.linalg.norm(ee_quat_mid)\n ).compose(th.SO3().exp_map(ee_rot_dev))\n ).to_quaternion()\n ee_pose_target = th.SE3(\n x_y_z_quaternion=torch.cat([ee_pos_target, ee_quat_target], dim=-1),\n name=\"ee_pose_target\",\n )\n\n return ee_pose_target" }, { "id": 7859, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_at(self, img_idx, resolution_level=1):\n \"\"\"\n Generate rays at world space from one camera.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n rays_v = torch.matmul(pose[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = pose[None, None, :3, 3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7860, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(self.dtype) # batch_size, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o, rays_v, color, mask[:, :1]], dim=-1)", "probing input": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(self.dtype) # batch_size, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n", "probing input new": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(self.dtype) # batch_size, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # batch_size, 3", "retain": " def gen_random_rays_at(self, img_idx, batch_size):\n \"\"\"\n Generate random rays at world space from one camera.\n \"\"\"\n pixels_x = torch.randint(low=0, high=self.W, size=[batch_size])\n pixels_y = torch.randint(low=0, high=self.H, size=[batch_size])\n color = self.images[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n mask = self.masks[img_idx].to(self.device)[(pixels_y, pixels_x)] # batch_size, 3\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1).to(self.dtype) # batch_size, 3\n # Camera\n if self.camera_trainable:\n intrinsic_inv, pose = self.dynamic_paras_to_mat(img_idx)\n else:\n if self.is_monocular:\n intrinsic_inv = self.intrinsics_all_inv[0]\n else:\n intrinsic_inv = self.intrinsics_all_inv[img_idx]\n pose = self.poses_all[img_idx]\n p = torch.matmul(intrinsic_inv[None, :3, :3], p[:, :, None]).squeeze() # batch_size, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # batch_size, 3\n rays_v = torch.matmul(pose[None, :3, :3], rays_v[:, :, None]).squeeze() # batch_size, 3\n rays_o = pose[None, :3, 3].expand(rays_v.shape) # batch_size, 3\n return torch.cat([rays_o, rays_v, color, mask[:, :1]], dim=-1)" }, { "id": 7861, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)", "probing input": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n", "probing input new": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.", "reference": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "reference dict": { "slerp": "Slerp" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "rays_v=p/torch.linalg.norm(p,ord=2,dim=-1,keepdim=True)", "y_neg": " rays_v = p / torch.norm(p, dim=-1, keepdim=True) # W, H, 3", "retain": " def gen_rays_between(self, idx_0, idx_1, ratio, resolution_level=1):\n \"\"\"\n Interpolate pose between two cameras.\n \"\"\"\n l = resolution_level\n tx = torch.linspace(0, self.W - 1, self.W // l)\n ty = torch.linspace(0, self.H - 1, self.H // l)\n pixels_x, pixels_y = torch.meshgrid(tx, ty)\n p = torch.stack([pixels_x, pixels_y, torch.ones_like(pixels_y)], dim=-1) # W, H, 3\n p = torch.matmul(self.intrinsics_all_inv[0, None, None, :3, :3], p[:, :, :, None]).squeeze() # W, H, 3\n rays_v = p / torch.linalg.norm(p, ord=2, dim=-1, keepdim=True) # W, H, 3\n trans = self.pose_all[idx_0, :3, 3] * (1.0 - ratio) + self.pose_all[idx_1, :3, 3] * ratio\n pose_0 = self.pose_all[idx_0].detach().cpu().numpy()\n pose_1 = self.pose_all[idx_1].detach().cpu().numpy()\n pose_0 = np.linalg.inv(pose_0)\n pose_1 = np.linalg.inv(pose_1)\n rot_0 = pose_0[:3, :3]\n rot_1 = pose_1[:3, :3]\n rots = Rot.from_matrix(np.stack([rot_0, rot_1]))\n key_times = [0, 1]\n slerp = Slerp(key_times, rots)\n rot = slerp(ratio)\n pose = np.diag([1.0, 1.0, 1.0, 1.0])\n pose = pose.astype(np.float32)\n pose[:3, :3] = rot.as_matrix()\n pose[:3, 3] = ((1.0 - ratio) * pose_0 + ratio * pose_1)[:3, 3]\n pose = np.linalg.inv(pose)\n rot = torch.from_numpy(pose[:3, :3]).cuda()\n trans = torch.from_numpy(pose[:3, 3]).cuda()\n rays_v = torch.matmul(rot[None, None, :3, :3], rays_v[:, :, :, None]).squeeze() # W, H, 3\n rays_o = trans[None, None, :3].expand(rays_v.shape) # W, H, 3\n return rays_o.transpose(0, 1), rays_v.transpose(0, 1)" }, { "id": 7866, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n x = x.view(x.shape[0], -1, self.param_channels)\n mag = torch.linalg.norm(x, dim=-1)\n mag = self.act(mag * self.inner_fac) * self.outer_fac\n x = torch.nn.functional.normalize(x, dim=-1) * mag[..., None]\n return x", "probing input": " def forward(self, x):\n x = x.view(x.shape[0], -1, self.param_channels)\n", "probing input new": " def forward(self, x):\n x = x.view(x.shape[0], -1, self.param_channels)\n mag = torch.", "reference": "mag=torch.linalg.norm(x,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "mag=torch.linalg.norm(x,dim=-1)", "y_neg": " mag = torch.norm(x, 2, 2, True)", "retain": " def forward(self, x):\n x = x.view(x.shape[0], -1, self.param_channels)\n mag = torch.linalg.norm(x, dim=-1)\n mag = self.act(mag * self.inner_fac) * self.outer_fac\n x = torch.nn.functional.normalize(x, dim=-1) * mag[..., None]\n return x" }, { "id": 7872, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "for w in ws:\n _, dim = w.shape\n w = w.float().to(device)\n A, B, r, _ = svd_approx(w, r)\n As.append(A)\n Bs.append(B)\n\n\nWp = torch.zeros_like(ws[0])\n\nfor i in range(experts):\n Wd = As[i] @ Bs[i]\n Wp += ws[i] - Wd\nWp = Wp / experts\n\nfor idx, W, A, B in enumerate(zip(ws, As, Bs)):\n Wapx = Wp + A @ B\n print(idx, torch.linalg.norm(W - Wapx))", "probing input": "for w in ws:\n _, dim = w.shape\n w = w.float().to(device)\n A, B, r, _ = svd_approx(w, r)\n As.append(A)\n Bs.append(B)\n\n\nWp = torch.zeros_like(ws[0])\n\nfor i in range(experts):\n Wd = As[i] @ Bs[i]\n Wp += ws[i] - Wd\nWp = Wp / experts\n\nfor idx, W, A, B in enumerate(zip(ws, As, Bs)):\n Wapx = Wp + A @ B\n", "probing input new": "for w in ws:\n _, dim = w.shape\n w = w.float().to(device)\n A, B, r, _ = svd_approx(w, r)\n As.append(A)\n Bs.append(B)\n\n\nWp = torch.zeros_like(ws[0])\n\nfor i in range(experts):\n Wd = As[i] @ Bs[i]\n Wp += ws[i] - Wd\nWp = Wp / experts\n\nfor idx, W, A, B in enumerate(zip(ws, As, Bs)):\n Wapx = Wp + A @ B\n print(idx, torch.", "reference": "print(idx,torch.linalg.norm(W-Wapx))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "print(idx,torch.linalg.norm(W-Wapx))", "y_neg": " print(idx, torch.norm(W - Wapx))", "retain": "for w in ws:\n _, dim = w.shape\n w = w.float().to(device)\n A, B, r, _ = svd_approx(w, r)\n As.append(A)\n Bs.append(B)\n\n\nWp = torch.zeros_like(ws[0])\n\nfor i in range(experts):\n Wd = As[i] @ Bs[i]\n Wp += ws[i] - Wd\nWp = Wp / experts\n\nfor idx, W, A, B in enumerate(zip(ws, As, Bs)):\n Wapx = Wp + A @ B\n print(idx, torch.linalg.norm(W - Wapx))" }, { "id": 7873, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_norms():\n\n v1 = variable(torch.zeros(100, requires_grad=True))\n v2 = variable(torch.zeros(100, requires_grad=True))\n assert torch.equal(torch.linalg.norm(v1 - v2)(), torch.tensor(0.0))", "probing input": "def test_norms():\n\n v1 = variable(torch.zeros(100, requires_grad=True))\n v2 = variable(torch.zeros(100, requires_grad=True))\n", "probing input new": "def test_norms():\n\n v1 = variable(torch.zeros(100, requires_grad=True))\n v2 = variable(torch.zeros(100, requires_grad=True))\n assert torch.equal(torch.", "reference": "asserttorch.equal(torch.linalg.norm(v1-v2)(),torch.tensor(0.0))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "asserttorch.equal(torch.linalg.norm(v1-v2)(),torch.tensor(0.0))", "y_neg": " assert torch.equal(torch.norm(v1, 1), torch.norm(v2, 1))", "retain": "def test_norms():\n\n v1 = variable(torch.zeros(100, requires_grad=True))\n v2 = variable(torch.zeros(100, requires_grad=True))\n assert torch.equal(torch.linalg.norm(v1 - v2)(), torch.tensor(0.0))" }, { "id": 7875, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def grad_penalty(self, obs: torch.Tensor, action: torch.Tensor, ebm: nn.Module) -> torch.Tensor:\n \"\"\"\n Overview:\n Calculate gradient penalty.\n Arguments:\n - obs (:obj:`torch.Tensor`): Observations.\n - action (:obj:`torch.Tensor`): Actions.\n - ebm (:obj:`torch.nn.Module`): Energy based model.\n Returns:\n - loss (:obj:`torch.Tensor`): Gradient penalty.\n Shapes:\n - obs (:obj:`torch.Tensor`): :math:`(B, N+1, O)`.\n - action (:obj:`torch.Tensor`): :math:`(B, N+1, A)`.\n - ebm (:obj:`torch.nn.Module`): :math:`(B, N+1, O)`.\n - loss (:obj:`torch.Tensor`): :math:`(B, )`.\n \"\"\"\n if not self.add_grad_penalty:\n return 0.\n # (B, N+1, A), this gradient is differentiable w.r.t model parameters\n de_dact = MCMC._gradient_wrt_act(obs, action, ebm, create_graph=True)\n\n def compute_grad_norm(grad_norm_type, de_dact) -> torch.Tensor:\n # de_deact: B, N+1, A\n # return: B, N+1\n grad_norm_type_to_ord = {\n '1': 1,\n '2': 2,\n 'inf': float('inf'),\n }\n ord = grad_norm_type_to_ord[grad_norm_type]\n return torch.linalg.norm(de_dact, ord, dim=-1)\n\n # (B, N+1)\n grad_norms = compute_grad_norm(self.grad_norm_type, de_dact)\n grad_norms = grad_norms - self.grad_margin\n grad_norms = grad_norms.clamp(min=0., max=1e10)\n grad_norms = grad_norms.pow(2)\n\n grad_loss = grad_norms.mean()\n return grad_loss * self.grad_loss_weight", "probing input": " def grad_penalty(self, obs: torch.Tensor, action: torch.Tensor, ebm: nn.Module) -> torch.Tensor:\n \"\"\"\n Overview:\n Calculate gradient penalty.\n Arguments:\n - obs (:obj:`torch.Tensor`): Observations.\n - action (:obj:`torch.Tensor`): Actions.\n - ebm (:obj:`torch.nn.Module`): Energy based model.\n Returns:\n - loss (:obj:`torch.Tensor`): Gradient penalty.\n Shapes:\n - obs (:obj:`torch.Tensor`): :math:`(B, N+1, O)`.\n - action (:obj:`torch.Tensor`): :math:`(B, N+1, A)`.\n - ebm (:obj:`torch.nn.Module`): :math:`(B, N+1, O)`.\n - loss (:obj:`torch.Tensor`): :math:`(B, )`.\n \"\"\"\n if not self.add_grad_penalty:\n return 0.\n # (B, N+1, A), this gradient is differentiable w.r.t model parameters\n de_dact = MCMC._gradient_wrt_act(obs, action, ebm, create_graph=True)\n\n def compute_grad_norm(grad_norm_type, de_dact) -> torch.Tensor:\n # de_deact: B, N+1, A\n # return: B, N+1\n grad_norm_type_to_ord = {\n '1': 1,\n '2': 2,\n 'inf': float('inf'),\n }\n ord = grad_norm_type_to_ord[grad_norm_type]\n", "probing input new": " def grad_penalty(self, obs: torch.Tensor, action: torch.Tensor, ebm: nn.Module) -> torch.Tensor:\n \"\"\"\n Overview:\n Calculate gradient penalty.\n Arguments:\n - obs (:obj:`torch.Tensor`): Observations.\n - action (:obj:`torch.Tensor`): Actions.\n - ebm (:obj:`torch.nn.Module`): Energy based model.\n Returns:\n - loss (:obj:`torch.Tensor`): Gradient penalty.\n Shapes:\n - obs (:obj:`torch.Tensor`): :math:`(B, N+1, O)`.\n - action (:obj:`torch.Tensor`): :math:`(B, N+1, A)`.\n - ebm (:obj:`torch.nn.Module`): :math:`(B, N+1, O)`.\n - loss (:obj:`torch.Tensor`): :math:`(B, )`.\n \"\"\"\n if not self.add_grad_penalty:\n return 0.\n # (B, N+1, A), this gradient is differentiable w.r.t model parameters\n de_dact = MCMC._gradient_wrt_act(obs, action, ebm, create_graph=True)\n\n def compute_grad_norm(grad_norm_type, de_dact) -> torch.Tensor:\n # de_deact: B, N+1, A\n # return: B, N+1\n grad_norm_type_to_ord = {\n '1': 1,\n '2': 2,\n 'inf': float('inf'),\n }\n ord = grad_norm_type_to_ord[grad_norm_type]\n return torch.", "reference": "returntorch.linalg.norm(de_dact,ord,dim=-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "returntorch.linalg.norm(de_dact,ord,dim=-1)", "y_neg": " return torch.norm(de_dact, ord=ord, dim=-1)", "retain": " def grad_penalty(self, obs: torch.Tensor, action: torch.Tensor, ebm: nn.Module) -> torch.Tensor:\n \"\"\"\n Overview:\n Calculate gradient penalty.\n Arguments:\n - obs (:obj:`torch.Tensor`): Observations.\n - action (:obj:`torch.Tensor`): Actions.\n - ebm (:obj:`torch.nn.Module`): Energy based model.\n Returns:\n - loss (:obj:`torch.Tensor`): Gradient penalty.\n Shapes:\n - obs (:obj:`torch.Tensor`): :math:`(B, N+1, O)`.\n - action (:obj:`torch.Tensor`): :math:`(B, N+1, A)`.\n - ebm (:obj:`torch.nn.Module`): :math:`(B, N+1, O)`.\n - loss (:obj:`torch.Tensor`): :math:`(B, )`.\n \"\"\"\n if not self.add_grad_penalty:\n return 0.\n # (B, N+1, A), this gradient is differentiable w.r.t model parameters\n de_dact = MCMC._gradient_wrt_act(obs, action, ebm, create_graph=True)\n\n def compute_grad_norm(grad_norm_type, de_dact) -> torch.Tensor:\n # de_deact: B, N+1, A\n # return: B, N+1\n grad_norm_type_to_ord = {\n '1': 1,\n '2': 2,\n 'inf': float('inf'),\n }\n ord = grad_norm_type_to_ord[grad_norm_type]\n return torch.linalg.norm(de_dact, ord, dim=-1)\n\n # (B, N+1)\n grad_norms = compute_grad_norm(self.grad_norm_type, de_dact)\n grad_norms = grad_norms - self.grad_margin\n grad_norms = grad_norms.clamp(min=0., max=1e10)\n grad_norms = grad_norms.pow(2)\n\n grad_loss = grad_norms.mean()\n return grad_loss * self.grad_loss_weight" }, { "id": 7876, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_inverse_kinematics(\n self,\n position: torch.Tensor,\n orientation: torch.Tensor,\n q0: torch.Tensor,\n tol: float = 1e-3,\n ) -> Tuple[torch.Tensor, bool]:\n \"\"\"Compute inverse kinematics given desired EE pose\"\"\"\n # Call IK\n joint_pos_output = self.robot_model.inverse_kinematics(\n position, orientation, rest_pose=q0\n )\n\n # Check result\n pos_output, quat_output = self.robot_model.forward_kinematics(joint_pos_output)\n pose_desired = T.from_rot_xyz(R.from_quat(orientation), position)\n pose_output = T.from_rot_xyz(R.from_quat(quat_output), pos_output)\n err = torch.linalg.norm((pose_desired * pose_output.inv()).as_twist())\n ik_sol_found = err < tol\n\n return joint_pos_output, ik_sol_found", "probing input": " def solve_inverse_kinematics(\n self,\n position: torch.Tensor,\n orientation: torch.Tensor,\n q0: torch.Tensor,\n tol: float = 1e-3,\n ) -> Tuple[torch.Tensor, bool]:\n \"\"\"Compute inverse kinematics given desired EE pose\"\"\"\n # Call IK\n joint_pos_output = self.robot_model.inverse_kinematics(\n position, orientation, rest_pose=q0\n )\n\n # Check result\n pos_output, quat_output = self.robot_model.forward_kinematics(joint_pos_output)\n pose_desired = T.from_rot_xyz(R.from_quat(orientation), position)\n pose_output = T.from_rot_xyz(R.from_quat(quat_output), pos_output)\n", "probing input new": " def solve_inverse_kinematics(\n self,\n position: torch.Tensor,\n orientation: torch.Tensor,\n q0: torch.Tensor,\n tol: float = 1e-3,\n ) -> Tuple[torch.Tensor, bool]:\n \"\"\"Compute inverse kinematics given desired EE pose\"\"\"\n # Call IK\n joint_pos_output = self.robot_model.inverse_kinematics(\n position, orientation, rest_pose=q0\n )\n\n # Check result\n pos_output, quat_output = self.robot_model.forward_kinematics(joint_pos_output)\n pose_desired = T.from_rot_xyz(R.from_quat(orientation), position)\n pose_output = T.from_rot_xyz(R.from_quat(quat_output), pos_output)\n err = torch.", "reference": "err=torch.linalg.norm((pose_desired*pose_output.inv()).as_twist())", "reference dict": { "EMPTY": "Empty" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.norm" ], "replacement api": "torch.linalg.norm", "expected call": "torch.linalg.norm", "y_pos": "err=torch.linalg.norm((pose_desired*pose_output.inv()).as_twist())", "y_neg": " err = torch.norm(pose_desired - pose_output)", "retain": " def solve_inverse_kinematics(\n self,\n position: torch.Tensor,\n orientation: torch.Tensor,\n q0: torch.Tensor,\n tol: float = 1e-3,\n ) -> Tuple[torch.Tensor, bool]:\n \"\"\"Compute inverse kinematics given desired EE pose\"\"\"\n # Call IK\n joint_pos_output = self.robot_model.inverse_kinematics(\n position, orientation, rest_pose=q0\n )\n\n # Check result\n pos_output, quat_output = self.robot_model.forward_kinematics(joint_pos_output)\n pose_desired = T.from_rot_xyz(R.from_quat(orientation), position)\n pose_output = T.from_rot_xyz(R.from_quat(quat_output), pos_output)\n err = torch.linalg.norm((pose_desired * pose_output.inv()).as_twist())\n ik_sol_found = err < tol\n\n return joint_pos_output, ik_sol_found" }, { "id": 8007, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_triangular_solve(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper).solution\n actual = torch.linalg.solve_triangular(A, b, upper=upper)\n assert_close(actual, expected)\n A = A.triu() if upper else A.tril()\n assert_close(A @ actual, b)", "probing input": "def test_triangular_solve(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper).solution\n", "probing input new": "def test_triangular_solve(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper).solution\n actual = torch.", "reference": "actual=torch.linalg.solve_triangular(A,b,upper=upper)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.triangular_solve" ], "replacement api": "torch.linalg.solve_triangular", "expected call": "torch.linalg.solve_triangular", "y_pos": "actual=torch.linalg.solve_triangular(A,b,upper=upper)", "y_neg": " actual = torch.triangular_solve(b, A, upper=upper).solution", "retain": "def test_triangular_solve(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper).solution\n actual = torch.linalg.solve_triangular(A, b, upper=upper)\n assert_close(actual, expected)\n A = A.triu() if upper else A.tril()\n assert_close(A @ actual, b)" }, { "id": 8008, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_triangular_solve_transpose(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper, transpose=True).solution\n actual = torch.linalg.solve_triangular(A.T, b, upper=not upper)\n assert_close(actual, expected)\n A = A.triu() if upper else A.tril()\n assert_close(A.T @ actual, b)", "probing input": "def test_triangular_solve_transpose(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper, transpose=True).solution\n", "probing input new": "def test_triangular_solve_transpose(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper, transpose=True).solution\n actual = torch.", "reference": "actual=torch.linalg.solve_triangular(A.T,b,upper=notupper)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.triangular_solve" ], "replacement api": "torch.linalg.solve_triangular", "expected call": "torch.linalg.solve_triangular", "y_pos": "actual=torch.linalg.solve_triangular(A.T,b,upper=notupper)", "y_neg": " actual = torch.triangular_solve(b, A, upper=upper, transpose=True)", "retain": "def test_triangular_solve_transpose(upper):\n b = torch.randn(5, 6)\n A = torch.randn(5, 5)\n expected = torch.triangular_solve(b, A, upper=upper, transpose=True).solution\n actual = torch.linalg.solve_triangular(A.T, b, upper=not upper)\n assert_close(actual, expected)\n A = A.triu() if upper else A.tril()\n assert_close(A.T @ actual, b)" }, { "id": 8025, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma", "probing input": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda()\n try:\n", "probing input new": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.", "reference": "chol=torch.linalg.cholesky(Covi)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(Covi)", "y_neg": " chol = torch.cholesky(Covi)", "retain": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += cfg.COWA.EPSILON * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma" }, { "id": 8027, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def event_logsumexp(self):\n \"\"\"\n Integrates out all latent state (i.e. operating on event dimensions) of Gaussian component.\n \"\"\"\n n = self.dim()\n chol_P = torch.linalg.cholesky(self.precision)\n chol_P_u = torch.linalg.solve_triangular(\n chol_P, self.info_vec.unsqueeze(-1), upper=False\n ).squeeze(-1)\n u_P_u = chol_P_u.pow(2).sum(-1)\n # considering GammaGaussian as a Gaussian with precision = s * precision, info_vec = s * info_vec,\n # marginalize x variable, we get\n # logsumexp(s) = alpha * log(s) - s * beta + 0.5 n * log(2 pi) + \\\n # 0.5 s * uPu - 0.5 * log|P| - 0.5 n * log(s)\n # use the original parameterization of Gamma, we get\n # logsumexp(s) = (concentration - 1) * log(s) - s * rate + 0.5 n * log(2 pi) - 0.5 * |P|\n # Note that `(concentration - 1) * log(s) - s * rate` is unnormalized log_prob of\n # Gamma(concentration, rate)\n concentration = self.alpha - 0.5 * n + 1\n rate = self.beta - 0.5 * u_P_u\n log_normalizer_tmp = 0.5 * n * math.log(2 * math.pi) - chol_P.diagonal(\n dim1=-2, dim2=-1\n ).log().sum(-1)\n return Gamma(self.log_normalizer + log_normalizer_tmp, concentration, rate)", "probing input": " def event_logsumexp(self):\n \"\"\"\n Integrates out all latent state (i.e. operating on event dimensions) of Gaussian component.\n \"\"\"\n n = self.dim()\n", "probing input new": " def event_logsumexp(self):\n \"\"\"\n Integrates out all latent state (i.e. operating on event dimensions) of Gaussian component.\n \"\"\"\n n = self.dim()\n chol_P = torch.", "reference": "chol_P=torch.linalg.cholesky(self.precision)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_P=torch.linalg.cholesky(self.precision)", "y_neg": " chol_P = torch.cholesky(self.P)", "retain": " def event_logsumexp(self):\n \"\"\"\n Integrates out all latent state (i.e. operating on event dimensions) of Gaussian component.\n \"\"\"\n n = self.dim()\n chol_P = torch.linalg.cholesky(self.precision)\n chol_P_u = torch.linalg.solve_triangular(\n chol_P, self.info_vec.unsqueeze(-1), upper=False\n ).squeeze(-1)\n u_P_u = chol_P_u.pow(2).sum(-1)\n # considering GammaGaussian as a Gaussian with precision = s * precision, info_vec = s * info_vec,\n # marginalize x variable, we get\n # logsumexp(s) = alpha * log(s) - s * beta + 0.5 n * log(2 pi) + \\\n # 0.5 s * uPu - 0.5 * log|P| - 0.5 n * log(s)\n # use the original parameterization of Gamma, we get\n # logsumexp(s) = (concentration - 1) * log(s) - s * rate + 0.5 n * log(2 pi) - 0.5 * |P|\n # Note that `(concentration - 1) * log(s) - s * rate` is unnormalized log_prob of\n # Gamma(concentration, rate)\n concentration = self.alpha - 0.5 * n + 1\n rate = self.beta - 0.5 * u_P_u\n log_normalizer_tmp = 0.5 * n * math.log(2 * math.pi) - chol_P.diagonal(\n dim1=-2, dim2=-1\n ).log().sum(-1)\n return Gamma(self.log_normalizer + log_normalizer_tmp, concentration, rate)" }, { "id": 8029, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def covariance_cholesky(self, t: TensorType[..., 'N', 1]) -> TensorType[..., 'N', 'N']:\n return torch.linalg.cholesky(self.covariance(t))", "probing input": " def covariance_cholesky(self, t: TensorType[..., 'N', 1]) -> TensorType[..., 'N', 'N']:\n", "probing input new": " def covariance_cholesky(self, t: TensorType[..., 'N', 1]) -> TensorType[..., 'N', 'N']:\n return torch.", "reference": "returntorch.linalg.cholesky(self.covariance(t))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(self.covariance(t))", "y_neg": " return torch.cholesky(t)", "retain": " def covariance_cholesky(self, t: TensorType[..., 'N', 1]) -> TensorType[..., 'N', 'N']:\n return torch.linalg.cholesky(self.covariance(t))" }, { "id": 8031, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)", "probing input": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n", "probing input new": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.", "reference": "returntorch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(K)", "y_neg": " return torch.cholesky(K)", "retain": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)" }, { "id": 8032, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(self._batch_shape + self._event_shape + self._event_shape)", "probing input": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n", "probing input new": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.", "reference": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "y_neg": " scale_tril = cov_diag_sqrt_unsqueeze * torch.cholesky(K)", "retain": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(self._batch_shape + self._event_shape + self._event_shape)" }, { "id": 8033, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exacteig(A: LinearOperator, neig: int,\n mode: str, M: Optional[LinearOperator]) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n Eigendecomposition using explicit matrix construction.\n No additional option for this method.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n Amatrix = A.fullmatrix() # (*BA, q, q)\n if M is None:\n # evals, evecs = torch.linalg.eigh(Amatrix, eigenvectors=True) # (*BA, q), (*BA, q, q)\n evals, evecs = degen_symeig.apply(Amatrix) # (*BA, q, q)\n return _take_eigpairs(evals, evecs, neig, mode)\n else:\n Mmatrix = M.fullmatrix() # (*BM, q, q)\n\n # M decomposition to make A symmetric\n # it is done this way to make it numerically stable in avoiding\n # complex eigenvalues for (near-)degenerate case\n L = torch.linalg.cholesky(Mmatrix) # (*BM, q, q)\n Linv = torch.inverse(L) # (*BM, q, q)\n LinvT = Linv.transpose(-2, -1).conj() # (*BM, q, q)\n A2 = torch.matmul(Linv, torch.matmul(Amatrix, LinvT)) # (*BAM, q, q)\n\n # calculate the eigenvalues and eigenvectors\n # (the eigvecs are normalized in M-space)\n # evals, evecs = torch.linalg.eigh(A2, eigenvectors=True) # (*BAM, q, q)\n evals, evecs = degen_symeig.apply(A2) # (*BAM, q, q)\n evals, evecs = _take_eigpairs(evals, evecs, neig, mode) # (*BAM, neig) and (*BAM, q, neig)\n evecs = torch.matmul(LinvT, evecs)\n return evals, evecs", "probing input": "def exacteig(A: LinearOperator, neig: int,\n mode: str, M: Optional[LinearOperator]) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n Eigendecomposition using explicit matrix construction.\n No additional option for this method.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n Amatrix = A.fullmatrix() # (*BA, q, q)\n if M is None:\n # evals, evecs = torch.linalg.eigh(Amatrix, eigenvectors=True) # (*BA, q), (*BA, q, q)\n evals, evecs = degen_symeig.apply(Amatrix) # (*BA, q, q)\n return _take_eigpairs(evals, evecs, neig, mode)\n else:\n Mmatrix = M.fullmatrix() # (*BM, q, q)\n\n # M decomposition to make A symmetric\n # it is done this way to make it numerically stable in avoiding\n # complex eigenvalues for (near-)degenerate case\n", "probing input new": "def exacteig(A: LinearOperator, neig: int,\n mode: str, M: Optional[LinearOperator]) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n Eigendecomposition using explicit matrix construction.\n No additional option for this method.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n Amatrix = A.fullmatrix() # (*BA, q, q)\n if M is None:\n # evals, evecs = torch.linalg.eigh(Amatrix, eigenvectors=True) # (*BA, q), (*BA, q, q)\n evals, evecs = degen_symeig.apply(Amatrix) # (*BA, q, q)\n return _take_eigpairs(evals, evecs, neig, mode)\n else:\n Mmatrix = M.fullmatrix() # (*BM, q, q)\n\n # M decomposition to make A symmetric\n # it is done this way to make it numerically stable in avoiding\n # complex eigenvalues for (near-)degenerate case\n L = torch.", "reference": "L=torch.linalg.cholesky(Mmatrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Mmatrix)", "y_neg": " L = torch.cholesky(Mmatrix + Amatrix)", "retain": "def exacteig(A: LinearOperator, neig: int,\n mode: str, M: Optional[LinearOperator]) -> Tuple[torch.Tensor, torch.Tensor]:\n \"\"\"\n Eigendecomposition using explicit matrix construction.\n No additional option for this method.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n Amatrix = A.fullmatrix() # (*BA, q, q)\n if M is None:\n # evals, evecs = torch.linalg.eigh(Amatrix, eigenvectors=True) # (*BA, q), (*BA, q, q)\n evals, evecs = degen_symeig.apply(Amatrix) # (*BA, q, q)\n return _take_eigpairs(evals, evecs, neig, mode)\n else:\n Mmatrix = M.fullmatrix() # (*BM, q, q)\n\n # M decomposition to make A symmetric\n # it is done this way to make it numerically stable in avoiding\n # complex eigenvalues for (near-)degenerate case\n L = torch.linalg.cholesky(Mmatrix) # (*BM, q, q)\n Linv = torch.inverse(L) # (*BM, q, q)\n LinvT = Linv.transpose(-2, -1).conj() # (*BM, q, q)\n A2 = torch.matmul(Linv, torch.matmul(Amatrix, LinvT)) # (*BAM, q, q)\n\n # calculate the eigenvalues and eigenvectors\n # (the eigvecs are normalized in M-space)\n # evals, evecs = torch.linalg.eigh(A2, eigenvectors=True) # (*BAM, q, q)\n evals, evecs = degen_symeig.apply(A2) # (*BAM, q, q)\n evals, evecs = _take_eigpairs(evals, evecs, neig, mode) # (*BAM, neig) and (*BAM, q, neig)\n evecs = torch.matmul(LinvT, evecs)\n return evals, evecs" }, { "id": 8035, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _reset_cache(self):\n\t\t\"\"\"Reset the internally stored statistics.\n\n\t\tThis method is meant to only be called internally. It resets the\n\t\tstored statistics used to update the model parameters as well as\n\t\trecalculates the cached values meant to speed up log probability\n\t\tcalculations.\n\t\t\"\"\"\n\n\t\tif self._initialized == False:\n\t\t\treturn\n\n\t\tself.register_buffer(\"_w_sum\", torch.zeros(self.d, dtype=self.dtype, \n\t\t\tdevice=self.device))\n\t\tself.register_buffer(\"_xw_sum\", torch.zeros(self.d, dtype=self.dtype,\n\t\t\tdevice=self.device))\n\n\t\tif self.covariance_type == 'full':\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n\t\t\t\tchol = torch.linalg.cholesky(self.covs)\n\t\t\t\t_inv_cov = torch.linalg.solve_triangular(chol, torch.eye(\n\t\t\t\t\tlen(self.covs), dtype=self.dtype, device=self.device), \n\t\t\t\t\tupper=False).T\n\t\t\t\t_inv_cov_dot_mu = torch.matmul(self.means, _inv_cov)\n\t\t\t\t_log_det = -0.5 * torch.linalg.slogdet(self.covs)[1]\n\t\t\t\t_theta = _log_det - 0.5 * (self.d * LOG_2_PI)\n\n\t\t\t\tself.register_buffer(\"_inv_cov\", _inv_cov)\n\t\t\t\tself.register_buffer(\"_inv_cov_dot_mu\", _inv_cov_dot_mu)\n\t\t\t\tself.register_buffer(\"_log_det\", _log_det)\n\t\t\t\tself.register_buffer(\"_theta\", _theta)\n\n\t\telif self.covariance_type in ('diag', 'sphere'):\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n\t\t\t\t_log_sigma_sqrt_2pi = -torch.log(torch.sqrt(self.covs) * \n\t\t\t\t\tSQRT_2_PI)\n\t\t\t\t_inv_two_sigma = 1. / (2 * self.covs)\n\n\t\t\t\tself.register_buffer(\"_log_sigma_sqrt_2pi\", _log_sigma_sqrt_2pi)\n\t\t\t\tself.register_buffer(\"_inv_two_sigma\", _inv_two_sigma)\n\t\t\t\n\t\t\tif any(self.covs < 0):\n\t\t\t\traise ValueError(\"Variances must be positive.\")", "probing input": " def _reset_cache(self):\n\t\t\"\"\"Reset the internally stored statistics.\n\n\t\tThis method is meant to only be called internally. It resets the\n\t\tstored statistics used to update the model parameters as well as\n\t\trecalculates the cached values meant to speed up log probability\n\t\tcalculations.\n\t\t\"\"\"\n\n\t\tif self._initialized == False:\n\t\t\treturn\n\n\t\tself.register_buffer(\"_w_sum\", torch.zeros(self.d, dtype=self.dtype, \n\t\t\tdevice=self.device))\n\t\tself.register_buffer(\"_xw_sum\", torch.zeros(self.d, dtype=self.dtype,\n\t\t\tdevice=self.device))\n\n\t\tif self.covariance_type == 'full':\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n", "probing input new": " def _reset_cache(self):\n\t\t\"\"\"Reset the internally stored statistics.\n\n\t\tThis method is meant to only be called internally. It resets the\n\t\tstored statistics used to update the model parameters as well as\n\t\trecalculates the cached values meant to speed up log probability\n\t\tcalculations.\n\t\t\"\"\"\n\n\t\tif self._initialized == False:\n\t\t\treturn\n\n\t\tself.register_buffer(\"_w_sum\", torch.zeros(self.d, dtype=self.dtype, \n\t\t\tdevice=self.device))\n\t\tself.register_buffer(\"_xw_sum\", torch.zeros(self.d, dtype=self.dtype,\n\t\t\tdevice=self.device))\n\n\t\tif self.covariance_type == 'full':\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n\t\t\t\tchol = torch.", "reference": "chol=torch.linalg.cholesky(self.covs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(self.covs)", "y_neg": "\t\t\t\tchol = torch.cholesky(self.covs.add(self.eps).unsqueeze(0).unsqueeze(0))", "retain": " def _reset_cache(self):\n\t\t\"\"\"Reset the internally stored statistics.\n\n\t\tThis method is meant to only be called internally. It resets the\n\t\tstored statistics used to update the model parameters as well as\n\t\trecalculates the cached values meant to speed up log probability\n\t\tcalculations.\n\t\t\"\"\"\n\n\t\tif self._initialized == False:\n\t\t\treturn\n\n\t\tself.register_buffer(\"_w_sum\", torch.zeros(self.d, dtype=self.dtype, \n\t\t\tdevice=self.device))\n\t\tself.register_buffer(\"_xw_sum\", torch.zeros(self.d, dtype=self.dtype,\n\t\t\tdevice=self.device))\n\n\t\tif self.covariance_type == 'full':\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n\t\t\t\tchol = torch.linalg.cholesky(self.covs)\n\t\t\t\t_inv_cov = torch.linalg.solve_triangular(chol, torch.eye(\n\t\t\t\t\tlen(self.covs), dtype=self.dtype, device=self.device), \n\t\t\t\t\tupper=False).T\n\t\t\t\t_inv_cov_dot_mu = torch.matmul(self.means, _inv_cov)\n\t\t\t\t_log_det = -0.5 * torch.linalg.slogdet(self.covs)[1]\n\t\t\t\t_theta = _log_det - 0.5 * (self.d * LOG_2_PI)\n\n\t\t\t\tself.register_buffer(\"_inv_cov\", _inv_cov)\n\t\t\t\tself.register_buffer(\"_inv_cov_dot_mu\", _inv_cov_dot_mu)\n\t\t\t\tself.register_buffer(\"_log_det\", _log_det)\n\t\t\t\tself.register_buffer(\"_theta\", _theta)\n\n\t\telif self.covariance_type in ('diag', 'sphere'):\n\t\t\tself.register_buffer(\"_xxw_sum\", torch.zeros(self.d, \n\t\t\t\tdtype=self.dtype, device=self.device))\n\n\t\t\tif self.covs.sum() > 0.0:\n\t\t\t\t_log_sigma_sqrt_2pi = -torch.log(torch.sqrt(self.covs) * \n\t\t\t\t\tSQRT_2_PI)\n\t\t\t\t_inv_two_sigma = 1. / (2 * self.covs)\n\n\t\t\t\tself.register_buffer(\"_log_sigma_sqrt_2pi\", _log_sigma_sqrt_2pi)\n\t\t\t\tself.register_buffer(\"_inv_two_sigma\", _inv_two_sigma)\n\t\t\t\n\t\t\tif any(self.covs < 0):\n\t\t\t\traise ValueError(\"Variances must be positive.\")" }, { "id": 8037, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(A_hat, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term", "probing input": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n", "probing input new": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.", "reference": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "y_neg": " K_mm_chol = torch.cholesky(K_mm)", "retain": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(A_hat, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term" }, { "id": 8041, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _sample_approx_posterior_mog(\n self, num_samples, x: Tensor, batch_size: int\n ) -> Tensor:\n r\"\"\"Sample from the approximate posterior.\n\n Args:\n num_samples: Desired number of samples.\n x: Conditioning context for posterior $p(\\theta|x)$.\n batch_size: Batch size for sampling.\n\n Returns:\n Samples from the approximate mixture of Gaussians posterior.\n \"\"\"\n\n # Compute the mixture components of the posterior.\n logits_p, m_p, prec_p = self._posthoc_correction(x)\n\n # Compute the precision factors which represent the upper triangular matrix\n # of the cholesky decomposition of the prec_p.\n prec_factors_p = torch.linalg.cholesky(prec_p, upper=True)\n\n assert logits_p.ndim == 2\n assert m_p.ndim == 3\n assert prec_p.ndim == 4\n assert prec_factors_p.ndim == 4\n\n # Replicate to use batched sampling from pyknos.\n if batch_size is not None and batch_size > 1:\n logits_p = logits_p.repeat(batch_size, 1)\n m_p = m_p.repeat(batch_size, 1, 1)\n prec_factors_p = prec_factors_p.repeat(batch_size, 1, 1, 1)\n\n # Get (optionally z-scored) MoG samples.\n theta = MultivariateGaussianMDN.sample_mog(\n num_samples, logits_p, m_p, prec_factors_p\n )\n\n embedded_context = self._neural_net._embedding_net(x)\n if embedded_context is not None:\n # Merge the context dimension with sample dimension in order to\n # apply the transform.\n theta = torchutils.merge_leading_dims(theta, num_dims=2)\n embedded_context = torchutils.repeat_rows(\n embedded_context, num_reps=num_samples\n )\n\n theta, _ = self._neural_net._transform.inverse(theta, context=embedded_context)\n\n if embedded_context is not None:\n # Split the context dimension from sample dimension.\n theta = torchutils.split_leading_dim(theta, shape=[-1, num_samples])\n\n return theta", "probing input": " def _sample_approx_posterior_mog(\n self, num_samples, x: Tensor, batch_size: int\n ) -> Tensor:\n r\"\"\"Sample from the approximate posterior.\n\n Args:\n num_samples: Desired number of samples.\n x: Conditioning context for posterior $p(\\theta|x)$.\n batch_size: Batch size for sampling.\n\n Returns:\n Samples from the approximate mixture of Gaussians posterior.\n \"\"\"\n\n # Compute the mixture components of the posterior.\n logits_p, m_p, prec_p = self._posthoc_correction(x)\n\n # Compute the precision factors which represent the upper triangular matrix\n # of the cholesky decomposition of the prec_p.\n", "probing input new": " def _sample_approx_posterior_mog(\n self, num_samples, x: Tensor, batch_size: int\n ) -> Tensor:\n r\"\"\"Sample from the approximate posterior.\n\n Args:\n num_samples: Desired number of samples.\n x: Conditioning context for posterior $p(\\theta|x)$.\n batch_size: Batch size for sampling.\n\n Returns:\n Samples from the approximate mixture of Gaussians posterior.\n \"\"\"\n\n # Compute the mixture components of the posterior.\n logits_p, m_p, prec_p = self._posthoc_correction(x)\n\n # Compute the precision factors which represent the upper triangular matrix\n # of the cholesky decomposition of the prec_p.\n prec_factors_p = torch.", "reference": "prec_factors_p=torch.linalg.cholesky(prec_p,upper=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "prec_factors_p=torch.linalg.cholesky(prec_p,upper=True)", "y_neg": " prec_factors_p = torch.cholesky(prec_p)", "retain": " def _sample_approx_posterior_mog(\n self, num_samples, x: Tensor, batch_size: int\n ) -> Tensor:\n r\"\"\"Sample from the approximate posterior.\n\n Args:\n num_samples: Desired number of samples.\n x: Conditioning context for posterior $p(\\theta|x)$.\n batch_size: Batch size for sampling.\n\n Returns:\n Samples from the approximate mixture of Gaussians posterior.\n \"\"\"\n\n # Compute the mixture components of the posterior.\n logits_p, m_p, prec_p = self._posthoc_correction(x)\n\n # Compute the precision factors which represent the upper triangular matrix\n # of the cholesky decomposition of the prec_p.\n prec_factors_p = torch.linalg.cholesky(prec_p, upper=True)\n\n assert logits_p.ndim == 2\n assert m_p.ndim == 3\n assert prec_p.ndim == 4\n assert prec_factors_p.ndim == 4\n\n # Replicate to use batched sampling from pyknos.\n if batch_size is not None and batch_size > 1:\n logits_p = logits_p.repeat(batch_size, 1)\n m_p = m_p.repeat(batch_size, 1, 1)\n prec_factors_p = prec_factors_p.repeat(batch_size, 1, 1, 1)\n\n # Get (optionally z-scored) MoG samples.\n theta = MultivariateGaussianMDN.sample_mog(\n num_samples, logits_p, m_p, prec_factors_p\n )\n\n embedded_context = self._neural_net._embedding_net(x)\n if embedded_context is not None:\n # Merge the context dimension with sample dimension in order to\n # apply the transform.\n theta = torchutils.merge_leading_dims(theta, num_dims=2)\n embedded_context = torchutils.repeat_rows(\n embedded_context, num_reps=num_samples\n )\n\n theta, _ = self._neural_net._transform.inverse(theta, context=embedded_context)\n\n if embedded_context is not None:\n # Split the context dimension from sample dimension.\n theta = torchutils.split_leading_dim(theta, shape=[-1, num_samples])\n\n return theta" }, { "id": 8043, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x_train, y_train, x_test):\n \n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(x_train.size(0)) \\\n + JITTER * torch.eye(x_train.size(0))\n \n kx = self.kernel(x_train, x_test)\n L = torch.linalg.cholesky(Sigma)\n LinvKx,_ = torch.triangular_solve(kx, L, upper = False)\n\n # option 1\n mean = kx.t() @ torch.cholesky_solve(y_train, L) # torch.linalg.cholesky()\n \n var = self.kernel(x_test, x_test) - LinvKx.t() @ LinvKx\n\n # add the noise uncertainty\n var = var + self.log_beta.exp().pow(-1)\n # if y_train_var is not None:\n # var = var + y_train_var.diag()* torch.eye(x_test.size(0))\n\n return mean, var", "probing input": " def forward(self, x_train, y_train, x_test):\n \n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(x_train.size(0)) \\\n + JITTER * torch.eye(x_train.size(0))\n \n kx = self.kernel(x_train, x_test)\n", "probing input new": " def forward(self, x_train, y_train, x_test):\n \n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(x_train.size(0)) \\\n + JITTER * torch.eye(x_train.size(0))\n \n kx = self.kernel(x_train, x_test)\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def forward(self, x_train, y_train, x_test):\n \n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(x_train.size(0)) \\\n + JITTER * torch.eye(x_train.size(0))\n \n kx = self.kernel(x_train, x_test)\n L = torch.linalg.cholesky(Sigma)\n LinvKx,_ = torch.triangular_solve(kx, L, upper = False)\n\n # option 1\n mean = kx.t() @ torch.cholesky_solve(y_train, L) # torch.linalg.cholesky()\n \n var = self.kernel(x_test, x_test) - LinvKx.t() @ LinvKx\n\n # add the noise uncertainty\n var = var + self.log_beta.exp().pow(-1)\n # if y_train_var is not None:\n # var = var + y_train_var.diag()* torch.eye(x_test.size(0))\n\n return mean, var" }, { "id": 8044, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def negative_log_likelihood(self, x_train, y_train):\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n y_num, y_dimension = y_train.shape\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * torch.eye(x_train.size(0))\n if y_train_var is not None:\n Sigma = Sigma + y_train_var.diag()* torch.eye(x_train.size(0))\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y_train, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return -nll", "probing input": " def negative_log_likelihood(self, x_train, y_train):\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n y_num, y_dimension = y_train.shape\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * torch.eye(x_train.size(0))\n if y_train_var is not None:\n Sigma = Sigma + y_train_var.diag()* torch.eye(x_train.size(0))\n", "probing input new": " def negative_log_likelihood(self, x_train, y_train):\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n y_num, y_dimension = y_train.shape\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * torch.eye(x_train.size(0))\n if y_train_var is not None:\n Sigma = Sigma + y_train_var.diag()* torch.eye(x_train.size(0))\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def negative_log_likelihood(self, x_train, y_train):\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n y_num, y_dimension = y_train.shape\n Sigma = self.kernel(x_train, x_train) + self.log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * torch.eye(x_train.size(0))\n if y_train_var is not None:\n Sigma = Sigma + y_train_var.diag()* torch.eye(x_train.size(0))\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y_train, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return -nll" }, { "id": 8046, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_log_prob(self):\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n # check that logprob values match scipy logpdf,\n # and that covariance and scale_tril parameters are equivalent\n dist1 = MultivariateNormal(mean, cov)\n dist2 = MultivariateNormal(mean, precision_matrix=prec)\n dist3 = MultivariateNormal(mean, scale_tril=scale_tril)\n ref_dist = scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy())\n\n x = dist1.sample((10,))\n expected = ref_dist.logpdf(x.numpy())\n\n self.assertEqual(0.0, np.mean((dist1.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n self.assertEqual(0.0, np.mean((dist2.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n self.assertEqual(0.0, np.mean((dist3.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n\n # Double-check that batched versions behave the same as unbatched\n mean = torch.randn(5, 3, requires_grad=True)\n tmp = torch.randn(5, 3, 10)\n cov = (tmp.unsqueeze(-2) * tmp.unsqueeze(-3)).mean(-1).requires_grad_()\n\n dist_batched = MultivariateNormal(mean, cov)\n dist_unbatched = [MultivariateNormal(mean[i], cov[i]) for i in range(mean.size(0))]\n\n x = dist_batched.sample((10,))\n batched_prob = dist_batched.log_prob(x)\n unbatched_prob = torch.stack([dist_unbatched[i].log_prob(x[:, i]) for i in range(5)]).t()\n\n self.assertEqual(batched_prob.shape, unbatched_prob.shape)\n self.assertEqual(0.0, (batched_prob - unbatched_prob).abs().max(), atol=1e-3, rtol=0)", "probing input": " def test_multivariate_normal_log_prob(self):\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n", "probing input new": " def test_multivariate_normal_log_prob(self):\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "reference dict": { "dist1": "MultivariateNormal", "dist2": "MultivariateNormal", "dist3": "MultivariateNormal", "dist_batched": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "y_neg": " scale_tril = torch.cholesky(prec)", "retain": " def test_multivariate_normal_log_prob(self):\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n # check that logprob values match scipy logpdf,\n # and that covariance and scale_tril parameters are equivalent\n dist1 = MultivariateNormal(mean, cov)\n dist2 = MultivariateNormal(mean, precision_matrix=prec)\n dist3 = MultivariateNormal(mean, scale_tril=scale_tril)\n ref_dist = scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy())\n\n x = dist1.sample((10,))\n expected = ref_dist.logpdf(x.numpy())\n\n self.assertEqual(0.0, np.mean((dist1.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n self.assertEqual(0.0, np.mean((dist2.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n self.assertEqual(0.0, np.mean((dist3.log_prob(x).detach().numpy() - expected)**2), atol=1e-3, rtol=0)\n\n # Double-check that batched versions behave the same as unbatched\n mean = torch.randn(5, 3, requires_grad=True)\n tmp = torch.randn(5, 3, 10)\n cov = (tmp.unsqueeze(-2) * tmp.unsqueeze(-3)).mean(-1).requires_grad_()\n\n dist_batched = MultivariateNormal(mean, cov)\n dist_unbatched = [MultivariateNormal(mean[i], cov[i]) for i in range(mean.size(0))]\n\n x = dist_batched.sample((10,))\n batched_prob = dist_batched.log_prob(x)\n unbatched_prob = torch.stack([dist_unbatched[i].log_prob(x[:, i]) for i in range(5)]).t()\n\n self.assertEqual(batched_prob.shape, unbatched_prob.shape)\n self.assertEqual(0.0, (batched_prob - unbatched_prob).abs().max(), atol=1e-3, rtol=0)" }, { "id": 8047, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n self._check_sampler_sampler(MultivariateNormal(mean, cov),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, cov={})'.format(mean, cov),\n multivariate=True)\n self._check_sampler_sampler(MultivariateNormal(mean, precision_matrix=prec),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, atol={})'.format(mean, prec),\n multivariate=True)\n self._check_sampler_sampler(MultivariateNormal(mean, scale_tril=scale_tril),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, scale_tril={})'.format(mean, scale_tril),\n multivariate=True)", "probing input": " def test_multivariate_normal_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n", "probing input new": " def test_multivariate_normal_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "y_neg": " scale_tril = torch.cholesky(prec)", "retain": " def test_multivariate_normal_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n mean = torch.randn(3, requires_grad=True)\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n self._check_sampler_sampler(MultivariateNormal(mean, cov),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, cov={})'.format(mean, cov),\n multivariate=True)\n self._check_sampler_sampler(MultivariateNormal(mean, precision_matrix=prec),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, atol={})'.format(mean, prec),\n multivariate=True)\n self._check_sampler_sampler(MultivariateNormal(mean, scale_tril=scale_tril),\n scipy.stats.multivariate_normal(mean.detach().numpy(), cov.detach().numpy()),\n 'MultivariateNormal(loc={}, scale_tril={})'.format(mean, scale_tril),\n multivariate=True)" }, { "id": 8048, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))", "probing input": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n", "probing input new": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.", "reference": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "reference dict": { "m": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "y_neg": " self.assertEqual(m.scale_tril, torch.cholesky(m.scale_tril + m.precision_diag.unsqueeze(0) * torch.eye(m.event_shape[0])))", "retain": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))" }, { "id": 8051, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_wishart_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n df = (torch.rand([], requires_grad=True) + 1) * 3\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n self._check_sampler_sampler(Wishart(df, cov),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, covariance_matrix={})'.format(df, cov),\n multivariate=True)\n self._check_sampler_sampler(Wishart(df, precision_matrix=prec),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, precision_matrix={})'.format(df, prec),\n multivariate=True)\n self._check_sampler_sampler(Wishart(df, scale_tril=scale_tril),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, scale_tril={})'.format(df, scale_tril),\n multivariate=True)", "probing input": " def test_wishart_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n df = (torch.rand([], requires_grad=True) + 1) * 3\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n", "probing input new": " def test_wishart_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n df = (torch.rand([], requires_grad=True) + 1) * 3\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(cov).requires_grad_()", "y_neg": " scale_tril = torch.cholesky(prec)", "retain": " def test_wishart_sample(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n df = (torch.rand([], requires_grad=True) + 1) * 3\n tmp = torch.randn(3, 10)\n cov = (torch.matmul(tmp, tmp.t()) / tmp.size(-1)).requires_grad_()\n prec = cov.inverse().requires_grad_()\n scale_tril = torch.linalg.cholesky(cov).requires_grad_()\n\n self._check_sampler_sampler(Wishart(df, cov),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, covariance_matrix={})'.format(df, cov),\n multivariate=True)\n self._check_sampler_sampler(Wishart(df, precision_matrix=prec),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, precision_matrix={})'.format(df, prec),\n multivariate=True)\n self._check_sampler_sampler(Wishart(df, scale_tril=scale_tril),\n scipy.stats.wishart(df.item(), cov.detach().numpy()),\n 'Wishart(df={}, scale_tril={})'.format(df, scale_tril),\n multivariate=True)" }, { "id": 8052, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_wishart_properties(self):\n df = (torch.rand([]) + 1) * 5\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))", "probing input": " def test_wishart_properties(self):\n df = (torch.rand([]) + 1) * 5\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n", "probing input new": " def test_wishart_properties(self):\n df = (torch.rand([]) + 1) * 5\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.", "reference": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "reference dict": { "m": "Wishart" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "y_neg": " self.assertEqual(m.scale_tril, torch.cholesky(m.precision_matrix))", "retain": " def test_wishart_properties(self):\n df = (torch.rand([]) + 1) * 5\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0]))\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))" }, { "id": 8054, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def decompose_C(self) -> None:\n \"\"\"Perform the decomposition C = AA^T using a cholesky decomposition\n Note that traditionally CMA-ES uses the eigendecomposition C = BDDB^-1. In our case,\n we keep track of zs, ys and xs when sampling, so we never need C^-1/2.\n Therefore, a cholesky decomposition is all that is necessary. This generally requires\n O(d^3/3) operations, rather than the more costly O(d^3) operations associated with the eigendecomposition.\n \"\"\"\n if self.separable:\n self.A = self.C.pow(0.5)\n else:\n self.A = torch.linalg.cholesky(self.C)", "probing input": " def decompose_C(self) -> None:\n \"\"\"Perform the decomposition C = AA^T using a cholesky decomposition\n Note that traditionally CMA-ES uses the eigendecomposition C = BDDB^-1. In our case,\n we keep track of zs, ys and xs when sampling, so we never need C^-1/2.\n Therefore, a cholesky decomposition is all that is necessary. This generally requires\n O(d^3/3) operations, rather than the more costly O(d^3) operations associated with the eigendecomposition.\n \"\"\"\n if self.separable:\n self.A = self.C.pow(0.5)\n else:\n", "probing input new": " def decompose_C(self) -> None:\n \"\"\"Perform the decomposition C = AA^T using a cholesky decomposition\n Note that traditionally CMA-ES uses the eigendecomposition C = BDDB^-1. In our case,\n we keep track of zs, ys and xs when sampling, so we never need C^-1/2.\n Therefore, a cholesky decomposition is all that is necessary. This generally requires\n O(d^3/3) operations, rather than the more costly O(d^3) operations associated with the eigendecomposition.\n \"\"\"\n if self.separable:\n self.A = self.C.pow(0.5)\n else:\n self.A = torch.", "reference": "self.A=torch.linalg.cholesky(self.C)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.A=torch.linalg.cholesky(self.C)", "y_neg": " self.A = torch.cholesky(self.C)", "retain": " def decompose_C(self) -> None:\n \"\"\"Perform the decomposition C = AA^T using a cholesky decomposition\n Note that traditionally CMA-ES uses the eigendecomposition C = BDDB^-1. In our case,\n we keep track of zs, ys and xs when sampling, so we never need C^-1/2.\n Therefore, a cholesky decomposition is all that is necessary. This generally requires\n O(d^3/3) operations, rather than the more costly O(d^3) operations associated with the eigendecomposition.\n \"\"\"\n if self.separable:\n self.A = self.C.pow(0.5)\n else:\n self.A = torch.linalg.cholesky(self.C)" }, { "id": 8056, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def SigmatoH(Sigmas):\n \"\"\"\n Transform covariance matrices into logCholesky factors\n\n Inputs:\n Sigmas : (K,D,D,B) array, B observations of the K cluster covariances\n\n Outpus:\n Hs : (K,D,D,B) array, B observations of the K cluster logCholesky factors\n \"\"\"\n\n idx=np.diag_indices(Sigmas.shape[1])\n Ls=torch.linalg.cholesky(torch.moveaxis(Sigmas,3,1))\n Hs=torch.clone(Ls)\n Hs[:,:,idx[0],idx[1]]=torch.log(Ls[:,:,idx[0],idx[1]])\n return torch.moveaxis(Hs,1,3)", "probing input": "def SigmatoH(Sigmas):\n \"\"\"\n Transform covariance matrices into logCholesky factors\n\n Inputs:\n Sigmas : (K,D,D,B) array, B observations of the K cluster covariances\n\n Outpus:\n Hs : (K,D,D,B) array, B observations of the K cluster logCholesky factors\n \"\"\"\n\n idx=np.diag_indices(Sigmas.shape[1])\n", "probing input new": "def SigmatoH(Sigmas):\n \"\"\"\n Transform covariance matrices into logCholesky factors\n\n Inputs:\n Sigmas : (K,D,D,B) array, B observations of the K cluster covariances\n\n Outpus:\n Hs : (K,D,D,B) array, B observations of the K cluster logCholesky factors\n \"\"\"\n\n idx=np.diag_indices(Sigmas.shape[1])\n Ls=torch.", "reference": "Ls=torch.linalg.cholesky(torch.moveaxis(Sigmas,3,1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Ls=torch.linalg.cholesky(torch.moveaxis(Sigmas,3,1))", "y_neg": " Ls=torch.cholesky(Sigmas)", "retain": "def SigmatoH(Sigmas):\n \"\"\"\n Transform covariance matrices into logCholesky factors\n\n Inputs:\n Sigmas : (K,D,D,B) array, B observations of the K cluster covariances\n\n Outpus:\n Hs : (K,D,D,B) array, B observations of the K cluster logCholesky factors\n \"\"\"\n\n idx=np.diag_indices(Sigmas.shape[1])\n Ls=torch.linalg.cholesky(torch.moveaxis(Sigmas,3,1))\n Hs=torch.clone(Ls)\n Hs[:,:,idx[0],idx[1]]=torch.log(Ls[:,:,idx[0],idx[1]])\n return torch.moveaxis(Hs,1,3)" }, { "id": 8061, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def make_munu(self, *args, **kwargs):\n\n # *** targets ***\n energies, forces = [], []\n atom_types = set()\n # for dummy atom type Z\n atom_counts = torch.zeros(len(self.data), 120)\n for i, atoms in enumerate(self.data):\n for z, c in atoms.counts().items():\n atom_types.add(z)\n atom_counts[i, z] = c\n energies.append(atoms.target_energy.view(-1))\n forces.append(atoms.target_forces.view(-1))\n energies = torch.cat(energies)\n forces = torch.cat(forces)\n targets = torch.cat([energies, forces])\n size = targets.numel()\n atom_types = sorted(atom_types)\n\n # *** kernel matrices ***\n # main block:\n kern_1 = torch.cat([self.Ke, self.Kf])\n\n # Constant-energy-shift block:\n ntypes = len(atom_types)\n ke_shift = atom_counts[:, atom_types]\n kf_shift = torch.zeros(self.Kf.size(0), ntypes)\n kern_2 = torch.cat([ke_shift, kf_shift])\n\n # patch all blocks:\n kern = torch.cat([kern_1, kern_2], dim=1)\n\n # *** legacy stuff ***\n sigma = 0.01\n self.scaled_noise = {\"all\": sigma}\n chol = torch.linalg.cholesky(self.M)\n self.ridge = torch.tensor(0.0)\n self.choli = chol.inverse().contiguous()\n self.Mi = self.choli.t() @ self.choli\n chol_size = chol.size(0)\n self.mean._weight = {}\n self.mean.weights = {}\n\n # *** sgpr extensions ***\n sgpr = True\n if sgpr:\n _kern_1 = sigma * chol.t()\n _kern_2 = torch.zeros(chol_size, ntypes)\n _kern = torch.cat([_kern_1, _kern_2], dim=1)\n kern = torch.cat([kern, _kern])\n _targets = torch.zeros(self.tasks * chol_size)\n targets = torch.cat([targets, _targets])\n\n # *** tasks kernel ***\n # covariance between tasks:\n # in principle this should be optimized as a hyper parameter.\n # for now we set it equal to correlation of forces in different\n # tasks.\n\n \"\"\"\n As the optimization of the intertask correlations is time-consuming,\n an alternative is to (acvtively) optimize the intertask correlations over the course of the simulation.\n \"\"\"\n if self.tasks_kern_optimization is True:\n # self.tasks_kern_L = torch.eye(self.tasks)\n # self.tasks_kern_L += 1e-2\n\n # decoupled optimizer for mu and W\n # 1. Initial weights \\mu optimization ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n\n for i, _ in enumerate(range(self.niter_tasks)):\n # 2. Inter-task kernel W=L@L.T optimization ***\n x1 = self.tasks_kern_L[0][0].item()\n x2 = self.tasks_kern_L[1][0].item()\n x3 = self.tasks_kern_L[1][1].item()\n res = minimize(\n optimize_task_kern_twobytwo,\n [x1, x2, x3],\n args=(kern, solution, targets),\n )\n self.tasks_kern_L[0][0] = res.x[0]\n self.tasks_kern_L[1][0] = res.x[1]\n self.tasks_kern_L[1][1] = res.x[2]\n self.tasks_kern = self.tasks_kern_L @ self.tasks_kern_L.T\n\n # 3. Re-optimization of weights \\mu based on an updated W ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n # print(f'{i} Optimized tasks corrs: {self.tasks_kern}, Lower: {self.tasks_kern_L}, error: {res.fun}')\n else:\n # for predetermined tasks corr\n # self.tasks_kern = tasks_correlation(forces.view(self.tasks,-1),corr_coef='pearson')\n self.tasks_kern = torch.eye(self.tasks)\n\n # for independent tasks, set:\n # self.tasks_kern = torch.eye(self.tasks)\n # a small ridge maybe needed in case tasks are identical:\n # self.tasks_kern += torch.eye(self.tasks) * 1e-1\n\n # np corr\n # import numpy as np\n # self.tasks_kern = np.corrcoef(forces.view(-1, self.tasks)[:,0], forces.view(-1, self.tasks)[:,1])\n # self.tasks_kern = torch.from_numpy(self.tasks_kern)\n\n # *** solution ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n\n # *** stats ***\n # TODO: per-task vscales?\n split = chol_size * self.tasks\n self.mu = solution[:split].reshape(-1, self.tasks)\n self.make_stats((targets[:size], predictions[:size]))", "probing input": " def make_munu(self, *args, **kwargs):\n\n # *** targets ***\n energies, forces = [], []\n atom_types = set()\n # for dummy atom type Z\n atom_counts = torch.zeros(len(self.data), 120)\n for i, atoms in enumerate(self.data):\n for z, c in atoms.counts().items():\n atom_types.add(z)\n atom_counts[i, z] = c\n energies.append(atoms.target_energy.view(-1))\n forces.append(atoms.target_forces.view(-1))\n energies = torch.cat(energies)\n forces = torch.cat(forces)\n targets = torch.cat([energies, forces])\n size = targets.numel()\n atom_types = sorted(atom_types)\n\n # *** kernel matrices ***\n # main block:\n kern_1 = torch.cat([self.Ke, self.Kf])\n\n # Constant-energy-shift block:\n ntypes = len(atom_types)\n ke_shift = atom_counts[:, atom_types]\n kf_shift = torch.zeros(self.Kf.size(0), ntypes)\n kern_2 = torch.cat([ke_shift, kf_shift])\n\n # patch all blocks:\n kern = torch.cat([kern_1, kern_2], dim=1)\n\n # *** legacy stuff ***\n sigma = 0.01\n self.scaled_noise = {\"all\": sigma}\n", "probing input new": " def make_munu(self, *args, **kwargs):\n\n # *** targets ***\n energies, forces = [], []\n atom_types = set()\n # for dummy atom type Z\n atom_counts = torch.zeros(len(self.data), 120)\n for i, atoms in enumerate(self.data):\n for z, c in atoms.counts().items():\n atom_types.add(z)\n atom_counts[i, z] = c\n energies.append(atoms.target_energy.view(-1))\n forces.append(atoms.target_forces.view(-1))\n energies = torch.cat(energies)\n forces = torch.cat(forces)\n targets = torch.cat([energies, forces])\n size = targets.numel()\n atom_types = sorted(atom_types)\n\n # *** kernel matrices ***\n # main block:\n kern_1 = torch.cat([self.Ke, self.Kf])\n\n # Constant-energy-shift block:\n ntypes = len(atom_types)\n ke_shift = atom_counts[:, atom_types]\n kf_shift = torch.zeros(self.Kf.size(0), ntypes)\n kern_2 = torch.cat([ke_shift, kf_shift])\n\n # patch all blocks:\n kern = torch.cat([kern_1, kern_2], dim=1)\n\n # *** legacy stuff ***\n sigma = 0.01\n self.scaled_noise = {\"all\": sigma}\n chol = torch.", "reference": "chol=torch.linalg.cholesky(self.M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(self.M)", "y_neg": " chol = torch.cholesky(kern + sigma * torch.eye(size))", "retain": " def make_munu(self, *args, **kwargs):\n\n # *** targets ***\n energies, forces = [], []\n atom_types = set()\n # for dummy atom type Z\n atom_counts = torch.zeros(len(self.data), 120)\n for i, atoms in enumerate(self.data):\n for z, c in atoms.counts().items():\n atom_types.add(z)\n atom_counts[i, z] = c\n energies.append(atoms.target_energy.view(-1))\n forces.append(atoms.target_forces.view(-1))\n energies = torch.cat(energies)\n forces = torch.cat(forces)\n targets = torch.cat([energies, forces])\n size = targets.numel()\n atom_types = sorted(atom_types)\n\n # *** kernel matrices ***\n # main block:\n kern_1 = torch.cat([self.Ke, self.Kf])\n\n # Constant-energy-shift block:\n ntypes = len(atom_types)\n ke_shift = atom_counts[:, atom_types]\n kf_shift = torch.zeros(self.Kf.size(0), ntypes)\n kern_2 = torch.cat([ke_shift, kf_shift])\n\n # patch all blocks:\n kern = torch.cat([kern_1, kern_2], dim=1)\n\n # *** legacy stuff ***\n sigma = 0.01\n self.scaled_noise = {\"all\": sigma}\n chol = torch.linalg.cholesky(self.M)\n self.ridge = torch.tensor(0.0)\n self.choli = chol.inverse().contiguous()\n self.Mi = self.choli.t() @ self.choli\n chol_size = chol.size(0)\n self.mean._weight = {}\n self.mean.weights = {}\n\n # *** sgpr extensions ***\n sgpr = True\n if sgpr:\n _kern_1 = sigma * chol.t()\n _kern_2 = torch.zeros(chol_size, ntypes)\n _kern = torch.cat([_kern_1, _kern_2], dim=1)\n kern = torch.cat([kern, _kern])\n _targets = torch.zeros(self.tasks * chol_size)\n targets = torch.cat([targets, _targets])\n\n # *** tasks kernel ***\n # covariance between tasks:\n # in principle this should be optimized as a hyper parameter.\n # for now we set it equal to correlation of forces in different\n # tasks.\n\n \"\"\"\n As the optimization of the intertask correlations is time-consuming,\n an alternative is to (acvtively) optimize the intertask correlations over the course of the simulation.\n \"\"\"\n if self.tasks_kern_optimization is True:\n # self.tasks_kern_L = torch.eye(self.tasks)\n # self.tasks_kern_L += 1e-2\n\n # decoupled optimizer for mu and W\n # 1. Initial weights \\mu optimization ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n\n for i, _ in enumerate(range(self.niter_tasks)):\n # 2. Inter-task kernel W=L@L.T optimization ***\n x1 = self.tasks_kern_L[0][0].item()\n x2 = self.tasks_kern_L[1][0].item()\n x3 = self.tasks_kern_L[1][1].item()\n res = minimize(\n optimize_task_kern_twobytwo,\n [x1, x2, x3],\n args=(kern, solution, targets),\n )\n self.tasks_kern_L[0][0] = res.x[0]\n self.tasks_kern_L[1][0] = res.x[1]\n self.tasks_kern_L[1][1] = res.x[2]\n self.tasks_kern = self.tasks_kern_L @ self.tasks_kern_L.T\n\n # 3. Re-optimization of weights \\mu based on an updated W ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n # print(f'{i} Optimized tasks corrs: {self.tasks_kern}, Lower: {self.tasks_kern_L}, error: {res.fun}')\n else:\n # for predetermined tasks corr\n # self.tasks_kern = tasks_correlation(forces.view(self.tasks,-1),corr_coef='pearson')\n self.tasks_kern = torch.eye(self.tasks)\n\n # for independent tasks, set:\n # self.tasks_kern = torch.eye(self.tasks)\n # a small ridge maybe needed in case tasks are identical:\n # self.tasks_kern += torch.eye(self.tasks) * 1e-1\n\n # np corr\n # import numpy as np\n # self.tasks_kern = np.corrcoef(forces.view(-1, self.tasks)[:,0], forces.view(-1, self.tasks)[:,1])\n # self.tasks_kern = torch.from_numpy(self.tasks_kern)\n\n # *** solution ***\n design = torch.kron(kern, self.tasks_kern)\n solution, predictions = least_squares(design, targets, solver=self.algo)\n self.multi_mu = solution\n self.multi_types = {z: i for i, z in enumerate(atom_types)}\n\n # *** stats ***\n # TODO: per-task vscales?\n split = chol_size * self.tasks\n self.mu = solution[:split].reshape(-1, self.tasks)\n self.make_stats((targets[:size], predictions[:size]))" }, { "id": 8062, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, X):\n if self.param_type == \"scalar\":\n if self.q_shape is None:\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X)\n else:\n chol = self.post_process(self.q, self.param_type) * torch.linalg.cholesky(\n torch.exp(self.q_shape * self.base))\n X = X + torch.randn_like(X) @ chol.t()\n elif self.param_type == \"diag\":\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X) # (x_dim) * (*bs, N_ensem, x_dim)\n elif self.param_type == \"tril\":\n # batch_shape = X.shape[:-1]\n chol = self.post_process(self.q, self.param_type)\n X = X + torch.randn_like(X) @ chol.t() # (*bs, N_ensem, x_dim) @ (x_dim, x_dim)\n # X = X + torch.distributions.MultivariateNormal(torch.zeros(self.x_dim, device=self.q.device), scale_tril=chol).sample(batch_shape)\n elif self.param_type == \"full\":\n batch_shape = X.shape[:-1]\n chol = torch.linalg.cholesky(self.q)\n X = X + torch.distributions.MultivariateNormal(torch.zeros(self.x_dim, device=self.q.device),\n scale_tril=chol).sample(batch_shape) # (*bs, N_ensem, x_dim)\n return X", "probing input": " def forward(self, X):\n if self.param_type == \"scalar\":\n if self.q_shape is None:\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X)\n else:\n", "probing input new": " def forward(self, X):\n if self.param_type == \"scalar\":\n if self.q_shape is None:\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X)\n else:\n chol = self.post_process(self.q, self.param_type) * torch.", "reference": "chol=self.post_process(self.q,self.param_type)*torch.linalg.cholesky(torch.exp(self.q_shape*self.base))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=self.post_process(self.q,self.param_type)*torch.linalg.cholesky(torch.exp(self.q_shape*self.base))", "y_neg": " chol = self.post_process(self.q, self.param_type) * torch.cholesky(self.q)", "retain": " def forward(self, X):\n if self.param_type == \"scalar\":\n if self.q_shape is None:\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X)\n else:\n chol = self.post_process(self.q, self.param_type) * torch.linalg.cholesky(\n torch.exp(self.q_shape * self.base))\n X = X + torch.randn_like(X) @ chol.t()\n elif self.param_type == \"diag\":\n X = X + self.post_process(self.q, self.param_type) * torch.randn_like(X) # (x_dim) * (*bs, N_ensem, x_dim)\n elif self.param_type == \"tril\":\n # batch_shape = X.shape[:-1]\n chol = self.post_process(self.q, self.param_type)\n X = X + torch.randn_like(X) @ chol.t() # (*bs, N_ensem, x_dim) @ (x_dim, x_dim)\n # X = X + torch.distributions.MultivariateNormal(torch.zeros(self.x_dim, device=self.q.device), scale_tril=chol).sample(batch_shape)\n elif self.param_type == \"full\":\n batch_shape = X.shape[:-1]\n chol = torch.linalg.cholesky(self.q)\n X = X + torch.distributions.MultivariateNormal(torch.zeros(self.x_dim, device=self.q.device),\n scale_tril=chol).sample(batch_shape) # (*bs, N_ensem, x_dim)\n return X" }, { "id": 8065, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += cfg.epsilon * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma", "probing input": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n", "probing input new": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.", "reference": "chol=torch.linalg.cholesky(Covi)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(Covi)", "y_neg": " chol = torch.cholesky(Covi)", "retain": "def gmm(cfg,all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + cfg.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += cfg.epsilon * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma" }, { "id": 8066, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def cholesky_update(self, constmean: float, log_amp: float, log_beta: torch.FloatTensor,\n log_likelihood_noise: float):\n \"\"\"\n Function used to update the Cholesky matrix\n :param constmean\n :param log_amp:\n :param log_beta:\n :param log_likelihood_noise:\n :return:\n \"\"\"\n self.gram_mat_update(constmean, log_amp, log_beta, log_likelihood_noise)\n\n eye_mat = torch.diag(self.gram_mat.new_ones(self.gram_mat.size(0)))\n for jitter_const in [0, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:\n chol_jitter = torch.trace(self.gram_mat).item() * jitter_const\n try:\n # cholesky is lower triangular matrix\n self.cholesky = torch.linalg.cholesky(self.gram_mat + eye_mat * chol_jitter)\n self.jitter = chol_jitter\n return\n except RuntimeError:\n pass\n raise RuntimeError('Absolute entry values of Gram matrix are between %.4E~%.4E with trace %.4E' %\n (torch.min(torch.abs(self.gram_mat)).item(), torch.max(torch.abs(self.gram_mat)).item(),\n torch.trace(self.gram_mat).item()))", "probing input": " def cholesky_update(self, constmean: float, log_amp: float, log_beta: torch.FloatTensor,\n log_likelihood_noise: float):\n \"\"\"\n Function used to update the Cholesky matrix\n :param constmean\n :param log_amp:\n :param log_beta:\n :param log_likelihood_noise:\n :return:\n \"\"\"\n self.gram_mat_update(constmean, log_amp, log_beta, log_likelihood_noise)\n\n eye_mat = torch.diag(self.gram_mat.new_ones(self.gram_mat.size(0)))\n for jitter_const in [0, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:\n chol_jitter = torch.trace(self.gram_mat).item() * jitter_const\n try:\n # cholesky is lower triangular matrix\n", "probing input new": " def cholesky_update(self, constmean: float, log_amp: float, log_beta: torch.FloatTensor,\n log_likelihood_noise: float):\n \"\"\"\n Function used to update the Cholesky matrix\n :param constmean\n :param log_amp:\n :param log_beta:\n :param log_likelihood_noise:\n :return:\n \"\"\"\n self.gram_mat_update(constmean, log_amp, log_beta, log_likelihood_noise)\n\n eye_mat = torch.diag(self.gram_mat.new_ones(self.gram_mat.size(0)))\n for jitter_const in [0, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:\n chol_jitter = torch.trace(self.gram_mat).item() * jitter_const\n try:\n # cholesky is lower triangular matrix\n self.", "reference": "self.cholesky=torch.linalg.cholesky(self.gram_mat+eye_mat*chol_jitter)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.cholesky=torch.linalg.cholesky(self.gram_mat+eye_mat*chol_jitter)", "y_neg": " self.chol_mat = torch.cholesky(self.gram_mat - eye_mat + chol_jitter * eye_mat)", "retain": " def cholesky_update(self, constmean: float, log_amp: float, log_beta: torch.FloatTensor,\n log_likelihood_noise: float):\n \"\"\"\n Function used to update the Cholesky matrix\n :param constmean\n :param log_amp:\n :param log_beta:\n :param log_likelihood_noise:\n :return:\n \"\"\"\n self.gram_mat_update(constmean, log_amp, log_beta, log_likelihood_noise)\n\n eye_mat = torch.diag(self.gram_mat.new_ones(self.gram_mat.size(0)))\n for jitter_const in [0, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:\n chol_jitter = torch.trace(self.gram_mat).item() * jitter_const\n try:\n # cholesky is lower triangular matrix\n self.cholesky = torch.linalg.cholesky(self.gram_mat + eye_mat * chol_jitter)\n self.jitter = chol_jitter\n return\n except RuntimeError:\n pass\n raise RuntimeError('Absolute entry values of Gram matrix are between %.4E~%.4E with trace %.4E' %\n (torch.min(torch.abs(self.gram_mat)).item(), torch.max(torch.abs(self.gram_mat)).item(),\n torch.trace(self.gram_mat).item()))" }, { "id": 8069, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, H, b):\n # don't crash training if cholesky decomp fails\n try:\n U = torch.linalg.cholesky(H)\n xs = torch.cholesky_solve(b, U)\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n except Exception as e:\n print(e)\n ctx.failed = True\n xs = torch.zeros_like(b)\n\n return xs", "probing input": " def forward(ctx, H, b):\n # don't crash training if cholesky decomp fails\n try:\n", "probing input new": " def forward(ctx, H, b):\n # don't crash training if cholesky decomp fails\n try:\n U = torch.", "reference": "U=torch.linalg.cholesky(H)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "U=torch.linalg.cholesky(H)", "y_neg": " U = torch.cholesky(H)", "retain": " def forward(ctx, H, b):\n # don't crash training if cholesky decomp fails\n try:\n U = torch.linalg.cholesky(H)\n xs = torch.cholesky_solve(b, U)\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n except Exception as e:\n print(e)\n ctx.failed = True\n xs = torch.zeros_like(b)\n\n return xs" }, { "id": 8076, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() ==1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter \n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov", "probing input": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() ==1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter \n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n", "probing input new": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() ==1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter \n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() ==1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter \n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov" }, { "id": 8077, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def iter_sample(self, noiseless=True):\n r\"\"\"\n Iteratively constructs a sample from the Gaussian Process posterior.\n\n Recall that at test input points :math:`X_{new}`, the posterior is\n multivariate Gaussian distributed with mean and covariance matrix\n given by :func:`forward`.\n\n This method samples lazily from this multivariate Gaussian. The advantage\n of this approach is that later query points can depend upon earlier ones.\n Particularly useful when the querying is to be done by an optimisation\n routine.\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param bool noiseless: A flag to decide if we want to add sampling noise\n to the samples beyond the noise inherent in the GP posterior.\n :returns: sampler\n :rtype: function\n \"\"\"\n noise = self.noise.detach()\n X = self.X.clone().detach()\n y = self.y.clone().detach()\n N = X.size(0)\n Kff = self.kernel(X).contiguous()\n Kff.view(-1)[:: N + 1] += noise # add noise to the diagonal\n\n outside_vars = {\"X\": X, \"y\": y, \"N\": N, \"Kff\": Kff}\n\n def sample_next(xnew, outside_vars):\n \"\"\"Repeatedly samples from the Gaussian process posterior,\n conditioning on previously sampled values.\n \"\"\"\n warn_if_nan(xnew)\n\n # Variables from outer scope\n X, y, Kff = outside_vars[\"X\"], outside_vars[\"y\"], outside_vars[\"Kff\"]\n\n # Compute Cholesky decomposition of kernel matrix\n Lff = torch.linalg.cholesky(Kff)\n y_residual = y - self.mean_function(X)\n\n # Compute conditional mean and variance\n loc, cov = conditional(\n xnew, X, self.kernel, y_residual, None, Lff, False, jitter=self.jitter\n )\n if not noiseless:\n cov = cov + noise\n\n ynew = torchdist.Normal(\n loc + self.mean_function(xnew), cov.sqrt()\n ).rsample()\n\n # Update kernel matrix\n N = outside_vars[\"N\"]\n Kffnew = Kff.new_empty(N + 1, N + 1)\n Kffnew[:N, :N] = Kff\n cross = self.kernel(X, xnew).squeeze()\n end = self.kernel(xnew, xnew).squeeze()\n Kffnew[N, :N] = cross\n Kffnew[:N, N] = cross\n # No noise, just jitter for numerical stability\n Kffnew[N, N] = end + self.jitter\n # Heuristic to avoid adding degenerate points\n if Kffnew.logdet() > -15.0:\n outside_vars[\"Kff\"] = Kffnew\n outside_vars[\"N\"] += 1\n outside_vars[\"X\"] = torch.cat((X, xnew))\n outside_vars[\"y\"] = torch.cat((y, ynew))\n\n return ynew\n\n return lambda xnew: sample_next(xnew, outside_vars)", "probing input": " def iter_sample(self, noiseless=True):\n r\"\"\"\n Iteratively constructs a sample from the Gaussian Process posterior.\n\n Recall that at test input points :math:`X_{new}`, the posterior is\n multivariate Gaussian distributed with mean and covariance matrix\n given by :func:`forward`.\n\n This method samples lazily from this multivariate Gaussian. The advantage\n of this approach is that later query points can depend upon earlier ones.\n Particularly useful when the querying is to be done by an optimisation\n routine.\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param bool noiseless: A flag to decide if we want to add sampling noise\n to the samples beyond the noise inherent in the GP posterior.\n :returns: sampler\n :rtype: function\n \"\"\"\n noise = self.noise.detach()\n X = self.X.clone().detach()\n y = self.y.clone().detach()\n N = X.size(0)\n Kff = self.kernel(X).contiguous()\n Kff.view(-1)[:: N + 1] += noise # add noise to the diagonal\n\n outside_vars = {\"X\": X, \"y\": y, \"N\": N, \"Kff\": Kff}\n\n def sample_next(xnew, outside_vars):\n \"\"\"Repeatedly samples from the Gaussian process posterior,\n conditioning on previously sampled values.\n \"\"\"\n warn_if_nan(xnew)\n\n # Variables from outer scope\n X, y, Kff = outside_vars[\"X\"], outside_vars[\"y\"], outside_vars[\"Kff\"]\n\n # Compute Cholesky decomposition of kernel matrix\n", "probing input new": " def iter_sample(self, noiseless=True):\n r\"\"\"\n Iteratively constructs a sample from the Gaussian Process posterior.\n\n Recall that at test input points :math:`X_{new}`, the posterior is\n multivariate Gaussian distributed with mean and covariance matrix\n given by :func:`forward`.\n\n This method samples lazily from this multivariate Gaussian. The advantage\n of this approach is that later query points can depend upon earlier ones.\n Particularly useful when the querying is to be done by an optimisation\n routine.\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param bool noiseless: A flag to decide if we want to add sampling noise\n to the samples beyond the noise inherent in the GP posterior.\n :returns: sampler\n :rtype: function\n \"\"\"\n noise = self.noise.detach()\n X = self.X.clone().detach()\n y = self.y.clone().detach()\n N = X.size(0)\n Kff = self.kernel(X).contiguous()\n Kff.view(-1)[:: N + 1] += noise # add noise to the diagonal\n\n outside_vars = {\"X\": X, \"y\": y, \"N\": N, \"Kff\": Kff}\n\n def sample_next(xnew, outside_vars):\n \"\"\"Repeatedly samples from the Gaussian process posterior,\n conditioning on previously sampled values.\n \"\"\"\n warn_if_nan(xnew)\n\n # Variables from outer scope\n X, y, Kff = outside_vars[\"X\"], outside_vars[\"y\"], outside_vars[\"Kff\"]\n\n # Compute Cholesky decomposition of kernel matrix\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def iter_sample(self, noiseless=True):\n r\"\"\"\n Iteratively constructs a sample from the Gaussian Process posterior.\n\n Recall that at test input points :math:`X_{new}`, the posterior is\n multivariate Gaussian distributed with mean and covariance matrix\n given by :func:`forward`.\n\n This method samples lazily from this multivariate Gaussian. The advantage\n of this approach is that later query points can depend upon earlier ones.\n Particularly useful when the querying is to be done by an optimisation\n routine.\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param bool noiseless: A flag to decide if we want to add sampling noise\n to the samples beyond the noise inherent in the GP posterior.\n :returns: sampler\n :rtype: function\n \"\"\"\n noise = self.noise.detach()\n X = self.X.clone().detach()\n y = self.y.clone().detach()\n N = X.size(0)\n Kff = self.kernel(X).contiguous()\n Kff.view(-1)[:: N + 1] += noise # add noise to the diagonal\n\n outside_vars = {\"X\": X, \"y\": y, \"N\": N, \"Kff\": Kff}\n\n def sample_next(xnew, outside_vars):\n \"\"\"Repeatedly samples from the Gaussian process posterior,\n conditioning on previously sampled values.\n \"\"\"\n warn_if_nan(xnew)\n\n # Variables from outer scope\n X, y, Kff = outside_vars[\"X\"], outside_vars[\"y\"], outside_vars[\"Kff\"]\n\n # Compute Cholesky decomposition of kernel matrix\n Lff = torch.linalg.cholesky(Kff)\n y_residual = y - self.mean_function(X)\n\n # Compute conditional mean and variance\n loc, cov = conditional(\n xnew, X, self.kernel, y_residual, None, Lff, False, jitter=self.jitter\n )\n if not noiseless:\n cov = cov + noise\n\n ynew = torchdist.Normal(\n loc + self.mean_function(xnew), cov.sqrt()\n ).rsample()\n\n # Update kernel matrix\n N = outside_vars[\"N\"]\n Kffnew = Kff.new_empty(N + 1, N + 1)\n Kffnew[:N, :N] = Kff\n cross = self.kernel(X, xnew).squeeze()\n end = self.kernel(xnew, xnew).squeeze()\n Kffnew[N, :N] = cross\n Kffnew[:N, N] = cross\n # No noise, just jitter for numerical stability\n Kffnew[N, N] = end + self.jitter\n # Heuristic to avoid adding degenerate points\n if Kffnew.logdet() > -15.0:\n outside_vars[\"Kff\"] = Kffnew\n outside_vars[\"N\"] += 1\n outside_vars[\"X\"] = torch.cat((X, xnew))\n outside_vars[\"y\"] = torch.cat((y, ynew))\n\n return ynew\n\n return lambda xnew: sample_next(xnew, outside_vars)" }, { "id": 8078, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def model(self):\n self.set_mode(\"model\")\n N = self.X.size(0)\n x_noise = pyro.sample('obs',dist.Normal(torch.zeros(N),self.xerr**0.5).to_event(1))\n if self.X.dim()<=1:\n X_noisy = (self.X+x_noise)\n else:\n X_noisy = self.X\n X_noisy[:,0] += x_noise\n \n Kff = self.kernel(X_noisy)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.linalg.cholesky(Kff)\n zero_loc = X_noisy.new_zeros(X_noisy.size(0))\n f_loc = zero_loc + self.mean_function(X_noisy)\n if self.y is None:\n f_var = Lff.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.MultivariateNormal(f_loc, scale_tril=Lff)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )", "probing input": " def model(self):\n self.set_mode(\"model\")\n N = self.X.size(0)\n x_noise = pyro.sample('obs',dist.Normal(torch.zeros(N),self.xerr**0.5).to_event(1))\n if self.X.dim()<=1:\n X_noisy = (self.X+x_noise)\n else:\n X_noisy = self.X\n X_noisy[:,0] += x_noise\n \n Kff = self.kernel(X_noisy)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n", "probing input new": " def model(self):\n self.set_mode(\"model\")\n N = self.X.size(0)\n x_noise = pyro.sample('obs',dist.Normal(torch.zeros(N),self.xerr**0.5).to_event(1))\n if self.X.dim()<=1:\n X_noisy = (self.X+x_noise)\n else:\n X_noisy = self.X\n X_noisy[:,0] += x_noise\n \n Kff = self.kernel(X_noisy)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def model(self):\n self.set_mode(\"model\")\n N = self.X.size(0)\n x_noise = pyro.sample('obs',dist.Normal(torch.zeros(N),self.xerr**0.5).to_event(1))\n if self.X.dim()<=1:\n X_noisy = (self.X+x_noise)\n else:\n X_noisy = self.X\n X_noisy[:,0] += x_noise\n \n Kff = self.kernel(X_noisy)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.linalg.cholesky(Kff)\n zero_loc = X_noisy.new_zeros(X_noisy.size(0))\n f_loc = zero_loc + self.mean_function(X_noisy)\n if self.y is None:\n f_var = Lff.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.MultivariateNormal(f_loc, scale_tril=Lff)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )" }, { "id": 8079, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov", "probing input": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n", "probing input new": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov" }, { "id": 8080, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n Kff +=gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n \n output = []\n for kernel in kernels:\n Kfs = kernel(gpr.X, pred_matrix)\n pack = torch.cat((f_loc_2D, Kfs), dim=1)\n Lffinv_pack = pack.triangular_solve(Lff, upper=False)[0]\n W = Lffinv_pack[:, f_loc_2D.size(1):f_loc_2D.size(1) + M].t()\n Qss = W.matmul(W.t())\n v_2D = Lffinv_pack[:, :f_loc_2D.size(1)]\n loc = W.matmul(v_2D).t().reshape(loc_shape)\n Kss = kernel(pred_matrix)\n cov = Kss - Qss\n output.append((loc, cov))\n \n return output", "probing input": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n Kff +=gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter # add noise to the diagonal\n", "probing input new": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n Kff +=gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter # add noise to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n Kff +=gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n \n output = []\n for kernel in kernels:\n Kfs = kernel(gpr.X, pred_matrix)\n pack = torch.cat((f_loc_2D, Kfs), dim=1)\n Lffinv_pack = pack.triangular_solve(Lff, upper=False)[0]\n W = Lffinv_pack[:, f_loc_2D.size(1):f_loc_2D.size(1) + M].t()\n Qss = W.matmul(W.t())\n v_2D = Lffinv_pack[:, :f_loc_2D.size(1)]\n loc = W.matmul(v_2D).t().reshape(loc_shape)\n Kss = kernel(pred_matrix)\n cov = Kss - Qss\n output.append((loc, cov))\n \n return output" }, { "id": 8082, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def covs_to_prec(covs):\n cov_chol = torch.linalg.cholesky(covs)\n Id = torch.eye(covs.shape[-1], dtype=covs.dtype, device=covs.device)\n prec_chol = torch.linalg.solve_triangular(cov_chol, Id, upper=False)\n return prec_chol.transpose(-1, -2)", "probing input": "def covs_to_prec(covs):\n", "probing input new": "def covs_to_prec(covs):\n cov_chol = torch.", "reference": "cov_chol=torch.linalg.cholesky(covs)", "reference dict": { "GaussianParams": "NamedTuple" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "cov_chol=torch.linalg.cholesky(covs)", "y_neg": " cov_chol = torch.cholesky(covs)", "retain": "def covs_to_prec(covs):\n cov_chol = torch.linalg.cholesky(covs)\n Id = torch.eye(covs.shape[-1], dtype=covs.dtype, device=covs.device)\n prec_chol = torch.linalg.solve_triangular(cov_chol, Id, upper=False)\n return prec_chol.transpose(-1, -2)" }, { "id": 8085, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cholesky_errors_and_warnings(self, device, dtype):\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n # cholesky requires the input to be a square matrix or batch of square matrices\n A = torch.randn(2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n torch.linalg.cholesky(A)\n A = torch.randn(2, 2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError, r'Last 2 dimensions of the array must be square'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # cholesky requires the input to be at least 2 dimensional tensor\n A = torch.randn(2, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must have at least 2 dimensions'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError,\n r'1-dimensional array given\\. Array must be at least two-dimensional'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # if the input matrix is singular, an error should be raised\n A = torch.eye(3, 3, dtype=dtype, device=device)\n A[-1, -1] = 0 # Now A is singular\n with self.assertRaisesRegex(RuntimeError, r'U\\(3,3\\) is zero, singular U\\.'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError, r'Matrix is not positive definite'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # if at least one matrix in the batch is singular, an error should be raised\n A = torch.eye(3, 3, dtype=dtype, device=device)\n A = A.reshape((1, 3, 3))\n A = A.repeat(5, 1, 1)\n A[4, -1, -1] = 0 # Now A[4] is singular\n with self.assertRaisesRegex(RuntimeError, r'For batch 4: U\\(3,3\\) is zero, singular U\\.'):\n torch.linalg.cholesky(A)\n\n # if out tensor with wrong shape is passed a warning is given\n A = random_hermitian_pd_matrix(3, dtype=dtype, device=device)\n out = torch.empty(2, 3, dtype=dtype, device=device)\n with warnings.catch_warnings(record=True) as w:\n # Trigger warning\n torch.linalg.cholesky(A, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # dtypes should match\n out = torch.empty_like(A).to(torch.int)\n with self.assertRaisesRegex(RuntimeError, \"result dtype Int does not match self dtype\"):\n torch.linalg.cholesky(A, out=out)", "probing input": " def test_cholesky_errors_and_warnings(self, device, dtype):\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n # cholesky requires the input to be a square matrix or batch of square matrices\n A = torch.randn(2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n", "probing input new": " def test_cholesky_errors_and_warnings(self, device, dtype):\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n # cholesky requires the input to be a square matrix or batch of square matrices\n A = torch.randn(2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n torch.", "reference": "torch.linalg.cholesky(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(A)", "y_neg": " torch.cholesky(A)", "retain": " def test_cholesky_errors_and_warnings(self, device, dtype):\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n # cholesky requires the input to be a square matrix or batch of square matrices\n A = torch.randn(2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n torch.linalg.cholesky(A)\n A = torch.randn(2, 2, 3, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must be batches of square matrices'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError, r'Last 2 dimensions of the array must be square'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # cholesky requires the input to be at least 2 dimensional tensor\n A = torch.randn(2, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, r'must have at least 2 dimensions'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError,\n r'1-dimensional array given\\. Array must be at least two-dimensional'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # if the input matrix is singular, an error should be raised\n A = torch.eye(3, 3, dtype=dtype, device=device)\n A[-1, -1] = 0 # Now A is singular\n with self.assertRaisesRegex(RuntimeError, r'U\\(3,3\\) is zero, singular U\\.'):\n torch.linalg.cholesky(A)\n with self.assertRaisesRegex(np.linalg.LinAlgError, r'Matrix is not positive definite'):\n np.linalg.cholesky(A.cpu().numpy())\n\n # if at least one matrix in the batch is singular, an error should be raised\n A = torch.eye(3, 3, dtype=dtype, device=device)\n A = A.reshape((1, 3, 3))\n A = A.repeat(5, 1, 1)\n A[4, -1, -1] = 0 # Now A[4] is singular\n with self.assertRaisesRegex(RuntimeError, r'For batch 4: U\\(3,3\\) is zero, singular U\\.'):\n torch.linalg.cholesky(A)\n\n # if out tensor with wrong shape is passed a warning is given\n A = random_hermitian_pd_matrix(3, dtype=dtype, device=device)\n out = torch.empty(2, 3, dtype=dtype, device=device)\n with warnings.catch_warnings(record=True) as w:\n # Trigger warning\n torch.linalg.cholesky(A, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # dtypes should match\n out = torch.empty_like(A).to(torch.int)\n with self.assertRaisesRegex(RuntimeError, \"result dtype Int does not match self dtype\"):\n torch.linalg.cholesky(A, out=out)" }, { "id": 8087, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "Xnew = torch.tensor([[2.0, 3.0], [4.0, 6.0]])\nX = torch.tensor([[1.0, 5.0], [2.0, 1.0], [3.0, 2.0]])\nkernel = Matern52(input_dim=2)\nKff = kernel(X) + torch.eye(3) * 1e-6\nLff = torch.linalg.cholesky(Kff)", "probing input": "Xnew = torch.tensor([[2.0, 3.0], [4.0, 6.0]])\nX = torch.tensor([[1.0, 5.0], [2.0, 1.0], [3.0, 2.0]])\nkernel = Matern52(input_dim=2)\nKff = kernel(X) + torch.eye(3) * 1e-6\n", "probing input new": "Xnew = torch.tensor([[2.0, 3.0], [4.0, 6.0]])\nX = torch.tensor([[1.0, 5.0], [2.0, 1.0], [3.0, 2.0]])\nkernel = Matern52(input_dim=2)\nKff = kernel(X) + torch.eye(3) * 1e-6\nLff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": { "kernel": "Matern52" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": "Lff = torch.cholesky(Kff)", "retain": "Xnew = torch.tensor([[2.0, 3.0], [4.0, 6.0]])\nX = torch.tensor([[1.0, 5.0], [2.0, 1.0], [3.0, 2.0]])\nkernel = Matern52(input_dim=2)\nKff = kernel(X) + torch.eye(3) * 1e-6\nLff = torch.linalg.cholesky(Kff)" }, { "id": 8088, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_conditional_whiten(Xnew, X, kernel, f_loc, f_scale_tril, loc, cov):\n if f_scale_tril is None:\n return\n\n loc0, cov0 = conditional(\n Xnew, X, kernel, f_loc, f_scale_tril, full_cov=True, whiten=False\n )\n Kff = kernel(X) + torch.eye(3) * 1e-6\n Lff = torch.linalg.cholesky(Kff)\n whiten_f_loc = Lff.inverse().matmul(f_loc)\n whiten_f_scale_tril = Lff.inverse().matmul(f_scale_tril)\n loc1, cov1 = conditional(\n Xnew, X, kernel, whiten_f_loc, whiten_f_scale_tril, full_cov=True, whiten=True\n )\n\n assert_equal(loc0, loc1)\n assert_equal(cov0, cov1)", "probing input": "def test_conditional_whiten(Xnew, X, kernel, f_loc, f_scale_tril, loc, cov):\n if f_scale_tril is None:\n return\n\n loc0, cov0 = conditional(\n Xnew, X, kernel, f_loc, f_scale_tril, full_cov=True, whiten=False\n )\n Kff = kernel(X) + torch.eye(3) * 1e-6\n", "probing input new": "def test_conditional_whiten(Xnew, X, kernel, f_loc, f_scale_tril, loc, cov):\n if f_scale_tril is None:\n return\n\n loc0, cov0 = conditional(\n Xnew, X, kernel, f_loc, f_scale_tril, full_cov=True, whiten=False\n )\n Kff = kernel(X) + torch.eye(3) * 1e-6\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": { "kernel": "Matern52" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": "def test_conditional_whiten(Xnew, X, kernel, f_loc, f_scale_tril, loc, cov):\n if f_scale_tril is None:\n return\n\n loc0, cov0 = conditional(\n Xnew, X, kernel, f_loc, f_scale_tril, full_cov=True, whiten=False\n )\n Kff = kernel(X) + torch.eye(3) * 1e-6\n Lff = torch.linalg.cholesky(Kff)\n whiten_f_loc = Lff.inverse().matmul(f_loc)\n whiten_f_scale_tril = Lff.inverse().matmul(f_scale_tril)\n loc1, cov1 = conditional(\n Xnew, X, kernel, whiten_f_loc, whiten_f_scale_tril, full_cov=True, whiten=True\n )\n\n assert_equal(loc0, loc1)\n assert_equal(cov0, cov1)" }, { "id": 8094, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def torch_reduction_matrix(sigma: Tensor, reduction_method=\"pseudo\"):\n import torch\n\n if reduction_method == \"cholesky\":\n C = torch.linalg.cholesky(sigma)\n return torch.linalg.inv(C.T)\n elif reduction_method == \"svd\":\n u, s, _ = torch.linalg.svd(sigma)\n return u @ torch.diag(torch.sqrt(1 / s))\n elif reduction_method == \"pseudo\" or reduction_method == \"pinv\":\n return torch.linalg.pinv(sigma)\n elif reduction_method == \"inverse\" or reduction_method == \"inv\":\n return torch.linalg.inv(sigma)\n else:\n raise ValueError(f\"Unknown reduction method {reduction_method}\")", "probing input": "def torch_reduction_matrix(sigma: Tensor, reduction_method=\"pseudo\"):\n import torch\n\n if reduction_method == \"cholesky\":\n", "probing input new": "def torch_reduction_matrix(sigma: Tensor, reduction_method=\"pseudo\"):\n import torch\n\n if reduction_method == \"cholesky\":\n C = torch.", "reference": "C=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "C=torch.linalg.cholesky(sigma)", "y_neg": " C = torch.cholesky(sigma)", "retain": "def torch_reduction_matrix(sigma: Tensor, reduction_method=\"pseudo\"):\n import torch\n\n if reduction_method == \"cholesky\":\n C = torch.linalg.cholesky(sigma)\n return torch.linalg.inv(C.T)\n elif reduction_method == \"svd\":\n u, s, _ = torch.linalg.svd(sigma)\n return u @ torch.diag(torch.sqrt(1 / s))\n elif reduction_method == \"pseudo\" or reduction_method == \"pinv\":\n return torch.linalg.pinv(sigma)\n elif reduction_method == \"inverse\" or reduction_method == \"inv\":\n return torch.linalg.inv(sigma)\n else:\n raise ValueError(f\"Unknown reduction method {reduction_method}\")" }, { "id": 8095, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def predictive_dist_exact(train_data, test_data, train_labels, noise_vars, kernel_fun):\n \"\"\"\n Heteroskedastic GP predictive distribution with the exact kernel.\n This function is used to compute the ground truth for KL divergence computation.\n\n train_data: Real-valued training inputs\n test_data: Real-valued test inputs\n train_labels: Real-valued training labels\n noise_vars: Heteroskedastic noise variances\n kernel_fun: callable k(X, Y)\n \"\"\"\n\n with torch.no_grad():\n k_xx = kernel_fun(train_data, train_data)\n k_xt = kernel_fun(train_data, test_data)\n k_tt = kernel_fun(test_data, test_data)\n\n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in tqdm(range(train_labels.shape[1])):\n train_labels_tmp = train_labels[:, out_dim].unsqueeze(1)\n c_xx = k_xx + noise_vars[:, out_dim].diag()\n # c_xx = (c_xx + c_xx.t()) / 2.\n L_xx = torch.linalg.cholesky(c_xx)\n L_X_t = torch.triangular_solve(k_xt, L_xx, upper=False)[0]\n\n f_test_mean_full[:, out_dim] = (k_xt.t() @ cholesky_solve(train_labels_tmp, L_xx)).view(-1)\n f_test_stds_full[:, out_dim] = k_tt.diagonal() - (L_X_t**2).sum(dim=0)\n f_test_stds_full[f_test_stds_full < 0] = 0\n f_test_stds_full = f_test_stds_full.sqrt()\n\n return f_test_mean_full, f_test_stds_full", "probing input": "def predictive_dist_exact(train_data, test_data, train_labels, noise_vars, kernel_fun):\n \"\"\"\n Heteroskedastic GP predictive distribution with the exact kernel.\n This function is used to compute the ground truth for KL divergence computation.\n\n train_data: Real-valued training inputs\n test_data: Real-valued test inputs\n train_labels: Real-valued training labels\n noise_vars: Heteroskedastic noise variances\n kernel_fun: callable k(X, Y)\n \"\"\"\n\n with torch.no_grad():\n k_xx = kernel_fun(train_data, train_data)\n k_xt = kernel_fun(train_data, test_data)\n k_tt = kernel_fun(test_data, test_data)\n\n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in tqdm(range(train_labels.shape[1])):\n train_labels_tmp = train_labels[:, out_dim].unsqueeze(1)\n c_xx = k_xx + noise_vars[:, out_dim].diag()\n # c_xx = (c_xx + c_xx.t()) / 2.\n", "probing input new": "def predictive_dist_exact(train_data, test_data, train_labels, noise_vars, kernel_fun):\n \"\"\"\n Heteroskedastic GP predictive distribution with the exact kernel.\n This function is used to compute the ground truth for KL divergence computation.\n\n train_data: Real-valued training inputs\n test_data: Real-valued test inputs\n train_labels: Real-valued training labels\n noise_vars: Heteroskedastic noise variances\n kernel_fun: callable k(X, Y)\n \"\"\"\n\n with torch.no_grad():\n k_xx = kernel_fun(train_data, train_data)\n k_xt = kernel_fun(train_data, test_data)\n k_tt = kernel_fun(test_data, test_data)\n\n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in tqdm(range(train_labels.shape[1])):\n train_labels_tmp = train_labels[:, out_dim].unsqueeze(1)\n c_xx = k_xx + noise_vars[:, out_dim].diag()\n # c_xx = (c_xx + c_xx.t()) / 2.\n L_xx = torch.", "reference": "L_xx=torch.linalg.cholesky(c_xx)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_xx=torch.linalg.cholesky(c_xx)", "y_neg": " L_xx = torch.cholesky(c_xx)", "retain": "def predictive_dist_exact(train_data, test_data, train_labels, noise_vars, kernel_fun):\n \"\"\"\n Heteroskedastic GP predictive distribution with the exact kernel.\n This function is used to compute the ground truth for KL divergence computation.\n\n train_data: Real-valued training inputs\n test_data: Real-valued test inputs\n train_labels: Real-valued training labels\n noise_vars: Heteroskedastic noise variances\n kernel_fun: callable k(X, Y)\n \"\"\"\n\n with torch.no_grad():\n k_xx = kernel_fun(train_data, train_data)\n k_xt = kernel_fun(train_data, test_data)\n k_tt = kernel_fun(test_data, test_data)\n\n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in tqdm(range(train_labels.shape[1])):\n train_labels_tmp = train_labels[:, out_dim].unsqueeze(1)\n c_xx = k_xx + noise_vars[:, out_dim].diag()\n # c_xx = (c_xx + c_xx.t()) / 2.\n L_xx = torch.linalg.cholesky(c_xx)\n L_X_t = torch.triangular_solve(k_xt, L_xx, upper=False)[0]\n\n f_test_mean_full[:, out_dim] = (k_xt.t() @ cholesky_solve(train_labels_tmp, L_xx)).view(-1)\n f_test_stds_full[:, out_dim] = k_tt.diagonal() - (L_X_t**2).sum(dim=0)\n f_test_stds_full[f_test_stds_full < 0] = 0\n f_test_stds_full = f_test_stds_full.sqrt()\n\n return f_test_mean_full, f_test_stds_full" }, { "id": 8096, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def predictive_dist(self, train_data, test_data, train_labels, noise_vars):\n with torch.no_grad():\n # step 1: extract random features (optional)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n test_features = self.feature_encoder.forward(test_data)\n else:\n train_features = train_data\n test_features = test_data\n\n if train_features.dtype in [torch.complex64, torch.complex128]:\n train_labels = train_labels.type(train_features.dtype)\n noise_vars = noise_vars.type(train_features.dtype)\n \n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n noise_var_tmp = noise_vars[:, out_dim].unsqueeze(1)\n # bottleneck (cannot be accelerated without using a lot of memory)\n sigma_inv = train_features.conj().t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=train_labels.device)\n xTy = train_features.conj().t() @ (y_tmp / noise_var_tmp)\n L_sigma_inv = torch.linalg.cholesky(sigma_inv)\n alpha = cholesky_solve(xTy, L_sigma_inv)\n\n f_test_mean = test_features @ alpha\n if f_test_mean.dtype in [torch.complex64, torch.complex128]:\n f_test_mean = f_test_mean.real\n # bottleneck (cannot be accelerated without using a lot of memory)\n L_sigma_X_t = torch.triangular_solve(test_features.conj().t(), L_sigma_inv, upper=False)[0]\n f_test_stds = L_sigma_X_t.t().norm(dim=-1)\n\n del sigma_inv, L_sigma_inv, xTy, L_sigma_X_t\n\n f_test_mean_full[:, out_dim] = f_test_mean.view(-1)\n f_test_stds_full[:, out_dim] = f_test_stds\n\n return f_test_mean_full, f_test_stds_full", "probing input": " def predictive_dist(self, train_data, test_data, train_labels, noise_vars):\n with torch.no_grad():\n # step 1: extract random features (optional)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n test_features = self.feature_encoder.forward(test_data)\n else:\n train_features = train_data\n test_features = test_data\n\n if train_features.dtype in [torch.complex64, torch.complex128]:\n train_labels = train_labels.type(train_features.dtype)\n noise_vars = noise_vars.type(train_features.dtype)\n \n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n noise_var_tmp = noise_vars[:, out_dim].unsqueeze(1)\n # bottleneck (cannot be accelerated without using a lot of memory)\n sigma_inv = train_features.conj().t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=train_labels.device)\n xTy = train_features.conj().t() @ (y_tmp / noise_var_tmp)\n", "probing input new": " def predictive_dist(self, train_data, test_data, train_labels, noise_vars):\n with torch.no_grad():\n # step 1: extract random features (optional)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n test_features = self.feature_encoder.forward(test_data)\n else:\n train_features = train_data\n test_features = test_data\n\n if train_features.dtype in [torch.complex64, torch.complex128]:\n train_labels = train_labels.type(train_features.dtype)\n noise_vars = noise_vars.type(train_features.dtype)\n \n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n noise_var_tmp = noise_vars[:, out_dim].unsqueeze(1)\n # bottleneck (cannot be accelerated without using a lot of memory)\n sigma_inv = train_features.conj().t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=train_labels.device)\n xTy = train_features.conj().t() @ (y_tmp / noise_var_tmp)\n L_sigma_inv = torch.", "reference": "L_sigma_inv=torch.linalg.cholesky(sigma_inv)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_sigma_inv=torch.linalg.cholesky(sigma_inv)", "y_neg": " L_sigma_inv = torch.cholesky(sigma_inv)", "retain": " def predictive_dist(self, train_data, test_data, train_labels, noise_vars):\n with torch.no_grad():\n # step 1: extract random features (optional)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n test_features = self.feature_encoder.forward(test_data)\n else:\n train_features = train_data\n test_features = test_data\n\n if train_features.dtype in [torch.complex64, torch.complex128]:\n train_labels = train_labels.type(train_features.dtype)\n noise_vars = noise_vars.type(train_features.dtype)\n \n f_test_mean_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n f_test_stds_full = torch.zeros(len(test_data), train_labels.shape[1], device=train_labels.device)\n\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n noise_var_tmp = noise_vars[:, out_dim].unsqueeze(1)\n # bottleneck (cannot be accelerated without using a lot of memory)\n sigma_inv = train_features.conj().t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=train_labels.device)\n xTy = train_features.conj().t() @ (y_tmp / noise_var_tmp)\n L_sigma_inv = torch.linalg.cholesky(sigma_inv)\n alpha = cholesky_solve(xTy, L_sigma_inv)\n\n f_test_mean = test_features @ alpha\n if f_test_mean.dtype in [torch.complex64, torch.complex128]:\n f_test_mean = f_test_mean.real\n # bottleneck (cannot be accelerated without using a lot of memory)\n L_sigma_X_t = torch.triangular_solve(test_features.conj().t(), L_sigma_inv, upper=False)[0]\n f_test_stds = L_sigma_X_t.t().norm(dim=-1)\n\n del sigma_inv, L_sigma_inv, xTy, L_sigma_X_t\n\n f_test_mean_full[:, out_dim] = f_test_mean.view(-1)\n f_test_stds_full[:, out_dim] = f_test_stds\n\n return f_test_mean_full, f_test_stds_full" }, { "id": 8097, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_marginal_likelihood(self, train_data, train_labels, log_noise_vars, heteroskedastic=False):\n \"\"\"\n Computes the log marginal likelihood on train_data.\n We assume 0 covariance between the individual heteroskedastic GPs.\n\n This function is only implemented for real-valued random features for now!\n\n train_data: training inputs\n train_labels: training labels\n log_noise_vars: (heteroskedastic) log noise variances\n heteroskedastic: whether the noise variances are heteroskedastic\n \"\"\"\n\n # step 1: feature extraction (to store gradients for kernel parameters)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n else:\n train_features = train_data\n\n # step 2: compute marginal log likelihood for every gp\n lml = 0\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n if heteroskedastic:\n noise_var_tmp = log_noise_vars[:, out_dim].exp().unsqueeze(1)\n else:\n noise_var_tmp = log_noise_vars.exp() * torch.ones_like(y_tmp)\n\n sigma_inv = train_features.t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=sigma_inv.device)\n L_sigma_inv = torch.linalg.cholesky(sigma_inv)\n xTy = train_features.t() @ (y_tmp / noise_var_tmp)\n q_inv_xTy = torch.triangular_solve(xTy, L_sigma_inv, upper=False)[0]\n\n lml += -0.5 * noise_var_tmp.log().sum() - L_sigma_inv.diagonal().log().sum()\n lml += -0.5 * (y_tmp * (y_tmp / noise_var_tmp)).sum()\n lml += 0.5 * q_inv_xTy.pow(2).sum()\n lml += -len(y_tmp) / 2 * np.log(2. * np.pi)\n\n return lml", "probing input": " def log_marginal_likelihood(self, train_data, train_labels, log_noise_vars, heteroskedastic=False):\n \"\"\"\n Computes the log marginal likelihood on train_data.\n We assume 0 covariance between the individual heteroskedastic GPs.\n\n This function is only implemented for real-valued random features for now!\n\n train_data: training inputs\n train_labels: training labels\n log_noise_vars: (heteroskedastic) log noise variances\n heteroskedastic: whether the noise variances are heteroskedastic\n \"\"\"\n\n # step 1: feature extraction (to store gradients for kernel parameters)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n else:\n train_features = train_data\n\n # step 2: compute marginal log likelihood for every gp\n lml = 0\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n if heteroskedastic:\n noise_var_tmp = log_noise_vars[:, out_dim].exp().unsqueeze(1)\n else:\n noise_var_tmp = log_noise_vars.exp() * torch.ones_like(y_tmp)\n\n sigma_inv = train_features.t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=sigma_inv.device)\n", "probing input new": " def log_marginal_likelihood(self, train_data, train_labels, log_noise_vars, heteroskedastic=False):\n \"\"\"\n Computes the log marginal likelihood on train_data.\n We assume 0 covariance between the individual heteroskedastic GPs.\n\n This function is only implemented for real-valued random features for now!\n\n train_data: training inputs\n train_labels: training labels\n log_noise_vars: (heteroskedastic) log noise variances\n heteroskedastic: whether the noise variances are heteroskedastic\n \"\"\"\n\n # step 1: feature extraction (to store gradients for kernel parameters)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n else:\n train_features = train_data\n\n # step 2: compute marginal log likelihood for every gp\n lml = 0\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n if heteroskedastic:\n noise_var_tmp = log_noise_vars[:, out_dim].exp().unsqueeze(1)\n else:\n noise_var_tmp = log_noise_vars.exp() * torch.ones_like(y_tmp)\n\n sigma_inv = train_features.t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=sigma_inv.device)\n L_sigma_inv = torch.", "reference": "L_sigma_inv=torch.linalg.cholesky(sigma_inv)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_sigma_inv=torch.linalg.cholesky(sigma_inv)", "y_neg": " L_sigma_inv = torch.cholesky(sigma_inv)", "retain": " def log_marginal_likelihood(self, train_data, train_labels, log_noise_vars, heteroskedastic=False):\n \"\"\"\n Computes the log marginal likelihood on train_data.\n We assume 0 covariance between the individual heteroskedastic GPs.\n\n This function is only implemented for real-valued random features for now!\n\n train_data: training inputs\n train_labels: training labels\n log_noise_vars: (heteroskedastic) log noise variances\n heteroskedastic: whether the noise variances are heteroskedastic\n \"\"\"\n\n # step 1: feature extraction (to store gradients for kernel parameters)\n if self.feature_encoder is not None:\n train_features = self.feature_encoder.forward(train_data)\n else:\n train_features = train_data\n\n # step 2: compute marginal log likelihood for every gp\n lml = 0\n for out_dim in range(train_labels.shape[1]):\n y_tmp = train_labels[:, out_dim].unsqueeze(1)\n if heteroskedastic:\n noise_var_tmp = log_noise_vars[:, out_dim].exp().unsqueeze(1)\n else:\n noise_var_tmp = log_noise_vars.exp() * torch.ones_like(y_tmp)\n\n sigma_inv = train_features.t() @ (train_features / noise_var_tmp)\n sigma_inv = sigma_inv + torch.eye(len(sigma_inv), device=sigma_inv.device)\n L_sigma_inv = torch.linalg.cholesky(sigma_inv)\n xTy = train_features.t() @ (y_tmp / noise_var_tmp)\n q_inv_xTy = torch.triangular_solve(xTy, L_sigma_inv, upper=False)[0]\n\n lml += -0.5 * noise_var_tmp.log().sum() - L_sigma_inv.diagonal().log().sum()\n lml += -0.5 * (y_tmp * (y_tmp / noise_var_tmp)).sum()\n lml += 0.5 * q_inv_xTy.pow(2).sum()\n lml += -len(y_tmp) / 2 * np.log(2. * np.pi)\n\n return lml" }, { "id": 8099, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def set_variances(self, var):\n self.var[:] = var\n if self.covariance_type == \"diag\":\n self.var_chol[:] = var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.linalg.cholesky(var)\n else:\n raise Exception(\"[GaussianMixture] __init__ got invalid covariance_type: {}\".format(self.covariance_type))\n self.gmm.covariances_ = var.detach().cpu().numpy()\n self.gmm.precisions_cholesky_ = torch.linalg.cholesky(torch.linalg.inv(var)).detach().cpu().numpy()", "probing input": " def set_variances(self, var):\n self.var[:] = var\n if self.covariance_type == \"diag\":\n self.var_chol[:] = var.sqrt()\n elif self.covariance_type == \"full\":\n", "probing input new": " def set_variances(self, var):\n self.var[:] = var\n if self.covariance_type == \"diag\":\n self.var_chol[:] = var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.", "reference": "self.var_chol[:]=torch.linalg.cholesky(var)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.var_chol[:]=torch.linalg.cholesky(var)", "y_neg": " self.var_chol[:] = torch.cholesky(self.var).diag()", "retain": " def set_variances(self, var):\n self.var[:] = var\n if self.covariance_type == \"diag\":\n self.var_chol[:] = var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.linalg.cholesky(var)\n else:\n raise Exception(\"[GaussianMixture] __init__ got invalid covariance_type: {}\".format(self.covariance_type))\n self.gmm.covariances_ = var.detach().cpu().numpy()\n self.gmm.precisions_cholesky_ = torch.linalg.cholesky(torch.linalg.inv(var)).detach().cpu().numpy()" }, { "id": 8100, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, x):\n x = x.cpu().numpy()\n self.gmm.fit(x)\n self.mu[:] = torch.tensor(self.gmm.means_, device=self.device, dtype=torch.float, requires_grad=False)\n self.var[:] = torch.tensor(self.gmm.covariances_, device=self.device, dtype=torch.float, requires_grad=False)\n self.pi[:] = torch.tensor(self.gmm.weights_, device=self.device, dtype=torch.float, requires_grad=False)\n if self.covariance_type == \"diag\":\n self.var_chol[:] = self.var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.linalg.cholesky(self.var)\n else:\n raise Exception(\"[GaussianMixture] __init__ got invalid covariance_type: {}\".format(self.covariance_type))", "probing input": " def fit(self, x):\n x = x.cpu().numpy()\n self.gmm.fit(x)\n self.mu[:] = torch.tensor(self.gmm.means_, device=self.device, dtype=torch.float, requires_grad=False)\n self.var[:] = torch.tensor(self.gmm.covariances_, device=self.device, dtype=torch.float, requires_grad=False)\n self.pi[:] = torch.tensor(self.gmm.weights_, device=self.device, dtype=torch.float, requires_grad=False)\n if self.covariance_type == \"diag\":\n self.var_chol[:] = self.var.sqrt()\n elif self.covariance_type == \"full\":\n", "probing input new": " def fit(self, x):\n x = x.cpu().numpy()\n self.gmm.fit(x)\n self.mu[:] = torch.tensor(self.gmm.means_, device=self.device, dtype=torch.float, requires_grad=False)\n self.var[:] = torch.tensor(self.gmm.covariances_, device=self.device, dtype=torch.float, requires_grad=False)\n self.pi[:] = torch.tensor(self.gmm.weights_, device=self.device, dtype=torch.float, requires_grad=False)\n if self.covariance_type == \"diag\":\n self.var_chol[:] = self.var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.", "reference": "self.var_chol[:]=torch.linalg.cholesky(self.var)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.var_chol[:]=torch.linalg.cholesky(self.var)", "y_neg": " self.var_chol[:] = torch.cholesky(self.var).cpu()", "retain": " def fit(self, x):\n x = x.cpu().numpy()\n self.gmm.fit(x)\n self.mu[:] = torch.tensor(self.gmm.means_, device=self.device, dtype=torch.float, requires_grad=False)\n self.var[:] = torch.tensor(self.gmm.covariances_, device=self.device, dtype=torch.float, requires_grad=False)\n self.pi[:] = torch.tensor(self.gmm.weights_, device=self.device, dtype=torch.float, requires_grad=False)\n if self.covariance_type == \"diag\":\n self.var_chol[:] = self.var.sqrt()\n elif self.covariance_type == \"full\":\n self.var_chol[:] = torch.linalg.cholesky(self.var)\n else:\n raise Exception(\"[GaussianMixture] __init__ got invalid covariance_type: {}\".format(self.covariance_type))" }, { "id": 8101, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _apply_non_linear_constraint_at_t( # noqa: WPS210, WPS231\n loc_t: Tensor, cov_t: Tensor, max_iter: int, tol: float, mode: InequalityConstraint\n):\n nx = loc_t.shape[0]\n eye = torch.eye(nx).to(loc_t.device)\n chol_t: Tensor = torch.linalg.cholesky(cov_t)\n chinv: Tensor = torch.linalg.solve_triangular(chol_t, eye, upper=False)\n chinv_loc_t = chinv.matmul(loc_t)\n if mode == \"nonneg\":\n a_matrix = chinv.numpy()\n b = chinv_loc_t.squeeze(-1).numpy()\n loc_t_np, _ = nnls(a_matrix, b)\n return torch.from_numpy(loc_t_np).unsqueeze(-1)\n if mode == \"monotone\":\n diff_matrix = _construct_diff_matrix(nx)\n diff_matrix_inv = np.linalg.inv(diff_matrix)\n a_matrix = np.matmul(chinv.numpy(), diff_matrix_inv)\n b = chinv_loc_t.squeeze(-1).numpy()\n loc_t_np_diff, _ = nnls(a_matrix, b)\n loc_t_np = np.matmul(diff_matrix_inv, loc_t_np_diff)\n return torch.from_numpy(loc_t_np).unsqueeze(-1)", "probing input": "def _apply_non_linear_constraint_at_t( # noqa: WPS210, WPS231\n loc_t: Tensor, cov_t: Tensor, max_iter: int, tol: float, mode: InequalityConstraint\n):\n nx = loc_t.shape[0]\n eye = torch.eye(nx).to(loc_t.device)\n", "probing input new": "def _apply_non_linear_constraint_at_t( # noqa: WPS210, WPS231\n loc_t: Tensor, cov_t: Tensor, max_iter: int, tol: float, mode: InequalityConstraint\n):\n nx = loc_t.shape[0]\n eye = torch.eye(nx).to(loc_t.device)\n chol_t: Tensor = torch.", "reference": "chol_t:Tensor=torch.linalg.cholesky(cov_t)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_t:Tensor=torch.linalg.cholesky(cov_t)", "y_neg": " chol_t: Tensor = torch.cholesky(cov_t)", "retain": "def _apply_non_linear_constraint_at_t( # noqa: WPS210, WPS231\n loc_t: Tensor, cov_t: Tensor, max_iter: int, tol: float, mode: InequalityConstraint\n):\n nx = loc_t.shape[0]\n eye = torch.eye(nx).to(loc_t.device)\n chol_t: Tensor = torch.linalg.cholesky(cov_t)\n chinv: Tensor = torch.linalg.solve_triangular(chol_t, eye, upper=False)\n chinv_loc_t = chinv.matmul(loc_t)\n if mode == \"nonneg\":\n a_matrix = chinv.numpy()\n b = chinv_loc_t.squeeze(-1).numpy()\n loc_t_np, _ = nnls(a_matrix, b)\n return torch.from_numpy(loc_t_np).unsqueeze(-1)\n if mode == \"monotone\":\n diff_matrix = _construct_diff_matrix(nx)\n diff_matrix_inv = np.linalg.inv(diff_matrix)\n a_matrix = np.matmul(chinv.numpy(), diff_matrix_inv)\n b = chinv_loc_t.squeeze(-1).numpy()\n loc_t_np_diff, _ = nnls(a_matrix, b)\n loc_t_np = np.matmul(diff_matrix_inv, loc_t_np_diff)\n return torch.from_numpy(loc_t_np).unsqueeze(-1)" }, { "id": 8103, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cholesky_hermitian_grad(self, device, dtype):\n # Check that the gradient is Hermitian (or symmetric)\n def run_test(shape):\n root = torch.rand(*shape, dtype=dtype, device=device)\n root = torch.matmul(root, root.transpose(-1, -2).conj())\n root.requires_grad_()\n chol = torch.linalg.cholesky(root).sum().backward()\n self.assertEqual(root.grad, root.grad.transpose(-1, -2).conj())\n\n shapes = ((3, 3), (1, 1, 3, 3))\n for shape in shapes:\n run_test(shape)", "probing input": " def test_cholesky_hermitian_grad(self, device, dtype):\n # Check that the gradient is Hermitian (or symmetric)\n def run_test(shape):\n root = torch.rand(*shape, dtype=dtype, device=device)\n root = torch.matmul(root, root.transpose(-1, -2).conj())\n root.requires_grad_()\n", "probing input new": " def test_cholesky_hermitian_grad(self, device, dtype):\n # Check that the gradient is Hermitian (or symmetric)\n def run_test(shape):\n root = torch.rand(*shape, dtype=dtype, device=device)\n root = torch.matmul(root, root.transpose(-1, -2).conj())\n root.requires_grad_()\n chol = torch.", "reference": "chol=torch.linalg.cholesky(root).sum().backward()", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(root).sum().backward()", "y_neg": " chol = torch.cholesky(root)", "retain": " def test_cholesky_hermitian_grad(self, device, dtype):\n # Check that the gradient is Hermitian (or symmetric)\n def run_test(shape):\n root = torch.rand(*shape, dtype=dtype, device=device)\n root = torch.matmul(root, root.transpose(-1, -2).conj())\n root.requires_grad_()\n chol = torch.linalg.cholesky(root).sum().backward()\n self.assertEqual(root.grad, root.grad.transpose(-1, -2).conj())\n\n shapes = ((3, 3), (1, 1, 3, 3))\n for shape in shapes:\n run_test(shape)" }, { "id": 8105, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n\t\"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n\tArgs:\n\t\t:attr:`A` (Tensor):\n\t\t\tThe tensor to compute the Cholesky decomposition of\n\t\t:attr:`upper` (bool, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`out` (Tensor, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`jitter` (float, optional):\n\t\t\tThe jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n\t\t\tas 1e-6 (float) or 1e-8 (double)\n\t\"\"\"\n\ttry:\n\t\tL = torch.linalg.cholesky(A, upper=upper, out=out)\n\t\treturn L\n\texcept RuntimeError as e:\n\t\tisnan = torch.isnan(A)\n\t\tif isnan.any():\n\t\t\traise NanError(\n\t\t\t\tf\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n\t\t\t)\n\n\t\tif jitter is None:\n\t\t\tjitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n\t\tAprime = A.clone()\n\t\tjitter_prev = 0\n\t\tfor i in range(10):\n\t\t\tjitter_new = jitter * (10 ** i)\n\t\t\tAprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n\t\t\tjitter_prev = jitter_new\n\t\t\ttry:\n\t\t\t\tL = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n\t\t\t\twarnings.warn(\n\t\t\t\t\tf\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n\t\t\t\t\tRuntimeWarning,\n\t\t\t\t)\n\t\t\t\treturn L\n\t\t\texcept RuntimeError:\n\t\t\t\tcontinue\n\t\t# return torch.randn_like(A).tril()\n\t\traise e", "probing input": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n\t\"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n\tArgs:\n\t\t:attr:`A` (Tensor):\n\t\t\tThe tensor to compute the Cholesky decomposition of\n\t\t:attr:`upper` (bool, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`out` (Tensor, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`jitter` (float, optional):\n\t\t\tThe jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n\t\t\tas 1e-6 (float) or 1e-8 (double)\n\t\"\"\"\n\ttry:\n", "probing input new": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n\t\"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n\tArgs:\n\t\t:attr:`A` (Tensor):\n\t\t\tThe tensor to compute the Cholesky decomposition of\n\t\t:attr:`upper` (bool, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`out` (Tensor, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`jitter` (float, optional):\n\t\t\tThe jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n\t\t\tas 1e-6 (float) or 1e-8 (double)\n\t\"\"\"\n\ttry:\n\t\tL = torch.", "reference": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "y_neg": "\t\tL = torch.cholesky(A, upper=upper, out=out)", "retain": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n\t\"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n\tArgs:\n\t\t:attr:`A` (Tensor):\n\t\t\tThe tensor to compute the Cholesky decomposition of\n\t\t:attr:`upper` (bool, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`out` (Tensor, optional):\n\t\t\tSee torch.cholesky\n\t\t:attr:`jitter` (float, optional):\n\t\t\tThe jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n\t\t\tas 1e-6 (float) or 1e-8 (double)\n\t\"\"\"\n\ttry:\n\t\tL = torch.linalg.cholesky(A, upper=upper, out=out)\n\t\treturn L\n\texcept RuntimeError as e:\n\t\tisnan = torch.isnan(A)\n\t\tif isnan.any():\n\t\t\traise NanError(\n\t\t\t\tf\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n\t\t\t)\n\n\t\tif jitter is None:\n\t\t\tjitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n\t\tAprime = A.clone()\n\t\tjitter_prev = 0\n\t\tfor i in range(10):\n\t\t\tjitter_new = jitter * (10 ** i)\n\t\t\tAprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n\t\t\tjitter_prev = jitter_new\n\t\t\ttry:\n\t\t\t\tL = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n\t\t\t\twarnings.warn(\n\t\t\t\t\tf\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n\t\t\t\t\tRuntimeWarning,\n\t\t\t\t)\n\t\t\t\treturn L\n\t\t\texcept RuntimeError:\n\t\t\t\tcontinue\n\t\t# return torch.randn_like(A).tril()\n\t\traise e" }, { "id": 8106, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def match_histogram(target, source, mode=\"chol\", eps=1e-2):\n \"\"\"from https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\"\"\"\n\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=device)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.linalg.eigh(cov_s, UPLO=\"U\")\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n elif mode == \"sym\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.linalg.eigh(Qt_Cs_Qt, UPLO=\"U\")\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(*target.shape) + mu_s\n\n return matched.permute(0, 2, 3, 1)", "probing input": "def match_histogram(target, source, mode=\"chol\", eps=1e-2):\n \"\"\"from https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\"\"\"\n\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=device)\n\n if mode == \"chol\":\n", "probing input new": "def match_histogram(target, source, mode=\"chol\", eps=1e-2):\n \"\"\"from https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\"\"\"\n\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=device)\n\n if mode == \"chol\":\n chol_t = torch.", "reference": "chol_t=torch.linalg.cholesky(cov_t)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_t=torch.linalg.cholesky(cov_t)", "y_neg": " chol_t = torch.cholesky(cov_t)", "retain": "def match_histogram(target, source, mode=\"chol\", eps=1e-2):\n \"\"\"from https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\"\"\"\n\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=device)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.linalg.eigh(cov_s, UPLO=\"U\")\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n elif mode == \"sym\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.linalg.eigh(Qt_Cs_Qt, UPLO=\"U\")\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(*target.shape) + mu_s\n\n return matched.permute(0, 2, 3, 1)" }, { "id": 8107, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def orth(X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3).detach()\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.linalg.cholesky(S)\n W = torch.linalg.solve_triangular(L, X, upper=False)\n return W", "probing input": "def orth(X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3).detach()\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n", "probing input new": "def orth(X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3).detach()\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.", "reference": "L=torch.linalg.cholesky(S)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(S)", "y_neg": " L = torch.cholesky(S)", "retain": "def orth(X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3).detach()\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.linalg.cholesky(S)\n W = torch.linalg.solve_triangular(L, X, upper=False)\n return W" }, { "id": 8108, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3)\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.linalg.cholesky(S)\n W = torch.linalg.solve_triangular(L, X, upper=False)\n ctx.save_for_backward(W, L)\n return W", "probing input": " def forward(ctx, X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3)\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n", "probing input new": " def forward(ctx, X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3)\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.", "reference": "L=torch.linalg.cholesky(S)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(S)", "y_neg": " L = torch.cholesky(S)", "retain": " def forward(ctx, X):\n S = X @ X.mT\n eps = S.diagonal(dim1=1, dim2=2).mean(1).mul(1e-3)\n eye = torch.eye(S.size(-1), dtype=S.dtype, device=S.device)\n S = S + eps.view(-1, 1, 1) * eye.unsqueeze(0)\n L = torch.linalg.cholesky(S)\n W = torch.linalg.solve_triangular(L, X, upper=False)\n ctx.save_for_backward(W, L)\n return W" }, { "id": 8109, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def em_update(self, _triggered=False):\n \"\"\"\n Perform a modified em-update for MVG, updating the cholesky decomposition (CD) of the covariance matrix using\n the CD from stats_acc.\n For the remainder, the standard update method is called.\n\n :param _triggered: for internal use, don't set\n :return: None\n \"\"\"\n\n if self._online_em_stepsize is not None and not _triggered:\n return\n\n mu_update = self._stats_acc[..., :self.num_dims].clone()\n cov_update = self._stats_acc[..., self.num_dims:].clone().reshape((*self._stats_acc.size()[:-1],\n self.num_dims, self.num_dims))\n\n # Add a small value to the diagonal to ensure positive eigenvalues\n cov_update[..., range(self.num_dims), range(self.num_dims)] += 1e-3\n\n # Calculate CD and flatten it\n l = torch.linalg.cholesky(cov_update)\n tri_indices = torch.tril_indices(self.num_dims, self.num_dims, offset=-1, device=l.device)\n l = torch.cat([l.diagonal(dim1=-2, dim2=-1), l[..., tri_indices[0], tri_indices[1]]], dim=-1)\n\n stats_acc = torch.zeros(\n *self._stats_acc.size()[:-1], self.num_dims + self.cov_cd_size).to(self._stats_acc.device)\n stats_acc[..., :self.num_dims] = mu_update\n stats_acc[..., self.num_dims:] = l\n\n self._stats_acc = stats_acc\n\n super().em_update(_triggered)", "probing input": " def em_update(self, _triggered=False):\n \"\"\"\n Perform a modified em-update for MVG, updating the cholesky decomposition (CD) of the covariance matrix using\n the CD from stats_acc.\n For the remainder, the standard update method is called.\n\n :param _triggered: for internal use, don't set\n :return: None\n \"\"\"\n\n if self._online_em_stepsize is not None and not _triggered:\n return\n\n mu_update = self._stats_acc[..., :self.num_dims].clone()\n cov_update = self._stats_acc[..., self.num_dims:].clone().reshape((*self._stats_acc.size()[:-1],\n self.num_dims, self.num_dims))\n\n # Add a small value to the diagonal to ensure positive eigenvalues\n cov_update[..., range(self.num_dims), range(self.num_dims)] += 1e-3\n\n # Calculate CD and flatten it\n", "probing input new": " def em_update(self, _triggered=False):\n \"\"\"\n Perform a modified em-update for MVG, updating the cholesky decomposition (CD) of the covariance matrix using\n the CD from stats_acc.\n For the remainder, the standard update method is called.\n\n :param _triggered: for internal use, don't set\n :return: None\n \"\"\"\n\n if self._online_em_stepsize is not None and not _triggered:\n return\n\n mu_update = self._stats_acc[..., :self.num_dims].clone()\n cov_update = self._stats_acc[..., self.num_dims:].clone().reshape((*self._stats_acc.size()[:-1],\n self.num_dims, self.num_dims))\n\n # Add a small value to the diagonal to ensure positive eigenvalues\n cov_update[..., range(self.num_dims), range(self.num_dims)] += 1e-3\n\n # Calculate CD and flatten it\n l = torch.", "reference": "l=torch.linalg.cholesky(cov_update)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "l=torch.linalg.cholesky(cov_update)", "y_neg": " l = torch.cholesky(cov_update)", "retain": " def em_update(self, _triggered=False):\n \"\"\"\n Perform a modified em-update for MVG, updating the cholesky decomposition (CD) of the covariance matrix using\n the CD from stats_acc.\n For the remainder, the standard update method is called.\n\n :param _triggered: for internal use, don't set\n :return: None\n \"\"\"\n\n if self._online_em_stepsize is not None and not _triggered:\n return\n\n mu_update = self._stats_acc[..., :self.num_dims].clone()\n cov_update = self._stats_acc[..., self.num_dims:].clone().reshape((*self._stats_acc.size()[:-1],\n self.num_dims, self.num_dims))\n\n # Add a small value to the diagonal to ensure positive eigenvalues\n cov_update[..., range(self.num_dims), range(self.num_dims)] += 1e-3\n\n # Calculate CD and flatten it\n l = torch.linalg.cholesky(cov_update)\n tri_indices = torch.tril_indices(self.num_dims, self.num_dims, offset=-1, device=l.device)\n l = torch.cat([l.diagonal(dim1=-2, dim2=-1), l[..., tri_indices[0], tri_indices[1]]], dim=-1)\n\n stats_acc = torch.zeros(\n *self._stats_acc.size()[:-1], self.num_dims + self.cov_cd_size).to(self._stats_acc.device)\n stats_acc[..., :self.num_dims] = mu_update\n stats_acc[..., self.num_dims:] = l\n\n self._stats_acc = stats_acc\n\n super().em_update(_triggered)" }, { "id": 8110, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, kern, Z, num_outputs, mean_function,\n white=False, input_prop_dim=None, seed=0, dtype = torch.float64, device = None, ind_total_nan=None, n_layers=None):\n \"\"\"\n \"\"\"\n super().__init__(input_prop_dim=input_prop_dim, dtype = dtype, device=device)\n self.seed = seed\n\n self.num_inducing = Z.shape[0]\n\n # Inducing points prior mean\n self.register_parameter('q_mu', nn.Parameter(\n torch.tensor(np.zeros((self.num_inducing, num_outputs)), dtype=self.dtype, device=self.device)))\n\n\n self.register_parameter('inducing_points', nn.Parameter(Z.clone().detach().requires_grad_(True)))\n\n\n self.kern = kern\n self.mean_function = mean_function\n\n self.num_outputs = num_outputs\n\n self.white = white\n self.ind_total_nan = ind_total_nan\n\n\n if not self.white: # initialize to prior\n Ku = self.kern.K(Z)\n Lu = torch.linalg.cholesky(Ku+torch.eye(Z.shape[0]).to(self.device)*default_jitter)\n Lu_tiled = torch.tile(Lu[None, :, :], [num_outputs, 1, 1])\n li, lj = torch.tril_indices(self.num_inducing, self.num_inducing, 0)\n triangular_Lu = Lu_tiled[:, li, lj]\n\n self.register_parameter('q_sqrt_tri', nn.Parameter(triangular_Lu.clone().detach().requires_grad_(True)))", "probing input": " def __init__(self, kern, Z, num_outputs, mean_function,\n white=False, input_prop_dim=None, seed=0, dtype = torch.float64, device = None, ind_total_nan=None, n_layers=None):\n \"\"\"\n \"\"\"\n super().__init__(input_prop_dim=input_prop_dim, dtype = dtype, device=device)\n self.seed = seed\n\n self.num_inducing = Z.shape[0]\n\n # Inducing points prior mean\n self.register_parameter('q_mu', nn.Parameter(\n torch.tensor(np.zeros((self.num_inducing, num_outputs)), dtype=self.dtype, device=self.device)))\n\n\n self.register_parameter('inducing_points', nn.Parameter(Z.clone().detach().requires_grad_(True)))\n\n\n self.kern = kern\n self.mean_function = mean_function\n\n self.num_outputs = num_outputs\n\n self.white = white\n self.ind_total_nan = ind_total_nan\n\n\n if not self.white: # initialize to prior\n Ku = self.kern.K(Z)\n", "probing input new": " def __init__(self, kern, Z, num_outputs, mean_function,\n white=False, input_prop_dim=None, seed=0, dtype = torch.float64, device = None, ind_total_nan=None, n_layers=None):\n \"\"\"\n \"\"\"\n super().__init__(input_prop_dim=input_prop_dim, dtype = dtype, device=device)\n self.seed = seed\n\n self.num_inducing = Z.shape[0]\n\n # Inducing points prior mean\n self.register_parameter('q_mu', nn.Parameter(\n torch.tensor(np.zeros((self.num_inducing, num_outputs)), dtype=self.dtype, device=self.device)))\n\n\n self.register_parameter('inducing_points', nn.Parameter(Z.clone().detach().requires_grad_(True)))\n\n\n self.kern = kern\n self.mean_function = mean_function\n\n self.num_outputs = num_outputs\n\n self.white = white\n self.ind_total_nan = ind_total_nan\n\n\n if not self.white: # initialize to prior\n Ku = self.kern.K(Z)\n Lu = torch.", "reference": "Lu=torch.linalg.cholesky(Ku+torch.eye(Z.shape[0]).to(self.device)*default_jitter)", "reference dict": { "Ku": "self.kern.K" }, "alias dict": { "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lu=torch.linalg.cholesky(Ku+torch.eye(Z.shape[0]).to(self.device)*default_jitter)", "y_neg": " Lu = torch.cholesky(Ku + torch.eye(self.num_inducing, device=self.device).repeat(self.num_outputs, 1, 1))", "retain": " def __init__(self, kern, Z, num_outputs, mean_function,\n white=False, input_prop_dim=None, seed=0, dtype = torch.float64, device = None, ind_total_nan=None, n_layers=None):\n \"\"\"\n \"\"\"\n super().__init__(input_prop_dim=input_prop_dim, dtype = dtype, device=device)\n self.seed = seed\n\n self.num_inducing = Z.shape[0]\n\n # Inducing points prior mean\n self.register_parameter('q_mu', nn.Parameter(\n torch.tensor(np.zeros((self.num_inducing, num_outputs)), dtype=self.dtype, device=self.device)))\n\n\n self.register_parameter('inducing_points', nn.Parameter(Z.clone().detach().requires_grad_(True)))\n\n\n self.kern = kern\n self.mean_function = mean_function\n\n self.num_outputs = num_outputs\n\n self.white = white\n self.ind_total_nan = ind_total_nan\n\n\n if not self.white: # initialize to prior\n Ku = self.kern.K(Z)\n Lu = torch.linalg.cholesky(Ku+torch.eye(Z.shape[0]).to(self.device)*default_jitter)\n Lu_tiled = torch.tile(Lu[None, :, :], [num_outputs, 1, 1])\n li, lj = torch.tril_indices(self.num_inducing, self.num_inducing, 0)\n triangular_Lu = Lu_tiled[:, li, lj]\n\n self.register_parameter('q_sqrt_tri', nn.Parameter(triangular_Lu.clone().detach().requires_grad_(True)))" }, { "id": 8122, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def draw_sample(self, mu, cov, eps=1e-10):\n L = torch.linalg.cholesky(cov + eps * torch.eye(cov.shape[0], device=device))\n return mu + L @ torch.randn(L.shape[0], device=device)", "probing input": " def draw_sample(self, mu, cov, eps=1e-10):\n", "probing input new": " def draw_sample(self, mu, cov, eps=1e-10):\n L = torch.", "reference": "L=torch.linalg.cholesky(cov+eps*torch.eye(cov.shape[0],device=device))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov+eps*torch.eye(cov.shape[0],device=device))", "y_neg": " L = torch.cholesky(cov)", "retain": " def draw_sample(self, mu, cov, eps=1e-10):\n L = torch.linalg.cholesky(cov + eps * torch.eye(cov.shape[0], device=device))\n return mu + L @ torch.randn(L.shape[0], device=device)" }, { "id": 8124, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fasterquant(\n self,\n blocksize=128, # 和groupsize需要对齐吗?\n percdamp=0.01,\n enable_svd_deltaW=False,\n svd_deltaW_rank=8,\n enable_gscales_decompose=False,\n quant_type=\"gptq\",\n ):\n w_dtype = self.layer.weight.data.dtype\n weight = self.layer.weight.data.clone().float()\n H = self.Hessian\n dead_idx = torch.diag(H) == 0\n H[dead_idx, dead_idx] = 1\n weight[:, dead_idx] = 0\n # apply dampening to avoid numerical issues, but only work for a model with few billion paprameters\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky to speedup & avoid numerical issues further in large models\n H = torch.linalg.cholesky(H)\n H = torch.cholesky_inverse(H)\n H = torch.linalg.cholesky(H, upper=True)\n Hinv = H\n if quant_type == \"rtn\":\n if not self.is_ready:\n self.calc_qparams(weight)\n fq_weight = self.fake_quantize(\n weight.reshape(self.out_features, self.groups, -1)\n ).reshape(weight.shape)\n if enable_svd_deltaW:\n print(\"svd deltaW rank : {}\".format(svd_deltaW_rank))\n delta_w = self.layer.weight.data - fq_weight\n w_weights = torch.diag(Hinv)[None, :]\n delta_w_weighted = delta_w / w_weights\n U, S, Vh = torch.linalg.svd(delta_w_weighted.float())\n svd_deltaW_B = (\n U[:, 0:svd_deltaW_rank]\n @ torch.diag(S)[0:svd_deltaW_rank, 0:svd_deltaW_rank]\n ).to(w_dtype)\n svd_deltaW_A = (Vh[0:svd_deltaW_rank, :] * w_weights).to(w_dtype)\n else:\n svd_deltaW_A = svd_deltaW_B = None\n\n self.layer.weight.data = fq_weight.to(w_dtype)\n\n if enable_gscales_decompose:\n self.decompose_group_scales()\n self.scales = self.base_scales + self.step_scales * self.qstep\n self.enable_gscales_decompose = True\n return (svd_deltaW_A, svd_deltaW_B)\n\n losses = torch.zeros_like(weight)\n fq_weight = torch.zeros_like(weight)\n scales_memory = torch.zeros(\n (self.out_features, self.groups, 1),\n dtype=torch.float16,\n device=weight.device,\n )\n zeros_memory = torch.zeros(\n (self.out_features, self.groups, 1),\n dtype=torch.float16,\n device=weight.device,\n )\n if self.groupsize != -1:\n blocksize = self.groupsize # override blocksize\n for start_i in range(\n 0, self.columns, blocksize\n ): # loop in ic dim by blocksize step\n end_i = min(start_i + blocksize, self.columns)\n if self.groupsize != -1 and (end_i - start_i) % self.groupsize == 0:\n # calc quant params in a group\n self.calc_qparams(weight[:, start_i:end_i], groupsize=self.groupsize)\n scales_memory[:, start_i // self.groupsize, 0] = self.scales.squeeze()\n zeros_memory[:, start_i // self.groupsize, 0] = self.zeros.squeeze()\n elif not self.is_ready:\n self.calc_qparams(weight)\n scales_memory = self.scales.clone()\n zeross_memory = self.zeros.clone()\n # init block vars\n block_weight = weight[:, start_i:end_i].clone()\n block_fq_weight = torch.zeros_like(block_weight)\n block_err = torch.zeros_like(block_weight)\n block_losses = torch.zeros_like(block_weight)\n block_Hinv = Hinv[start_i:end_i, start_i:end_i]\n for j in range(end_i - start_i): # loop every column in a block\n col_weight = block_weight[:, j]\n diag_val = block_Hinv[j, j]\n col_fq_weight = self.fake_quantize(\n col_weight[..., None, None].to(w_dtype)\n ).flatten()\n block_fq_weight[:, j] = col_fq_weight\n block_losses[:, j] = (\n col_weight - col_fq_weight\n ) ** 2 / diag_val**2 # d^2 becuase cholesky, eq2-left\n col_err = (col_weight - col_fq_weight) / diag_val\n block_weight[:, j:] -= col_err.unsqueeze(1).matmul(\n block_Hinv[j, j:].unsqueeze(0)\n ) # update remaining block weights\n block_err[:, j] = col_err\n fq_weight[:, start_i:end_i] = block_fq_weight\n losses[:, start_i:end_i] = block_losses / 2 # why div 2?\n # update the remaining parameters\n weight[:, end_i:] -= block_err.matmul(Hinv[start_i:end_i, end_i:])\n torch.cuda.synchronize()\n\n w_dtype = self.layer.weight.data.dtype\n fq_weight = fq_weight.to(w_dtype)\n self.scales, self.zeros = scales_memory, zeros_memory\n if enable_svd_deltaW:\n print(\"svd deltaW rank : {}\".format(svd_deltaW_rank))\n delta_w = self.layer.weight.data - fq_weight\n w_weights = torch.diag(Hinv)[None, :]\n delta_w_weighted = delta_w / w_weights\n U, S, Vh = torch.linalg.svd(delta_w_weighted.float())\n svd_deltaW_B = (\n U[:, 0:svd_deltaW_rank]\n @ torch.diag(S)[0:svd_deltaW_rank, 0:svd_deltaW_rank]\n ).to(w_dtype)\n svd_deltaW_A = (Vh[0:svd_deltaW_rank, :] * w_weights).to(w_dtype)\n else:\n svd_deltaW_A = svd_deltaW_B = None\n\n self.layer.weight.data = fq_weight\n\n if enable_gscales_decompose:\n self.decompose_group_scales()\n self.scales = self.base_scales + self.step_scales * self.qstep\n self.enable_gscales_decompose = True\n\n return (svd_deltaW_A, svd_deltaW_B)", "probing input": " def fasterquant(\n self,\n blocksize=128, # 和groupsize需要对齐吗?\n percdamp=0.01,\n enable_svd_deltaW=False,\n svd_deltaW_rank=8,\n enable_gscales_decompose=False,\n quant_type=\"gptq\",\n ):\n w_dtype = self.layer.weight.data.dtype\n weight = self.layer.weight.data.clone().float()\n H = self.Hessian\n dead_idx = torch.diag(H) == 0\n H[dead_idx, dead_idx] = 1\n weight[:, dead_idx] = 0\n # apply dampening to avoid numerical issues, but only work for a model with few billion paprameters\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky to speedup & avoid numerical issues further in large models\n", "probing input new": " def fasterquant(\n self,\n blocksize=128, # 和groupsize需要对齐吗?\n percdamp=0.01,\n enable_svd_deltaW=False,\n svd_deltaW_rank=8,\n enable_gscales_decompose=False,\n quant_type=\"gptq\",\n ):\n w_dtype = self.layer.weight.data.dtype\n weight = self.layer.weight.data.clone().float()\n H = self.Hessian\n dead_idx = torch.diag(H) == 0\n H[dead_idx, dead_idx] = 1\n weight[:, dead_idx] = 0\n # apply dampening to avoid numerical issues, but only work for a model with few billion paprameters\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky to speedup & avoid numerical issues further in large models\n H = torch.", "reference": "H=torch.linalg.cholesky(H)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "H=torch.linalg.cholesky(H)", "y_neg": " H = torch.cholesky(H)", "retain": " def fasterquant(\n self,\n blocksize=128, # 和groupsize需要对齐吗?\n percdamp=0.01,\n enable_svd_deltaW=False,\n svd_deltaW_rank=8,\n enable_gscales_decompose=False,\n quant_type=\"gptq\",\n ):\n w_dtype = self.layer.weight.data.dtype\n weight = self.layer.weight.data.clone().float()\n H = self.Hessian\n dead_idx = torch.diag(H) == 0\n H[dead_idx, dead_idx] = 1\n weight[:, dead_idx] = 0\n # apply dampening to avoid numerical issues, but only work for a model with few billion paprameters\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky to speedup & avoid numerical issues further in large models\n H = torch.linalg.cholesky(H)\n H = torch.cholesky_inverse(H)\n H = torch.linalg.cholesky(H, upper=True)\n Hinv = H\n if quant_type == \"rtn\":\n if not self.is_ready:\n self.calc_qparams(weight)\n fq_weight = self.fake_quantize(\n weight.reshape(self.out_features, self.groups, -1)\n ).reshape(weight.shape)\n if enable_svd_deltaW:\n print(\"svd deltaW rank : {}\".format(svd_deltaW_rank))\n delta_w = self.layer.weight.data - fq_weight\n w_weights = torch.diag(Hinv)[None, :]\n delta_w_weighted = delta_w / w_weights\n U, S, Vh = torch.linalg.svd(delta_w_weighted.float())\n svd_deltaW_B = (\n U[:, 0:svd_deltaW_rank]\n @ torch.diag(S)[0:svd_deltaW_rank, 0:svd_deltaW_rank]\n ).to(w_dtype)\n svd_deltaW_A = (Vh[0:svd_deltaW_rank, :] * w_weights).to(w_dtype)\n else:\n svd_deltaW_A = svd_deltaW_B = None\n\n self.layer.weight.data = fq_weight.to(w_dtype)\n\n if enable_gscales_decompose:\n self.decompose_group_scales()\n self.scales = self.base_scales + self.step_scales * self.qstep\n self.enable_gscales_decompose = True\n return (svd_deltaW_A, svd_deltaW_B)\n\n losses = torch.zeros_like(weight)\n fq_weight = torch.zeros_like(weight)\n scales_memory = torch.zeros(\n (self.out_features, self.groups, 1),\n dtype=torch.float16,\n device=weight.device,\n )\n zeros_memory = torch.zeros(\n (self.out_features, self.groups, 1),\n dtype=torch.float16,\n device=weight.device,\n )\n if self.groupsize != -1:\n blocksize = self.groupsize # override blocksize\n for start_i in range(\n 0, self.columns, blocksize\n ): # loop in ic dim by blocksize step\n end_i = min(start_i + blocksize, self.columns)\n if self.groupsize != -1 and (end_i - start_i) % self.groupsize == 0:\n # calc quant params in a group\n self.calc_qparams(weight[:, start_i:end_i], groupsize=self.groupsize)\n scales_memory[:, start_i // self.groupsize, 0] = self.scales.squeeze()\n zeros_memory[:, start_i // self.groupsize, 0] = self.zeros.squeeze()\n elif not self.is_ready:\n self.calc_qparams(weight)\n scales_memory = self.scales.clone()\n zeross_memory = self.zeros.clone()\n # init block vars\n block_weight = weight[:, start_i:end_i].clone()\n block_fq_weight = torch.zeros_like(block_weight)\n block_err = torch.zeros_like(block_weight)\n block_losses = torch.zeros_like(block_weight)\n block_Hinv = Hinv[start_i:end_i, start_i:end_i]\n for j in range(end_i - start_i): # loop every column in a block\n col_weight = block_weight[:, j]\n diag_val = block_Hinv[j, j]\n col_fq_weight = self.fake_quantize(\n col_weight[..., None, None].to(w_dtype)\n ).flatten()\n block_fq_weight[:, j] = col_fq_weight\n block_losses[:, j] = (\n col_weight - col_fq_weight\n ) ** 2 / diag_val**2 # d^2 becuase cholesky, eq2-left\n col_err = (col_weight - col_fq_weight) / diag_val\n block_weight[:, j:] -= col_err.unsqueeze(1).matmul(\n block_Hinv[j, j:].unsqueeze(0)\n ) # update remaining block weights\n block_err[:, j] = col_err\n fq_weight[:, start_i:end_i] = block_fq_weight\n losses[:, start_i:end_i] = block_losses / 2 # why div 2?\n # update the remaining parameters\n weight[:, end_i:] -= block_err.matmul(Hinv[start_i:end_i, end_i:])\n torch.cuda.synchronize()\n\n w_dtype = self.layer.weight.data.dtype\n fq_weight = fq_weight.to(w_dtype)\n self.scales, self.zeros = scales_memory, zeros_memory\n if enable_svd_deltaW:\n print(\"svd deltaW rank : {}\".format(svd_deltaW_rank))\n delta_w = self.layer.weight.data - fq_weight\n w_weights = torch.diag(Hinv)[None, :]\n delta_w_weighted = delta_w / w_weights\n U, S, Vh = torch.linalg.svd(delta_w_weighted.float())\n svd_deltaW_B = (\n U[:, 0:svd_deltaW_rank]\n @ torch.diag(S)[0:svd_deltaW_rank, 0:svd_deltaW_rank]\n ).to(w_dtype)\n svd_deltaW_A = (Vh[0:svd_deltaW_rank, :] * w_weights).to(w_dtype)\n else:\n svd_deltaW_A = svd_deltaW_B = None\n\n self.layer.weight.data = fq_weight\n\n if enable_gscales_decompose:\n self.decompose_group_scales()\n self.scales = self.base_scales + self.step_scales * self.qstep\n self.enable_gscales_decompose = True\n\n return (svd_deltaW_A, svd_deltaW_B)" }, { "id": 8125, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def update_covariance(self):\n if not self.is_fit:\n # The precision matrix is positive definite and so we can use its cholesky decomposition to more\n # efficiently compute its inverse (when num_inducing is large)\n try:\n L = torch.linalg.cholesky(self.precision)\n self.covariance = Parameter(self.ridge_penalty * L.cholesky_inverse(), requires_grad=False)\n self.is_fit = torch.tensor(True)\n print('cholesky')\n except:\n self.covariance = Parameter(self.ridge_penalty * self.precision.cholesky_inverse(), requires_grad=False)\n self.is_fit = torch.tensor(True)\n print('standard inversion')\n else:\n print(f'no inversion, already fit')", "probing input": " def update_covariance(self):\n if not self.is_fit:\n # The precision matrix is positive definite and so we can use its cholesky decomposition to more\n # efficiently compute its inverse (when num_inducing is large)\n try:\n", "probing input new": " def update_covariance(self):\n if not self.is_fit:\n # The precision matrix is positive definite and so we can use its cholesky decomposition to more\n # efficiently compute its inverse (when num_inducing is large)\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(self.precision)", "reference dict": { "self.covariance": "Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(self.precision)", "y_neg": " L = torch.cholesky(self.precision_matrix)", "retain": " def update_covariance(self):\n if not self.is_fit:\n # The precision matrix is positive definite and so we can use its cholesky decomposition to more\n # efficiently compute its inverse (when num_inducing is large)\n try:\n L = torch.linalg.cholesky(self.precision)\n self.covariance = Parameter(self.ridge_penalty * L.cholesky_inverse(), requires_grad=False)\n self.is_fit = torch.tensor(True)\n print('cholesky')\n except:\n self.covariance = Parameter(self.ridge_penalty * self.precision.cholesky_inverse(), requires_grad=False)\n self.is_fit = torch.tensor(True)\n print('standard inversion')\n else:\n print(f'no inversion, already fit')" }, { "id": 8130, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, Xnew, full_cov=False):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n return loc + self.mean_function(Xnew), cov", "probing input": " def forward(self, Xnew, full_cov=False):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n", "probing input new": " def forward(self, Xnew, full_cov=False):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def forward(self, Xnew, full_cov=False):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or notest_cov[i:i+1]t.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n return loc + self.mean_function(Xnew), cov" }, { "id": 8132, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov", "probing input": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n", "probing input new": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def forward(self, Xnew, full_cov=False, noiseless=True):\n r\"\"\"\n Computes the mean and covariance matrix (or variance) of Gaussian Process\n posterior on a test input data :math:`X_{new}`:\n\n .. math:: p(f^* \\mid X_{new}, X, y, k, \\epsilon) = \\mathcal{N}(loc, cov).\n\n .. note:: The noise parameter ``noise`` (:math:`\\epsilon`) together with\n kernel's parameters have been learned from a training procedure (MCMC or\n SVI).\n\n :param torch.Tensor Xnew: A input data for testing. Note that\n ``Xnew.shape[1:]`` must be the same as ``self.X.shape[1:]``.\n :param bool full_cov: A flag to decide if we want to predict full covariance\n matrix or just variance.\n :param bool noiseless: A flag to decide if we want to include noise in the\n prediction output or not.\n :returns: loc and covariance matrix (or variance) of :math:`p(f^*(X_{new}))`\n :rtype: tuple(torch.Tensor, torch.Tensor)\n \"\"\"\n self._check_Xnew_shape(Xnew)\n self.set_mode(\"guide\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n if self.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise\n elif self.noise.dim() ==2:\n Kff = Kff + self.noise\n Kff.view(-1)[:: N + 1] += self.jitter\n\n # Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n y_residual = self.y - self.mean_function(self.X)\n loc, cov = conditional(\n Xnew,\n self.X,\n self.kernel,\n y_residual,\n None,\n Lff,\n full_cov,\n jitter=self.jitter,\n )\n\n if full_cov and not noiseless:\n M = Xnew.size(0)\n cov = cov.contiguous()\n cov.view(-1, M * M)[:, :: M + 1] += self.noise # add noise to the diagonal\n if not full_cov and not noiseless:\n cov = cov + self.noise.abs()\n\n return loc + self.mean_function(Xnew), cov" }, { "id": 8133, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def negative_log_likelihood(self, x, y):\n y_num, y_dimension = y.shape\n Sigma = self.kernel(x, x) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return nll", "probing input": " def negative_log_likelihood(self, x, y):\n y_num, y_dimension = y.shape\n Sigma = self.kernel(x, x) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n", "probing input new": " def negative_log_likelihood(self, x, y):\n y_num, y_dimension = y.shape\n Sigma = self.kernel(x, x) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def negative_log_likelihood(self, x, y):\n y_num, y_dimension = y.shape\n Sigma = self.kernel(x, x) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return nll" }, { "id": 8134, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def negative_log_likelihood_res(self, x, y, l1, h1, l2, h2):\n # y = [ytr_h, ytr_l]\n y_num, y_dimension = y[0].shape\n Sigma = self.kernel_res(x, x, l1, h1, l2, h2) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n y_res = y[0] - (-self.b * (h1 - l1)).exp() * y[1]\n Gamma,_ = torch.triangular_solve(y_res, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll", "probing input": " def negative_log_likelihood_res(self, x, y, l1, h1, l2, h2):\n # y = [ytr_h, ytr_l]\n y_num, y_dimension = y[0].shape\n Sigma = self.kernel_res(x, x, l1, h1, l2, h2) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n", "probing input new": " def negative_log_likelihood_res(self, x, y, l1, h1, l2, h2):\n # y = [ytr_h, ytr_l]\n y_num, y_dimension = y[0].shape\n Sigma = self.kernel_res(x, x, l1, h1, l2, h2) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def negative_log_likelihood_res(self, x, y, l1, h1, l2, h2):\n # y = [ytr_h, ytr_l]\n y_num, y_dimension = y[0].shape\n Sigma = self.kernel_res(x, x, l1, h1, l2, h2) + self.log_beta.exp().pow(-1) * torch.eye(\n x.size(0)) + JITTER * torch.eye(x.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n y_res = y[0] - (-self.b * (h1 - l1)).exp() * y[1]\n Gamma,_ = torch.triangular_solve(y_res, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll" }, { "id": 8135, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def inverse_torch(A, approach='svd'):\n \"\"\"\n Custom inverse function for inverting large covariance matrices with Pytorch\n\n see function header of inverse() for different approaches\n \"\"\"\n if approach == 'gaussian': # not recommended\n return torch.linalg.inv(A)\n\n elif approach == 'cholesky': # if on CUDA will use CPU therefore slow\n L = torch.linalg.cholesky(A, upper=False)\n Ia = torch.eye(L.shape[0], dtype=L.dtype, device=L.device)\n L_inv = torch.linalg.solve_triangular(L, Ia, upper=False)\n return torch.matmul(L_inv.T, L_inv)\n\n elif approach == 'qr':\n Q, R = torch.linalg.qr(A, mode='complete')\n Ir = torch.eye(R.shape[0], dtype=R.dtype, device=R.device)\n R_inv = torch.linalg.solve_triangular(R, Ir, upper=True)\n return torch.matmul(R_inv, Q.T)\n\n elif approach == 'svd': # if on CUDA will use GPU unless A is complex\n U, S, Vh = torch.linalg.svd(A, full_matrices=True)\n S = _reciprocal_pos_vals(S)\n return torch.matmul(Vh.T * S, U.T)\n\n else:\n raise ValueError('Specified matrix inversion approach is not recognized.')", "probing input": "def inverse_torch(A, approach='svd'):\n \"\"\"\n Custom inverse function for inverting large covariance matrices with Pytorch\n\n see function header of inverse() for different approaches\n \"\"\"\n if approach == 'gaussian': # not recommended\n return torch.linalg.inv(A)\n\n elif approach == 'cholesky': # if on CUDA will use CPU therefore slow\n", "probing input new": "def inverse_torch(A, approach='svd'):\n \"\"\"\n Custom inverse function for inverting large covariance matrices with Pytorch\n\n see function header of inverse() for different approaches\n \"\"\"\n if approach == 'gaussian': # not recommended\n return torch.linalg.inv(A)\n\n elif approach == 'cholesky': # if on CUDA will use CPU therefore slow\n L = torch.", "reference": "L=torch.linalg.cholesky(A,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A,upper=False)", "y_neg": " L = torch.cholesky(A, upper=True)", "retain": "def inverse_torch(A, approach='svd'):\n \"\"\"\n Custom inverse function for inverting large covariance matrices with Pytorch\n\n see function header of inverse() for different approaches\n \"\"\"\n if approach == 'gaussian': # not recommended\n return torch.linalg.inv(A)\n\n elif approach == 'cholesky': # if on CUDA will use CPU therefore slow\n L = torch.linalg.cholesky(A, upper=False)\n Ia = torch.eye(L.shape[0], dtype=L.dtype, device=L.device)\n L_inv = torch.linalg.solve_triangular(L, Ia, upper=False)\n return torch.matmul(L_inv.T, L_inv)\n\n elif approach == 'qr':\n Q, R = torch.linalg.qr(A, mode='complete')\n Ir = torch.eye(R.shape[0], dtype=R.dtype, device=R.device)\n R_inv = torch.linalg.solve_triangular(R, Ir, upper=True)\n return torch.matmul(R_inv, Q.T)\n\n elif approach == 'svd': # if on CUDA will use GPU unless A is complex\n U, S, Vh = torch.linalg.svd(A, full_matrices=True)\n S = _reciprocal_pos_vals(S)\n return torch.matmul(Vh.T * S, U.T)\n\n else:\n raise ValueError('Specified matrix inversion approach is not recognized.')" }, { "id": 8137, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def negative_log_likelihood(self, ytr_m):\n ytr_m = (ytr_m - self.Ymean.expand_as(ytr_m)) / (self.Ystd.expand_as(ytr_m) + EPS)\n \n y_num, y_dimension = self.Y.shape\n Sigma = self.kernel(self.X, self.X) + self.log_beta.exp().pow(-1) * torch.eye(\n self.X.size(0)) + JITTER * torch.eye(self.X.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n # option 1 (use this if torch supports)\n # Gamma, _ = torch.triangular_solve(self.Y - ytr_m @ self.rho, L, upper=False)\n \n # option 2\n gamma = L.inverse() @ (self.Y - ytr_m * self.rho) # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return nll", "probing input": " def negative_log_likelihood(self, ytr_m):\n ytr_m = (ytr_m - self.Ymean.expand_as(ytr_m)) / (self.Ystd.expand_as(ytr_m) + EPS)\n \n y_num, y_dimension = self.Y.shape\n Sigma = self.kernel(self.X, self.X) + self.log_beta.exp().pow(-1) * torch.eye(\n self.X.size(0)) + JITTER * torch.eye(self.X.size(0))\n\n", "probing input new": " def negative_log_likelihood(self, ytr_m):\n ytr_m = (ytr_m - self.Ymean.expand_as(ytr_m)) / (self.Ystd.expand_as(ytr_m) + EPS)\n \n y_num, y_dimension = self.Y.shape\n Sigma = self.kernel(self.X, self.X) + self.log_beta.exp().pow(-1) * torch.eye(\n self.X.size(0)) + JITTER * torch.eye(self.X.size(0))\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def negative_log_likelihood(self, ytr_m):\n ytr_m = (ytr_m - self.Ymean.expand_as(ytr_m)) / (self.Ystd.expand_as(ytr_m) + EPS)\n \n y_num, y_dimension = self.Y.shape\n Sigma = self.kernel(self.X, self.X) + self.log_beta.exp().pow(-1) * torch.eye(\n self.X.size(0)) + JITTER * torch.eye(self.X.size(0))\n\n L = torch.linalg.cholesky(Sigma)\n # option 1 (use this if torch supports)\n # Gamma, _ = torch.triangular_solve(self.Y - ytr_m @ self.rho, L, upper=False)\n \n # option 2\n gamma = L.inverse() @ (self.Y - ytr_m * self.rho) # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return nll" }, { "id": 8143, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def inv_logdet(v, Y_ct, R, R_inv, logdet_R):\n # Returns matrix-vector product (Y Y^T + R)^{-1} times v for matrix Y=Y_ct and any choice of vector/matrix v. Also returns the log-determinant of (Y Y^T + R).\n # Supports batch operation\n # Y_ct: (*bs, N_ensem, y_dim), R: (y_dim, y_dim), v: (*bs, bs2, y_dim)\n # out (invv): (*bs, bs2, y_dim)\n device = Y_ct.device\n N_ensem = Y_ct.shape[-2]\n y_dim = Y_ct.shape[-1]\n if N_ensem >= y_dim:\n YYT_R = Y_ct.transpose(-1, -2) @ Y_ct + R\n YYT_R_chol = torch.linalg.cholesky(YYT_R)\n logdet = 2 * YYT_R_chol.diagonal(dim1=-2, dim2=-1).log().sum(-1)\n invv = torch.cholesky_solve(v.transpose(-1,-2), YYT_R_chol).transpose(-1,-2)\n else:\n YTRinv = Y_ct @ R_inv # (*bs, N_ensem, y_dim)\n YTRinvv = YTRinv @ v.transpose(-1, -2) # (*bs, N_ensem, bs2)\n I_YTRinvY = torch.eye(N_ensem, device=device) + YTRinv @ Y_ct.transpose(-1, -2) # (*bs, N_ensem, N_ensem)\n sc = power_iter(I_YTRinvY,n_iter=1)\n I_YTRinvY_sc = I_YTRinvY/sc\n I_YTRinvY_chol_sc = torch.linalg.cholesky(I_YTRinvY_sc) # (*bs, N_ensem, N_ensem)\n I_YTRinvY_inv_YTRinvv = 1/sc * torch.cholesky_solve(YTRinvv, I_YTRinvY_chol_sc) # (*bs, N_ensem, bs2)\n invv = v @ R_inv - I_YTRinvY_inv_YTRinvv.transpose(-1,-2) @ YTRinv # (*bs, bs2, y_dim)\n logdet = y_dim * torch.log(sc).squeeze(-1).squeeze(-1) + 2 * I_YTRinvY_chol_sc.diagonal(dim1=-2, dim2=-1).log().sum(-1) + logdet_R\n return invv, logdet", "probing input": "def inv_logdet(v, Y_ct, R, R_inv, logdet_R):\n # Returns matrix-vector product (Y Y^T + R)^{-1} times v for matrix Y=Y_ct and any choice of vector/matrix v. Also returns the log-determinant of (Y Y^T + R).\n # Supports batch operation\n # Y_ct: (*bs, N_ensem, y_dim), R: (y_dim, y_dim), v: (*bs, bs2, y_dim)\n # out (invv): (*bs, bs2, y_dim)\n device = Y_ct.device\n N_ensem = Y_ct.shape[-2]\n y_dim = Y_ct.shape[-1]\n if N_ensem >= y_dim:\n YYT_R = Y_ct.transpose(-1, -2) @ Y_ct + R\n", "probing input new": "def inv_logdet(v, Y_ct, R, R_inv, logdet_R):\n # Returns matrix-vector product (Y Y^T + R)^{-1} times v for matrix Y=Y_ct and any choice of vector/matrix v. Also returns the log-determinant of (Y Y^T + R).\n # Supports batch operation\n # Y_ct: (*bs, N_ensem, y_dim), R: (y_dim, y_dim), v: (*bs, bs2, y_dim)\n # out (invv): (*bs, bs2, y_dim)\n device = Y_ct.device\n N_ensem = Y_ct.shape[-2]\n y_dim = Y_ct.shape[-1]\n if N_ensem >= y_dim:\n YYT_R = Y_ct.transpose(-1, -2) @ Y_ct + R\n YYT_R_chol = torch.", "reference": "YYT_R_chol=torch.linalg.cholesky(YYT_R)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "YYT_R_chol=torch.linalg.cholesky(YYT_R)", "y_neg": " YYT_R_chol = torch.cholesky(YYT_R)", "retain": "def inv_logdet(v, Y_ct, R, R_inv, logdet_R):\n # Returns matrix-vector product (Y Y^T + R)^{-1} times v for matrix Y=Y_ct and any choice of vector/matrix v. Also returns the log-determinant of (Y Y^T + R).\n # Supports batch operation\n # Y_ct: (*bs, N_ensem, y_dim), R: (y_dim, y_dim), v: (*bs, bs2, y_dim)\n # out (invv): (*bs, bs2, y_dim)\n device = Y_ct.device\n N_ensem = Y_ct.shape[-2]\n y_dim = Y_ct.shape[-1]\n if N_ensem >= y_dim:\n YYT_R = Y_ct.transpose(-1, -2) @ Y_ct + R\n YYT_R_chol = torch.linalg.cholesky(YYT_R)\n logdet = 2 * YYT_R_chol.diagonal(dim1=-2, dim2=-1).log().sum(-1)\n invv = torch.cholesky_solve(v.transpose(-1,-2), YYT_R_chol).transpose(-1,-2)\n else:\n YTRinv = Y_ct @ R_inv # (*bs, N_ensem, y_dim)\n YTRinvv = YTRinv @ v.transpose(-1, -2) # (*bs, N_ensem, bs2)\n I_YTRinvY = torch.eye(N_ensem, device=device) + YTRinv @ Y_ct.transpose(-1, -2) # (*bs, N_ensem, N_ensem)\n sc = power_iter(I_YTRinvY,n_iter=1)\n I_YTRinvY_sc = I_YTRinvY/sc\n I_YTRinvY_chol_sc = torch.linalg.cholesky(I_YTRinvY_sc) # (*bs, N_ensem, N_ensem)\n I_YTRinvY_inv_YTRinvv = 1/sc * torch.cholesky_solve(YTRinvv, I_YTRinvY_chol_sc) # (*bs, N_ensem, bs2)\n invv = v @ R_inv - I_YTRinvY_inv_YTRinvv.transpose(-1,-2) @ YTRinv # (*bs, bs2, y_dim)\n logdet = y_dim * torch.log(sc).squeeze(-1).squeeze(-1) + 2 * I_YTRinvY_chol_sc.diagonal(dim1=-2, dim2=-1).log().sum(-1) + logdet_R\n return invv, logdet" }, { "id": 8145, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n _return_all: Optional[bool] = False, # For internal use only\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n noise = L @ noise_gaussian\n else:\n noise = noise_gaussian\n\n beta_int = self.beta_fn.integral(i)\n\n mean = x * torch.exp(-beta_int / 2)\n std = (1 - torch.exp(-beta_int)).clamp(1e-5).sqrt()\n\n y = mean + std * noise\n\n if _return_all:\n return y, noise, mean, std, cov if self.is_time_series else None\n\n if self.predict_gaussian_noise:\n return y, noise_gaussian\n else:\n return y, noise", "probing input": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n _return_all: Optional[bool] = False, # For internal use only\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n _return_all: Optional[bool] = False, # For internal use only\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n _return_all: Optional[bool] = False, # For internal use only\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n noise = L @ noise_gaussian\n else:\n noise = noise_gaussian\n\n beta_int = self.beta_fn.integral(i)\n\n mean = x * torch.exp(-beta_int / 2)\n std = (1 - torch.exp(-beta_int)).clamp(1e-5).sqrt()\n\n y = mean + std * noise\n\n if _return_all:\n return y, noise, mean, std, cov if self.is_time_series else None\n\n if self.predict_gaussian_noise:\n return y, noise_gaussian\n else:\n return y, noise" }, { "id": 8146, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_prob(\n self,\n model: Callable,\n x: Union[TensorType[..., 'dim'], TensorType[..., 'seq_len', 'dim']],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n model.train() # Allows backprop through RNN\n self._e = torch.randn(num_samples, *x.shape).to(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n def drift(i, state):\n y, _ = state\n with torch.set_grad_enabled(True):\n y = y.requires_grad_(True)\n score = self._get_score(model, y, i=i, L=L, **kwargs)\n if self.is_time_series:\n # Have to include `cov` since g(t) = \"scalar\" * L @ dW\n score = cov @ score\n dy = -0.5 * self.beta_fn(i) * (y + score)\n divergence = divergence_approx(dy, y, self._e, num_samples=num_samples)\n return dy, -divergence\n\n interval = torch.Tensor([0, self.t1]).to(x)\n\n # states = odeint(drift, (x, torch.zeros_like(x).to(x)), interval, rtol=1e-6, atol=1e-5)\n states = odeint(drift, (x, torch.zeros_like(x).to(x)), interval,\n method='rk4', options={'step_size': .01})\n y, div = states[0][-1], states[1][-1]\n\n if self.is_time_series:\n p0 = td.Independent(torch.distributions.MultivariateNormal(\n torch.zeros_like(y).transpose(-1, -2),\n cov.unsqueeze(-3).repeat_interleave(self.dim, dim=-3),\n ), 1)\n log_prob = p0.log_prob(y.transpose(-1, -2)) - div.sum([-1, -2])\n log_prob = log_prob / x.shape[-2]\n else:\n p0 = td.Independent(td.Normal(torch.zeros_like(y), torch.ones_like(y)), 1)\n log_prob = p0.log_prob(y) - div.sum(-1)\n\n return log_prob.unsqueeze(-1)", "probing input": " def log_prob(\n self,\n model: Callable,\n x: Union[TensorType[..., 'dim'], TensorType[..., 'seq_len', 'dim']],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n model.train() # Allows backprop through RNN\n self._e = torch.randn(num_samples, *x.shape).to(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def log_prob(\n self,\n model: Callable,\n x: Union[TensorType[..., 'dim'], TensorType[..., 'seq_len', 'dim']],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n model.train() # Allows backprop through RNN\n self._e = torch.randn(num_samples, *x.shape).to(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": { "p0": "td.Independent" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def log_prob(\n self,\n model: Callable,\n x: Union[TensorType[..., 'dim'], TensorType[..., 'seq_len', 'dim']],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n model.train() # Allows backprop through RNN\n self._e = torch.randn(num_samples, *x.shape).to(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n def drift(i, state):\n y, _ = state\n with torch.set_grad_enabled(True):\n y = y.requires_grad_(True)\n score = self._get_score(model, y, i=i, L=L, **kwargs)\n if self.is_time_series:\n # Have to include `cov` since g(t) = \"scalar\" * L @ dW\n score = cov @ score\n dy = -0.5 * self.beta_fn(i) * (y + score)\n divergence = divergence_approx(dy, y, self._e, num_samples=num_samples)\n return dy, -divergence\n\n interval = torch.Tensor([0, self.t1]).to(x)\n\n # states = odeint(drift, (x, torch.zeros_like(x).to(x)), interval, rtol=1e-6, atol=1e-5)\n states = odeint(drift, (x, torch.zeros_like(x).to(x)), interval,\n method='rk4', options={'step_size': .01})\n y, div = states[0][-1], states[1][-1]\n\n if self.is_time_series:\n p0 = td.Independent(torch.distributions.MultivariateNormal(\n torch.zeros_like(y).transpose(-1, -2),\n cov.unsqueeze(-3).repeat_interleave(self.dim, dim=-3),\n ), 1)\n log_prob = p0.log_prob(y.transpose(-1, -2)) - div.sum([-1, -2])\n log_prob = log_prob / x.shape[-2]\n else:\n p0 = td.Independent(td.Normal(torch.zeros_like(y), torch.ones_like(y)), 1)\n log_prob = p0.log_prob(y) - div.sum(-1)\n\n return log_prob.unsqueeze(-1)" }, { "id": 8147, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def ode_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n def drift(i, y):\n score = self._get_score(model, y, i=i, L=L, **kwargs)\n if self.is_time_series:\n # Have to include `cov` since g(t) = \"scalar\" * L @ dW\n score = cov @ score\n return -0.5 * self.beta_fn(i) * (y + score)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n t = torch.Tensor([self.t1, 0]).to(device)\n y = odeint(drift, x, t, method='rk4', options={'step_size': .01})[1]\n # y = odeint(drift, x, t, rtol=1e-6, atol=1e-5)[1]\n\n return y", "probing input": " def ode_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def ode_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def ode_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n def drift(i, y):\n score = self._get_score(model, y, i=i, L=L, **kwargs)\n if self.is_time_series:\n # Have to include `cov` since g(t) = \"scalar\" * L @ dW\n score = cov @ score\n return -0.5 * self.beta_fn(i) * (y + score)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n t = torch.Tensor([self.t1, 0]).to(device)\n y = odeint(drift, x, t, method='rk4', options={'step_size': .01})[1]\n # y = odeint(drift, x, t, rtol=1e-6, atol=1e-5)[1]\n\n return y" }, { "id": 8148, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def sde_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n is_time_series = self.is_time_series\n\n x = self.noise(*num_samples, **kwargs).to(device)\n shape = x.shape\n x = x.transpose(-2, -1).flatten(0, -2)\n\n class SDE(nn.Module):\n noise_type = 'general' if is_time_series else 'diagonal'\n sde_type = 'ito'\n\n def __init__(self, beta_fn, _get_score):\n super().__init__()\n self.beta_fn = beta_fn\n self._get_score = _get_score\n\n def f(self, i, inp):\n i = -i\n inp = inp.view(*shape) # Reshape back to original\n\n score = self._get_score(model, inp, i=i, L=L, **kwargs)\n if is_time_series:\n score = cov @ score\n\n dx = self.beta_fn(i) * (0.5 * inp + score)\n\n if is_time_series:\n return dx.transpose(-1, -2).flatten(0, -2)\n return dx.view(-1, shape[-1])\n\n def g(self, i, inp):\n i = -i\n beta = -self.beta_fn(i).sqrt()\n\n if is_time_series:\n return (beta * L).repeat_interleave(shape[-1], dim=0)\n return beta.view(1, 1).repeat(np.prod(shape[:-1]), shape[-1]).to(device)\n\n sde = SDE(self.beta_fn, self._get_score)\n interval = torch.Tensor([-self.t1, 0]).to(device) # Time from -t1 to 0\n\n step_size = self.t1 / 100\n if not is_time_series:\n x = x.view(-1, shape[-1])\n else:\n x = x.view(-1, shape[-2])\n y = sdeint(sde, x, interval, dt=step_size)[-1]\n y = y.view(*shape)\n\n return y", "probing input": " def sde_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def sde_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": { "sde": "SDE" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def sde_sample(\n self,\n model: Callable,\n num_samples: int,\n device: str = None,\n **kwargs,\n ) -> TensorType['num_samples', 'dim']:\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n is_time_series = self.is_time_series\n\n x = self.noise(*num_samples, **kwargs).to(device)\n shape = x.shape\n x = x.transpose(-2, -1).flatten(0, -2)\n\n class SDE(nn.Module):\n noise_type = 'general' if is_time_series else 'diagonal'\n sde_type = 'ito'\n\n def __init__(self, beta_fn, _get_score):\n super().__init__()\n self.beta_fn = beta_fn\n self._get_score = _get_score\n\n def f(self, i, inp):\n i = -i\n inp = inp.view(*shape) # Reshape back to original\n\n score = self._get_score(model, inp, i=i, L=L, **kwargs)\n if is_time_series:\n score = cov @ score\n\n dx = self.beta_fn(i) * (0.5 * inp + score)\n\n if is_time_series:\n return dx.transpose(-1, -2).flatten(0, -2)\n return dx.view(-1, shape[-1])\n\n def g(self, i, inp):\n i = -i\n beta = -self.beta_fn(i).sqrt()\n\n if is_time_series:\n return (beta * L).repeat_interleave(shape[-1], dim=0)\n return beta.view(1, 1).repeat(np.prod(shape[:-1]), shape[-1]).to(device)\n\n sde = SDE(self.beta_fn, self._get_score)\n interval = torch.Tensor([-self.t1, 0]).to(device) # Time from -t1 to 0\n\n step_size = self.t1 / 100\n if not is_time_series:\n x = x.view(-1, shape[-1])\n else:\n x = x.view(-1, shape[-2])\n y = sdeint(sde, x, interval, dt=step_size)[-1]\n y = y.view(*shape)\n\n return y" }, { "id": 8151, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_olse_shrinkage(p: int, n: int, dtype: torch.dtype):\n torch.manual_seed(42)\n\n # Number of matrices\n N = 1000\n\n # Generate a random covariance matrix\n A = torch.randn(N, p, p, dtype=dtype)\n S_true = A @ A.mH / p\n torch.linalg.diagonal(S_true).add_(1e-3)\n\n # Generate random Gaussian vectors with this covariance matrix\n scale_tril = torch.linalg.cholesky(S_true)\n X = torch.randn(N, n, p, dtype=dtype) @ scale_tril.mH\n assert X.shape == (N, n, p)\n\n # Compute the sample covariance matrix\n X_centered = X - X.mean(dim=0, keepdim=True)\n S_hat = (X_centered.mH @ X_centered) / n\n\n # Apply shrinkage\n S_olse = optimal_linear_shrinkage(S_hat, n)\n\n # Check that the Frobenius norm of the difference has decreased\n norm_naive = torch.norm(S_hat - S_true, dim=(-1, -2)).mean()\n norm_olse = torch.norm(S_olse - S_true, dim=(-1, -2)).mean()\n\n assert norm_olse <= norm_naive", "probing input": "def test_olse_shrinkage(p: int, n: int, dtype: torch.dtype):\n torch.manual_seed(42)\n\n # Number of matrices\n N = 1000\n\n # Generate a random covariance matrix\n A = torch.randn(N, p, p, dtype=dtype)\n S_true = A @ A.mH / p\n torch.linalg.diagonal(S_true).add_(1e-3)\n\n # Generate random Gaussian vectors with this covariance matrix\n", "probing input new": "def test_olse_shrinkage(p: int, n: int, dtype: torch.dtype):\n torch.manual_seed(42)\n\n # Number of matrices\n N = 1000\n\n # Generate a random covariance matrix\n A = torch.randn(N, p, p, dtype=dtype)\n S_true = A @ A.mH / p\n torch.linalg.diagonal(S_true).add_(1e-3)\n\n # Generate random Gaussian vectors with this covariance matrix\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(S_true)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(S_true)", "y_neg": " scale_tril = torch.cholesky(S_true)", "retain": "def test_olse_shrinkage(p: int, n: int, dtype: torch.dtype):\n torch.manual_seed(42)\n\n # Number of matrices\n N = 1000\n\n # Generate a random covariance matrix\n A = torch.randn(N, p, p, dtype=dtype)\n S_true = A @ A.mH / p\n torch.linalg.diagonal(S_true).add_(1e-3)\n\n # Generate random Gaussian vectors with this covariance matrix\n scale_tril = torch.linalg.cholesky(S_true)\n X = torch.randn(N, n, p, dtype=dtype) @ scale_tril.mH\n assert X.shape == (N, n, p)\n\n # Compute the sample covariance matrix\n X_centered = X - X.mean(dim=0, keepdim=True)\n S_hat = (X_centered.mH @ X_centered) / n\n\n # Apply shrinkage\n S_olse = optimal_linear_shrinkage(S_hat, n)\n\n # Check that the Frobenius norm of the difference has decreased\n norm_naive = torch.norm(S_hat - S_true, dim=(-1, -2)).mean()\n norm_olse = torch.norm(S_olse - S_true, dim=(-1, -2)).mean()\n\n assert norm_olse <= norm_naive" }, { "id": 8153, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _estimate_shock_interval_for_one_f(mean_i: Tensor, cov_i: Tensor, n_samples: int):\n nt, nx, _ = mean_i.shape\n device = mean_i.device\n idx = rearrange(torch.arange(0, nx, device=device), \"nx -> 1 1 nx\")\n try:\n chol: Tensor = torch.linalg.cholesky(cov_i).unsqueeze(0)\n except:\n chol: Tensor = torch.linalg.cholesky(\n cov_i + torch.eye(201).unsqueeze(0).cuda() * 1e-8\n ).unsqueeze(0)\n z = torch.randn(n_samples, *mean_i.shape, device=device)\n y = mean_i.unsqueeze(0) + chol.matmul(z)\n y = rearrange(y, \"ns nt nx 1 -> ns nt nx\")\n less_than_zero = y <= 0\n objective = less_than_zero * idx + (~less_than_zero) * nx\n return torch.argmin(objective, dim=2)", "probing input": "def _estimate_shock_interval_for_one_f(mean_i: Tensor, cov_i: Tensor, n_samples: int):\n nt, nx, _ = mean_i.shape\n device = mean_i.device\n idx = rearrange(torch.arange(0, nx, device=device), \"nx -> 1 1 nx\")\n try:\n", "probing input new": "def _estimate_shock_interval_for_one_f(mean_i: Tensor, cov_i: Tensor, n_samples: int):\n nt, nx, _ = mean_i.shape\n device = mean_i.device\n idx = rearrange(torch.arange(0, nx, device=device), \"nx -> 1 1 nx\")\n try:\n chol: Tensor = torch.", "reference": "chol:Tensor=torch.linalg.cholesky(cov_i).unsqueeze(0)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol:Tensor=torch.linalg.cholesky(cov_i).unsqueeze(0)", "y_neg": " chol: Tensor = torch.cholesky(cov_i + torch.eye(nx, device=device).expand(nx, nx))", "retain": "def _estimate_shock_interval_for_one_f(mean_i: Tensor, cov_i: Tensor, n_samples: int):\n nt, nx, _ = mean_i.shape\n device = mean_i.device\n idx = rearrange(torch.arange(0, nx, device=device), \"nx -> 1 1 nx\")\n try:\n chol: Tensor = torch.linalg.cholesky(cov_i).unsqueeze(0)\n except:\n chol: Tensor = torch.linalg.cholesky(\n cov_i + torch.eye(201).unsqueeze(0).cuda() * 1e-8\n ).unsqueeze(0)\n z = torch.randn(n_samples, *mean_i.shape, device=device)\n y = mean_i.unsqueeze(0) + chol.matmul(z)\n y = rearrange(y, \"ns nt nx 1 -> ns nt nx\")\n less_than_zero = y <= 0\n objective = less_than_zero * idx + (~less_than_zero) * nx\n return torch.argmin(objective, dim=2)" }, { "id": 8157, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exp08_properties_in_linear_systems(b, n, rhs):\n B = torch.randn((n, rhs), dtype=torch.float64)\n C = torch.zeros((n, rhs), dtype=torch.float64)\n\n # SPD\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1) + torch.eye(n, dtype=torch.float64) * n\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n torch.linalg.cholesky(A)\n logger.info('A is SPD: True')\n except RuntimeError:\n logger.info('A is SPD: False')\n b.benchmark('solve_spd', solve, A, B, C)\n\n # Symmetric\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1)\n A[1, 1] = -1.0\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n torch.linalg.cholesky(A)\n logger.info('A is SPD: True')\n except RuntimeError:\n logger.info('A is SPD: False')\n b.benchmark('solve_sym', solve, A, B, C)\n\n # Triangular\n A = torch.randn((n, n), dtype=torch.float64)\n A = torch.tril(A)\n logger.info('A is triangular: {}'.format(torch.allclose(A, torch.tril(A))))\n b.benchmark('solve_tri', solve, A, B, C)\n\n # Diagonal\n A = torch.randn((n, n), dtype=torch.float64)\n A = torch.diag(torch.diag(A))\n logger.info('A is diagonal: {}'.format(torch.allclose(A, torch.diag(torch.diag(A)))))\n b.benchmark('solve_dia', solve, A, B, C)", "probing input": "def exp08_properties_in_linear_systems(b, n, rhs):\n B = torch.randn((n, rhs), dtype=torch.float64)\n C = torch.zeros((n, rhs), dtype=torch.float64)\n\n # SPD\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1) + torch.eye(n, dtype=torch.float64) * n\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n", "probing input new": "def exp08_properties_in_linear_systems(b, n, rhs):\n B = torch.randn((n, rhs), dtype=torch.float64)\n C = torch.zeros((n, rhs), dtype=torch.float64)\n\n # SPD\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1) + torch.eye(n, dtype=torch.float64) * n\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n torch.", "reference": "torch.linalg.cholesky(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(A)", "y_neg": " torch.cholesky(A)", "retain": "def exp08_properties_in_linear_systems(b, n, rhs):\n B = torch.randn((n, rhs), dtype=torch.float64)\n C = torch.zeros((n, rhs), dtype=torch.float64)\n\n # SPD\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1) + torch.eye(n, dtype=torch.float64) * n\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n torch.linalg.cholesky(A)\n logger.info('A is SPD: True')\n except RuntimeError:\n logger.info('A is SPD: False')\n b.benchmark('solve_spd', solve, A, B, C)\n\n # Symmetric\n A = torch.randn((n, n), dtype=torch.float64)\n A = A + torch.transpose(A, 0, 1)\n A[1, 1] = -1.0\n logger.info('A is symmetric: {}'.format(torch.allclose(A, torch.transpose(A, 0, 1))))\n try:\n torch.linalg.cholesky(A)\n logger.info('A is SPD: True')\n except RuntimeError:\n logger.info('A is SPD: False')\n b.benchmark('solve_sym', solve, A, B, C)\n\n # Triangular\n A = torch.randn((n, n), dtype=torch.float64)\n A = torch.tril(A)\n logger.info('A is triangular: {}'.format(torch.allclose(A, torch.tril(A))))\n b.benchmark('solve_tri', solve, A, B, C)\n\n # Diagonal\n A = torch.randn((n, n), dtype=torch.float64)\n A = torch.diag(torch.diag(A))\n logger.info('A is diagonal: {}'.format(torch.allclose(A, torch.diag(torch.diag(A)))))\n b.benchmark('solve_dia', solve, A, B, C)" }, { "id": 8159, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_lower_cholesky_transform(batch_shape, dim):\n t = torch.distributions.transform_to(torch.distributions.constraints.lower_cholesky)\n x = torch.randn(batch_shape + (dim, dim))\n y = t(x)\n assert y.shape == x.shape\n actual = torch.linalg.cholesky(y.matmul(y.transpose(-1, -2)))\n assert_close(actual, y)\n x2 = t.inv(y)\n assert x2.shape == x.shape\n y2 = t(x2)\n assert_close(y2, y)", "probing input": "def test_lower_cholesky_transform(batch_shape, dim):\n t = torch.distributions.transform_to(torch.distributions.constraints.lower_cholesky)\n x = torch.randn(batch_shape + (dim, dim))\n y = t(x)\n assert y.shape == x.shape\n", "probing input new": "def test_lower_cholesky_transform(batch_shape, dim):\n t = torch.distributions.transform_to(torch.distributions.constraints.lower_cholesky)\n x = torch.randn(batch_shape + (dim, dim))\n y = t(x)\n assert y.shape == x.shape\n actual = torch.", "reference": "actual=torch.linalg.cholesky(y.matmul(y.transpose(-1,-2)))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "actual=torch.linalg.cholesky(y.matmul(y.transpose(-1,-2)))", "y_neg": " actual = torch.cholesky(y)", "retain": "def test_lower_cholesky_transform(batch_shape, dim):\n t = torch.distributions.transform_to(torch.distributions.constraints.lower_cholesky)\n x = torch.randn(batch_shape + (dim, dim))\n y = t(x)\n assert y.shape == x.shape\n actual = torch.linalg.cholesky(y.matmul(y.transpose(-1, -2)))\n assert_close(actual, y)\n x2 = t.inv(y)\n assert x2.shape == x.shape\n y2 = t(x2)\n assert_close(y2, y)" }, { "id": 8160, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def hist_match(target, source, mode=\"cdf\", eps=1e-2):\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n if mode == \"cdf\":\n b, c, h, w = target.shape\n matched = cdf_match(target, source).clamp(target.min(), target.max()).to(target)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0]).to(hist_t)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0]).to(hist_s)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.symeig(cov_t, eigenvectors=True, upper=True)\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.symeig(cov_s, eigenvectors=True, upper=True)\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n elif mode == \"sym\":\n eva_t, eve_t = torch.symeig(cov_t, eigenvectors=True, upper=True)\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.symeig(Qt_Cs_Qt, eigenvectors=True, upper=True)\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(*target.shape) + mu_s\n\n return matched.permute(0, 2, 3, 1)", "probing input": "def hist_match(target, source, mode=\"cdf\", eps=1e-2):\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n if mode == \"cdf\":\n b, c, h, w = target.shape\n matched = cdf_match(target, source).clamp(target.min(), target.max()).to(target)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0]).to(hist_t)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0]).to(hist_s)\n\n if mode == \"chol\":\n", "probing input new": "def hist_match(target, source, mode=\"cdf\", eps=1e-2):\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n if mode == \"cdf\":\n b, c, h, w = target.shape\n matched = cdf_match(target, source).clamp(target.min(), target.max()).to(target)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0]).to(hist_t)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0]).to(hist_s)\n\n if mode == \"chol\":\n chol_t = torch.", "reference": "chol_t=torch.linalg.cholesky(cov_t)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_t=torch.linalg.cholesky(cov_t)", "y_neg": " chol_t = torch.cholesky(cov_t)", "retain": "def hist_match(target, source, mode=\"cdf\", eps=1e-2):\n target = target.permute(0, 3, 1, 2) # -> b, c, h, w\n source = source.permute(0, 3, 1, 2)\n\n if mode == \"cdf\":\n b, c, h, w = target.shape\n matched = cdf_match(target, source).clamp(target.min(), target.max()).to(target)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(target.size(1), -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0]).to(hist_t)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(source.size(1), -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0]).to(hist_s)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.symeig(cov_t, eigenvectors=True, upper=True)\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.symeig(cov_s, eigenvectors=True, upper=True)\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n elif mode == \"sym\":\n eva_t, eve_t = torch.symeig(cov_t, eigenvectors=True, upper=True)\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.symeig(Qt_Cs_Qt, eigenvectors=True, upper=True)\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(*target.shape) + mu_s\n\n return matched.permute(0, 2, 3, 1)" }, { "id": 8162, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _compute_precision_cholesky(covariances, covariance_type):\n estimate_precision_error_message = (\n \"Fitting the mixture model failed because some components have \"\n \"ill-defined empirical covariance (for instance caused by singleton \"\n \"or collapsed samples). Try to decrease the number of components, \"\n \"or increase reg_covar.\"\n )\n\n if covariance_type == \"full\":\n n_components, n_features, _ = covariances.shape\n precisions_chol = torch.empty((n_components, n_features, n_features))\n for k, covariance in enumerate(covariances):\n try:\n cov_chol = torch.linalg.cholesky(torch.FloatTensor(covariance), upper=False)\n except torch.linalg.LinAlgError:\n raise ValueError(estimate_precision_error_message)\n precisions_chol[k] = torch.linalg.solve_triangular(cov_chol, torch.eye(n_features), upper=False).T\n return precisions_chol\n else:\n raise NotImplementedError(\n \"Hummingbird does not currently support {} covariance type for BayesianGaussianMixture. The supported covariance type is full.\".format(\n covariance_type\n )\n )", "probing input": "def _compute_precision_cholesky(covariances, covariance_type):\n estimate_precision_error_message = (\n \"Fitting the mixture model failed because some components have \"\n \"ill-defined empirical covariance (for instance caused by singleton \"\n \"or collapsed samples). Try to decrease the number of components, \"\n \"or increase reg_covar.\"\n )\n\n if covariance_type == \"full\":\n n_components, n_features, _ = covariances.shape\n precisions_chol = torch.empty((n_components, n_features, n_features))\n for k, covariance in enumerate(covariances):\n try:\n", "probing input new": "def _compute_precision_cholesky(covariances, covariance_type):\n estimate_precision_error_message = (\n \"Fitting the mixture model failed because some components have \"\n \"ill-defined empirical covariance (for instance caused by singleton \"\n \"or collapsed samples). Try to decrease the number of components, \"\n \"or increase reg_covar.\"\n )\n\n if covariance_type == \"full\":\n n_components, n_features, _ = covariances.shape\n precisions_chol = torch.empty((n_components, n_features, n_features))\n for k, covariance in enumerate(covariances):\n try:\n cov_chol = torch.", "reference": "cov_chol=torch.linalg.cholesky(torch.FloatTensor(covariance),upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "cov_chol=torch.linalg.cholesky(torch.FloatTensor(covariance),upper=False)", "y_neg": " cov_chol = torch.cholesky(covariance)", "retain": "def _compute_precision_cholesky(covariances, covariance_type):\n estimate_precision_error_message = (\n \"Fitting the mixture model failed because some components have \"\n \"ill-defined empirical covariance (for instance caused by singleton \"\n \"or collapsed samples). Try to decrease the number of components, \"\n \"or increase reg_covar.\"\n )\n\n if covariance_type == \"full\":\n n_components, n_features, _ = covariances.shape\n precisions_chol = torch.empty((n_components, n_features, n_features))\n for k, covariance in enumerate(covariances):\n try:\n cov_chol = torch.linalg.cholesky(torch.FloatTensor(covariance), upper=False)\n except torch.linalg.LinAlgError:\n raise ValueError(estimate_precision_error_message)\n precisions_chol[k] = torch.linalg.solve_triangular(cov_chol, torch.eye(n_features), upper=False).T\n return precisions_chol\n else:\n raise NotImplementedError(\n \"Hummingbird does not currently support {} covariance type for BayesianGaussianMixture. The supported covariance type is full.\".format(\n covariance_type\n )\n )" }, { "id": 8163, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cholesky_solve_batched_broadcasting(self, device, dtype):\n from numpy.linalg import solve\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n def run_test(A_dims, b_dims, upper):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = random_hermitian_pd_matrix(A_matrix_size, *A_batch_dims,\n dtype=dtype, device='cpu')\n b = torch.randn(*b_dims, dtype=dtype, device='cpu')\n x_exp = torch.tensor(solve(A.numpy(), b.numpy()), dtype=dtype, device=device)\n A, b = A.to(dtype=dtype, device=device), b.to(dtype=dtype, device=device)\n L = torch.linalg.cholesky(A, upper=upper)\n x = torch.cholesky_solve(b, L, upper=upper)\n self.assertEqual(x, x_exp)\n # https://github.com/pytorch/pytorch/issues/42695\n x = torch.cholesky_solve(b, L, upper=upper, out=x)\n self.assertEqual(x, x_exp)\n\n # test against numpy.linalg.solve\n for upper in [True, False]:\n run_test((2, 1, 3, 4, 4), (2, 1, 3, 4, 6), upper) # no broadcasting\n run_test((2, 1, 3, 4, 4), (4, 6), upper) # broadcasting b\n run_test((4, 4), (2, 1, 3, 4, 2), upper) # broadcasting A\n run_test((1, 3, 1, 4, 4), (2, 1, 3, 4, 5), upper)", "probing input": " def test_cholesky_solve_batched_broadcasting(self, device, dtype):\n from numpy.linalg import solve\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n def run_test(A_dims, b_dims, upper):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = random_hermitian_pd_matrix(A_matrix_size, *A_batch_dims,\n dtype=dtype, device='cpu')\n b = torch.randn(*b_dims, dtype=dtype, device='cpu')\n x_exp = torch.tensor(solve(A.numpy(), b.numpy()), dtype=dtype, device=device)\n A, b = A.to(dtype=dtype, device=device), b.to(dtype=dtype, device=device)\n", "probing input new": " def test_cholesky_solve_batched_broadcasting(self, device, dtype):\n from numpy.linalg import solve\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n def run_test(A_dims, b_dims, upper):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = random_hermitian_pd_matrix(A_matrix_size, *A_batch_dims,\n dtype=dtype, device='cpu')\n b = torch.randn(*b_dims, dtype=dtype, device='cpu')\n x_exp = torch.tensor(solve(A.numpy(), b.numpy()), dtype=dtype, device=device)\n A, b = A.to(dtype=dtype, device=device), b.to(dtype=dtype, device=device)\n L = torch.", "reference": "L=torch.linalg.cholesky(A,upper=upper)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A,upper=upper)", "y_neg": " L = torch.cholesky(A, upper=upper)", "retain": " def test_cholesky_solve_batched_broadcasting(self, device, dtype):\n from numpy.linalg import solve\n from torch.testing._internal.common_utils import random_hermitian_pd_matrix\n\n def run_test(A_dims, b_dims, upper):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = random_hermitian_pd_matrix(A_matrix_size, *A_batch_dims,\n dtype=dtype, device='cpu')\n b = torch.randn(*b_dims, dtype=dtype, device='cpu')\n x_exp = torch.tensor(solve(A.numpy(), b.numpy()), dtype=dtype, device=device)\n A, b = A.to(dtype=dtype, device=device), b.to(dtype=dtype, device=device)\n L = torch.linalg.cholesky(A, upper=upper)\n x = torch.cholesky_solve(b, L, upper=upper)\n self.assertEqual(x, x_exp)\n # https://github.com/pytorch/pytorch/issues/42695\n x = torch.cholesky_solve(b, L, upper=upper, out=x)\n self.assertEqual(x, x_exp)\n\n # test against numpy.linalg.solve\n for upper in [True, False]:\n run_test((2, 1, 3, 4, 4), (2, 1, 3, 4, 6), upper) # no broadcasting\n run_test((2, 1, 3, 4, 4), (4, 6), upper) # broadcasting b\n run_test((4, 4), (2, 1, 3, 4, 2), upper) # broadcasting A\n run_test((1, 3, 1, 4, 4), (2, 1, 3, 4, 5), upper)" }, { "id": 8165, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _cholesky(self, K, add_jitter=False):\n if add_jitter:\n K = K + (self.jitter * K.diagonal().mean()).repeat(K.shape[0]).diagflat()\n try:\n return torch.linalg.cholesky(K)\n except RuntimeError as e:\n print(\"ERROR:\", e.args[0], file=sys.__stdout__)\n if K.isnan().any():\n print(\"ERROR: kernel matrix has NaNs!\", file=sys.__stdout__)\n if K.isinf().any():\n print(\"ERROR: kernel matrix has infinities!\", file=sys.__stdout__)\n self.print_parameters()\n plot_gram(K)\n raise CholeskyException(e.args[0], K, self)", "probing input": " def _cholesky(self, K, add_jitter=False):\n if add_jitter:\n K = K + (self.jitter * K.diagonal().mean()).repeat(K.shape[0]).diagflat()\n try:\n", "probing input new": " def _cholesky(self, K, add_jitter=False):\n if add_jitter:\n K = K + (self.jitter * K.diagonal().mean()).repeat(K.shape[0]).diagflat()\n try:\n return torch.", "reference": "returntorch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(K)", "y_neg": " return torch.cholesky(K)", "retain": " def _cholesky(self, K, add_jitter=False):\n if add_jitter:\n K = K + (self.jitter * K.diagonal().mean()).repeat(K.shape[0]).diagflat()\n try:\n return torch.linalg.cholesky(K)\n except RuntimeError as e:\n print(\"ERROR:\", e.args[0], file=sys.__stdout__)\n if K.isnan().any():\n print(\"ERROR: kernel matrix has NaNs!\", file=sys.__stdout__)\n if K.isinf().any():\n print(\"ERROR: kernel matrix has infinities!\", file=sys.__stdout__)\n self.print_parameters()\n plot_gram(K)\n raise CholeskyException(e.args[0], K, self)" }, { "id": 8166, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n if A.dim() == 2:\n L = torch.linalg.cholesky(A, upper=upper, out=out)\n return L\n else:\n L_list = []\n for idx in range(A.shape[0]):\n L = torch.linalg.cholesky(A[idx], upper=upper, out=out)\n L_list.append(L)\n return torch.stack(L_list, dim=0)\n except:\n isnan = torch.isnan(A)\n if isnan.any():\n raise NanError(\n f\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n )\n\n if jitter is None:\n jitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n Aprime = A.clone()\n jitter_prev = 0\n for i in range(8):\n jitter_new = jitter * (10 ** i)\n Aprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n jitter_prev = jitter_new\n try:\n if Aprime.dim() == 2:\n L = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return L\n else:\n L_list = []\n for idx in range(Aprime.shape[0]):\n L = torch.linalg.cholesky(Aprime[idx], upper=upper, out=out)\n L_list.append(L)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return torch.stack(L_list, dim=0)\n except:\n continue", "probing input": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n if A.dim() == 2:\n", "probing input new": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n if A.dim() == 2:\n L = torch.", "reference": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "y_neg": " L = torch.cholesky(A, upper=upper, out=out)", "retain": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n if A.dim() == 2:\n L = torch.linalg.cholesky(A, upper=upper, out=out)\n return L\n else:\n L_list = []\n for idx in range(A.shape[0]):\n L = torch.linalg.cholesky(A[idx], upper=upper, out=out)\n L_list.append(L)\n return torch.stack(L_list, dim=0)\n except:\n isnan = torch.isnan(A)\n if isnan.any():\n raise NanError(\n f\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n )\n\n if jitter is None:\n jitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n Aprime = A.clone()\n jitter_prev = 0\n for i in range(8):\n jitter_new = jitter * (10 ** i)\n Aprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n jitter_prev = jitter_new\n try:\n if Aprime.dim() == 2:\n L = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return L\n else:\n L_list = []\n for idx in range(Aprime.shape[0]):\n L = torch.linalg.cholesky(Aprime[idx], upper=upper, out=out)\n L_list.append(L)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return torch.stack(L_list, dim=0)\n except:\n continue" }, { "id": 8171, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self) -> torch.Tensor:\n # get sigma/mean or each level\n sigma_w, mu_w = self.implied_sigma_mu()\n sigma_l2, mu_l2 = self.implied_sigma_mu(suffix=\"_l2\")\n\n # decompose into 11, 12, 21, 22\n sigma_b, sigma_xx, sigma_yx, mu_b, mu_x = self._split(sigma_l2, mu_l2)\n\n # cluster FIML -2 * logL (without constants)\n loss = torch.zeros(1, dtype=mu_w.dtype, device=mu_w.device)\n\n # go through each cluster separately\n data_ys_available = ~torch.isnan(self.data_ys)\n cache_S_ij = {}\n cache_S_j_R_j = {}\n sigma_b_logdet = None\n sigma_b_inv = None\n if not self.naive_implementation:\n L_sigma_b = torch.linalg.cholesky(sigma_b)\n sigma_b_logdet = L_sigma_b.diagonal().log().sum() * 2\n sigma_b_inv = torch.cholesky_inverse(L_sigma_b)\n for cluster_slice, batches in self.missing_patterns:\n # get cluster data and define R_j for current cluster j\n cluster_x = self.data_xs[cluster_slice.start, :]\n R_j_index = ~torch.isnan(cluster_x)\n no_cluster = ~R_j_index.any()\n\n # cache\n key = (\n tuple(R_j_index.tolist()),\n tuple(tuple(x) for x in data_ys_available[cluster_slice, :].tolist()),\n )\n sigma_j_logdet, sigma_j_inv = cache_S_j_R_j.get(key, (None, None))\n\n # define S_ij and S_j\n S_ijs = []\n eye_w = torch.eye(mu_w.shape[0], dtype=mu_w.dtype, device=mu_w.device)\n lambda_ijs_logdet_sum = 0.0\n lambda_ijs_inv = []\n A_j = torch.zeros_like(sigma_w)\n for batch_slice in batches:\n size = batch_slice.stop - batch_slice.start\n available = data_ys_available[batch_slice.start]\n S_ij = eye_w[available, :]\n S_ijs.extend([S_ij] * size)\n\n if self.naive_implementation or sigma_j_logdet is not None:\n continue\n\n key_S_ij = tuple(available.tolist())\n lambda_ij_inv, lambda_ij_logdet, a_j = cache_S_ij.get(\n key_S_ij, (None, None, None),\n )\n\n if lambda_ij_inv is None:\n lambda_ij = sigma_w # no missing data\n if S_ij.shape[0] != eye_w.shape[0]:\n # missing data\n lambda_ij = S_ij.mm(sigma_w.mm(S_ij.t()))\n\n L_lambda_ij = torch.linalg.cholesky(lambda_ij)\n lambda_ij_logdet = L_lambda_ij.diagonal().log().sum() * 2\n lambda_ij_inv = torch.cholesky_inverse(L_lambda_ij)\n\n if S_ij.shape[0] != eye_w.shape[0]:\n # missing data\n a_j = S_ij.t().mm(torch.cholesky_solve(S_ij, L_lambda_ij))\n else:\n a_j = lambda_ij_inv\n cache_S_ij[key_S_ij] = lambda_ij_inv, lambda_ij_logdet, a_j\n\n lambda_ijs_inv.extend([lambda_ij_inv] * size)\n lambda_ijs_logdet_sum = lambda_ijs_logdet_sum + lambda_ij_logdet * size\n A_j = A_j + a_j * size\n\n S_j = torch.cat(S_ijs, dim=0)\n\n # means\n y_j = torch.cat(\n [\n self.data_ys[cluster_slice, :][data_ys_available[cluster_slice, :]][\n :, None,\n ],\n cluster_x[R_j_index, None],\n ],\n )\n mu_y = mu_w + mu_b\n mu_j = torch.cat([S_j.mm(mu_y), mu_x[R_j_index]])\n mean_diff = y_j - mu_j\n G_yj = mean_diff.mm(mean_diff.t())\n\n if sigma_j_logdet is None and not self.naive_implementation:\n sigma_b_inv_A_j = sigma_b_inv + A_j\n B_j = torch.inverse(sigma_b_inv_A_j)\n C_j = eye_w - A_j.mm(B_j)\n D_j = C_j.mm(A_j)\n lambda_inv = torch.block_diag(*lambda_ijs_inv)\n V_j_inv = lambda_inv - lambda_inv.mm(\n S_j.mm(B_j.mm(S_j.t().mm(lambda_inv))),\n )\n\n if no_cluster:\n # no cluster\n sigma_11_j = V_j_inv\n sigma_21_j = torch.empty(\n 0, device=sigma_11_j.device, dtype=sigma_11_j.dtype,\n )\n sigma_22_1 = torch.empty(\n [0, 0], device=sigma_11_j.device, dtype=sigma_11_j.dtype,\n )\n sigma_22_inv = sigma_21_j\n\n else:\n # normal case\n sigma_22_1 = (sigma_xx - sigma_yx.t().mm(D_j.mm(sigma_yx)))[\n R_j_index, :,\n ][:, R_j_index]\n sigma_22_inv = torch.inverse(sigma_22_1)\n sigma_jyx = S_j.mm(sigma_yx[:, R_j_index])\n sigma_11_j = (\n V_j_inv.mm(\n sigma_jyx.mm(sigma_22_inv.mm(sigma_jyx.t().mm(V_j_inv))),\n )\n + V_j_inv\n )\n sigma_21_j = -sigma_22_inv.mm(sigma_jyx.t().mm(V_j_inv))\n\n sigma_j_inv = torch.cat(\n [\n torch.cat([sigma_11_j, sigma_21_j]),\n torch.cat([sigma_21_j.t(), sigma_22_inv]),\n ],\n dim=1,\n )\n\n sigma_j_logdet = (\n lambda_ijs_logdet_sum\n + sigma_b_logdet\n + torch.logdet(sigma_b_inv_A_j)\n + torch.logdet(sigma_22_1)\n )\n cache_S_j_R_j[key] = (sigma_j_logdet, sigma_j_inv)\n\n elif sigma_j_logdet is None:\n # naive\n sigma_j = S_j.mm(sigma_b.mm(S_j.t())) + torch.block_diag(\n *[S_ij.mm(sigma_w.mm(S_ij.t())) for S_ij in S_ijs],\n )\n if not no_cluster:\n sigma_j_12 = S_j.mm(sigma_yx[:, R_j_index])\n sigma_j_21 = sigma_j_12.t()\n sigma_j_22 = sigma_xx[R_j_index, :][:, R_j_index]\n sigma_j = torch.cat(\n [\n torch.cat([sigma_j, sigma_j_21]),\n torch.cat([sigma_j_12, sigma_j_22]),\n ],\n dim=1,\n )\n L_sigma_j = torch.linalg.cholesky(sigma_j)\n sigma_j_logdet = L_sigma_j.diagonal().log().sum() * 2\n sigma_j_inv = torch.cholesky_inverse(L_sigma_j)\n\n cache_S_j_R_j[key] = (sigma_j_logdet, sigma_j_inv)\n\n loss_current = sigma_j_logdet + torch.trace(sigma_j_inv.mm(G_yj))\n loss = loss + loss_current.clamp(min=0.0)\n\n return loss", "probing input": " def forward(self) -> torch.Tensor:\n # get sigma/mean or each level\n sigma_w, mu_w = self.implied_sigma_mu()\n sigma_l2, mu_l2 = self.implied_sigma_mu(suffix=\"_l2\")\n\n # decompose into 11, 12, 21, 22\n sigma_b, sigma_xx, sigma_yx, mu_b, mu_x = self._split(sigma_l2, mu_l2)\n\n # cluster FIML -2 * logL (without constants)\n loss = torch.zeros(1, dtype=mu_w.dtype, device=mu_w.device)\n\n # go through each cluster separately\n data_ys_available = ~torch.isnan(self.data_ys)\n cache_S_ij = {}\n cache_S_j_R_j = {}\n sigma_b_logdet = None\n sigma_b_inv = None\n if not self.naive_implementation:\n", "probing input new": " def forward(self) -> torch.Tensor:\n # get sigma/mean or each level\n sigma_w, mu_w = self.implied_sigma_mu()\n sigma_l2, mu_l2 = self.implied_sigma_mu(suffix=\"_l2\")\n\n # decompose into 11, 12, 21, 22\n sigma_b, sigma_xx, sigma_yx, mu_b, mu_x = self._split(sigma_l2, mu_l2)\n\n # cluster FIML -2 * logL (without constants)\n loss = torch.zeros(1, dtype=mu_w.dtype, device=mu_w.device)\n\n # go through each cluster separately\n data_ys_available = ~torch.isnan(self.data_ys)\n cache_S_ij = {}\n cache_S_j_R_j = {}\n sigma_b_logdet = None\n sigma_b_inv = None\n if not self.naive_implementation:\n L_sigma_b = torch.", "reference": "L_sigma_b=torch.linalg.cholesky(sigma_b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_sigma_b=torch.linalg.cholesky(sigma_b)", "y_neg": " L_sigma_b = torch.cholesky(sigma_b)", "retain": " def forward(self) -> torch.Tensor:\n # get sigma/mean or each level\n sigma_w, mu_w = self.implied_sigma_mu()\n sigma_l2, mu_l2 = self.implied_sigma_mu(suffix=\"_l2\")\n\n # decompose into 11, 12, 21, 22\n sigma_b, sigma_xx, sigma_yx, mu_b, mu_x = self._split(sigma_l2, mu_l2)\n\n # cluster FIML -2 * logL (without constants)\n loss = torch.zeros(1, dtype=mu_w.dtype, device=mu_w.device)\n\n # go through each cluster separately\n data_ys_available = ~torch.isnan(self.data_ys)\n cache_S_ij = {}\n cache_S_j_R_j = {}\n sigma_b_logdet = None\n sigma_b_inv = None\n if not self.naive_implementation:\n L_sigma_b = torch.linalg.cholesky(sigma_b)\n sigma_b_logdet = L_sigma_b.diagonal().log().sum() * 2\n sigma_b_inv = torch.cholesky_inverse(L_sigma_b)\n for cluster_slice, batches in self.missing_patterns:\n # get cluster data and define R_j for current cluster j\n cluster_x = self.data_xs[cluster_slice.start, :]\n R_j_index = ~torch.isnan(cluster_x)\n no_cluster = ~R_j_index.any()\n\n # cache\n key = (\n tuple(R_j_index.tolist()),\n tuple(tuple(x) for x in data_ys_available[cluster_slice, :].tolist()),\n )\n sigma_j_logdet, sigma_j_inv = cache_S_j_R_j.get(key, (None, None))\n\n # define S_ij and S_j\n S_ijs = []\n eye_w = torch.eye(mu_w.shape[0], dtype=mu_w.dtype, device=mu_w.device)\n lambda_ijs_logdet_sum = 0.0\n lambda_ijs_inv = []\n A_j = torch.zeros_like(sigma_w)\n for batch_slice in batches:\n size = batch_slice.stop - batch_slice.start\n available = data_ys_available[batch_slice.start]\n S_ij = eye_w[available, :]\n S_ijs.extend([S_ij] * size)\n\n if self.naive_implementation or sigma_j_logdet is not None:\n continue\n\n key_S_ij = tuple(available.tolist())\n lambda_ij_inv, lambda_ij_logdet, a_j = cache_S_ij.get(\n key_S_ij, (None, None, None),\n )\n\n if lambda_ij_inv is None:\n lambda_ij = sigma_w # no missing data\n if S_ij.shape[0] != eye_w.shape[0]:\n # missing data\n lambda_ij = S_ij.mm(sigma_w.mm(S_ij.t()))\n\n L_lambda_ij = torch.linalg.cholesky(lambda_ij)\n lambda_ij_logdet = L_lambda_ij.diagonal().log().sum() * 2\n lambda_ij_inv = torch.cholesky_inverse(L_lambda_ij)\n\n if S_ij.shape[0] != eye_w.shape[0]:\n # missing data\n a_j = S_ij.t().mm(torch.cholesky_solve(S_ij, L_lambda_ij))\n else:\n a_j = lambda_ij_inv\n cache_S_ij[key_S_ij] = lambda_ij_inv, lambda_ij_logdet, a_j\n\n lambda_ijs_inv.extend([lambda_ij_inv] * size)\n lambda_ijs_logdet_sum = lambda_ijs_logdet_sum + lambda_ij_logdet * size\n A_j = A_j + a_j * size\n\n S_j = torch.cat(S_ijs, dim=0)\n\n # means\n y_j = torch.cat(\n [\n self.data_ys[cluster_slice, :][data_ys_available[cluster_slice, :]][\n :, None,\n ],\n cluster_x[R_j_index, None],\n ],\n )\n mu_y = mu_w + mu_b\n mu_j = torch.cat([S_j.mm(mu_y), mu_x[R_j_index]])\n mean_diff = y_j - mu_j\n G_yj = mean_diff.mm(mean_diff.t())\n\n if sigma_j_logdet is None and not self.naive_implementation:\n sigma_b_inv_A_j = sigma_b_inv + A_j\n B_j = torch.inverse(sigma_b_inv_A_j)\n C_j = eye_w - A_j.mm(B_j)\n D_j = C_j.mm(A_j)\n lambda_inv = torch.block_diag(*lambda_ijs_inv)\n V_j_inv = lambda_inv - lambda_inv.mm(\n S_j.mm(B_j.mm(S_j.t().mm(lambda_inv))),\n )\n\n if no_cluster:\n # no cluster\n sigma_11_j = V_j_inv\n sigma_21_j = torch.empty(\n 0, device=sigma_11_j.device, dtype=sigma_11_j.dtype,\n )\n sigma_22_1 = torch.empty(\n [0, 0], device=sigma_11_j.device, dtype=sigma_11_j.dtype,\n )\n sigma_22_inv = sigma_21_j\n\n else:\n # normal case\n sigma_22_1 = (sigma_xx - sigma_yx.t().mm(D_j.mm(sigma_yx)))[\n R_j_index, :,\n ][:, R_j_index]\n sigma_22_inv = torch.inverse(sigma_22_1)\n sigma_jyx = S_j.mm(sigma_yx[:, R_j_index])\n sigma_11_j = (\n V_j_inv.mm(\n sigma_jyx.mm(sigma_22_inv.mm(sigma_jyx.t().mm(V_j_inv))),\n )\n + V_j_inv\n )\n sigma_21_j = -sigma_22_inv.mm(sigma_jyx.t().mm(V_j_inv))\n\n sigma_j_inv = torch.cat(\n [\n torch.cat([sigma_11_j, sigma_21_j]),\n torch.cat([sigma_21_j.t(), sigma_22_inv]),\n ],\n dim=1,\n )\n\n sigma_j_logdet = (\n lambda_ijs_logdet_sum\n + sigma_b_logdet\n + torch.logdet(sigma_b_inv_A_j)\n + torch.logdet(sigma_22_1)\n )\n cache_S_j_R_j[key] = (sigma_j_logdet, sigma_j_inv)\n\n elif sigma_j_logdet is None:\n # naive\n sigma_j = S_j.mm(sigma_b.mm(S_j.t())) + torch.block_diag(\n *[S_ij.mm(sigma_w.mm(S_ij.t())) for S_ij in S_ijs],\n )\n if not no_cluster:\n sigma_j_12 = S_j.mm(sigma_yx[:, R_j_index])\n sigma_j_21 = sigma_j_12.t()\n sigma_j_22 = sigma_xx[R_j_index, :][:, R_j_index]\n sigma_j = torch.cat(\n [\n torch.cat([sigma_j, sigma_j_21]),\n torch.cat([sigma_j_12, sigma_j_22]),\n ],\n dim=1,\n )\n L_sigma_j = torch.linalg.cholesky(sigma_j)\n sigma_j_logdet = L_sigma_j.diagonal().log().sum() * 2\n sigma_j_inv = torch.cholesky_inverse(L_sigma_j)\n\n cache_S_j_R_j[key] = (sigma_j_logdet, sigma_j_inv)\n\n loss_current = sigma_j_logdet + torch.trace(sigma_j_inv.mm(G_yj))\n loss = loss + loss_current.clamp(min=0.0)\n\n return loss" }, { "id": 8175, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(\n self,\n alpha: float,\n gamma: float,\n train_embeddings: torch.Tensor,\n train_y: torch.Tensor,\n device: torch.device = torch.device(\"cpu\"),\n ) -> None:\n # Save values that we need later\n self.alpha = nn.Parameter(torch.tensor(alpha), requires_grad=False)\n self.gamma = nn.Parameter(torch.tensor(gamma), requires_grad=False)\n self.train_embeddings = nn.Parameter(train_embeddings, requires_grad=False)\n\n # Precompute what can be precomputed (cf. to SI)\n self.intercept = nn.Parameter(torch.mean(train_y), requires_grad=False)\n self.scale = nn.Parameter(torch.std(train_y), requires_grad=False)\n train_y = (train_y - self.intercept) / self.scale\n train_kernel = _compute_kernel(\n self.train_embeddings.data,\n self.train_embeddings.data,\n self.gamma.data,\n device=device,\n ) + self.alpha.to(device) * torch.eye(self.train_embeddings.shape[0], device=device)\n self.train_kernel_cholesky = nn.Parameter(\n torch.linalg.cholesky(train_kernel).cpu(), requires_grad=False\n )\n self.dual_coefficients = nn.Parameter(\n torch.cholesky_solve(train_y.unsqueeze(1), self.train_kernel_cholesky)[:, 0].cpu(),\n requires_grad=False,\n )", "probing input": " def fit(\n self,\n alpha: float,\n gamma: float,\n train_embeddings: torch.Tensor,\n train_y: torch.Tensor,\n device: torch.device = torch.device(\"cpu\"),\n ) -> None:\n # Save values that we need later\n self.alpha = nn.Parameter(torch.tensor(alpha), requires_grad=False)\n self.gamma = nn.Parameter(torch.tensor(gamma), requires_grad=False)\n self.train_embeddings = nn.Parameter(train_embeddings, requires_grad=False)\n\n # Precompute what can be precomputed (cf. to SI)\n self.intercept = nn.Parameter(torch.mean(train_y), requires_grad=False)\n self.scale = nn.Parameter(torch.std(train_y), requires_grad=False)\n train_y = (train_y - self.intercept) / self.scale\n train_kernel = _compute_kernel(\n self.train_embeddings.data,\n self.train_embeddings.data,\n self.gamma.data,\n device=device,\n ) + self.alpha.to(device) * torch.eye(self.train_embeddings.shape[0], device=device)\n self.train_kernel_cholesky = nn.Parameter(\n", "probing input new": " def fit(\n self,\n alpha: float,\n gamma: float,\n train_embeddings: torch.Tensor,\n train_y: torch.Tensor,\n device: torch.device = torch.device(\"cpu\"),\n ) -> None:\n # Save values that we need later\n self.alpha = nn.Parameter(torch.tensor(alpha), requires_grad=False)\n self.gamma = nn.Parameter(torch.tensor(gamma), requires_grad=False)\n self.train_embeddings = nn.Parameter(train_embeddings, requires_grad=False)\n\n # Precompute what can be precomputed (cf. to SI)\n self.intercept = nn.Parameter(torch.mean(train_y), requires_grad=False)\n self.scale = nn.Parameter(torch.std(train_y), requires_grad=False)\n train_y = (train_y - self.intercept) / self.scale\n train_kernel = _compute_kernel(\n self.train_embeddings.data,\n self.train_embeddings.data,\n self.gamma.data,\n device=device,\n ) + self.alpha.to(device) * torch.eye(self.train_embeddings.shape[0], device=device)\n self.train_kernel_cholesky = nn.Parameter(\n torch.", "reference": "torch.linalg.cholesky(train_kernel).cpu(),requires_grad=False", "reference dict": { "self.alpha": "nn.Parameter", "self.gamma": "nn.Parameter", "self.train_embeddings": "nn.Parameter", "self.intercept": "nn.Parameter", "self.scale": "nn.Parameter", "self.train_kernel_cholesky": "nn.Parameter", "self.dual_coefficients": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(train_kernel).cpu(),requires_grad=False", "y_neg": " torch.cholesky(train_kernel), requires_grad=False", "retain": " def fit(\n self,\n alpha: float,\n gamma: float,\n train_embeddings: torch.Tensor,\n train_y: torch.Tensor,\n device: torch.device = torch.device(\"cpu\"),\n ) -> None:\n # Save values that we need later\n self.alpha = nn.Parameter(torch.tensor(alpha), requires_grad=False)\n self.gamma = nn.Parameter(torch.tensor(gamma), requires_grad=False)\n self.train_embeddings = nn.Parameter(train_embeddings, requires_grad=False)\n\n # Precompute what can be precomputed (cf. to SI)\n self.intercept = nn.Parameter(torch.mean(train_y), requires_grad=False)\n self.scale = nn.Parameter(torch.std(train_y), requires_grad=False)\n train_y = (train_y - self.intercept) / self.scale\n train_kernel = _compute_kernel(\n self.train_embeddings.data,\n self.train_embeddings.data,\n self.gamma.data,\n device=device,\n ) + self.alpha.to(device) * torch.eye(self.train_embeddings.shape[0], device=device)\n self.train_kernel_cholesky = nn.Parameter(\n torch.linalg.cholesky(train_kernel).cpu(), requires_grad=False\n )\n self.dual_coefficients = nn.Parameter(\n torch.cholesky_solve(train_y.unsqueeze(1), self.train_kernel_cholesky)[:, 0].cpu(),\n requires_grad=False,\n )" }, { "id": 8176, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_reparametrization_parameters(self, sigmas_init, eps = 1e-4):\n \"\"\"\n Compute the paramters for the reparamterization of the sigmas, such that \\sigma = L_lower_init @ L_lower_init.T + torch.exp(log_diag_init) where log_diag_init is a diagonal matrix \n \"\"\"\n\n L_lower_init = torch.linalg.cholesky(sigmas_init)\n log_diag_init = torch.log(torch.ones(self.n_topics, self.n_dims)*1e-4) # initialize diag = (1,...,1)*eps, such that only a small value is added to the diagonal\n\n return L_lower_init, log_diag_init", "probing input": " def get_reparametrization_parameters(self, sigmas_init, eps = 1e-4):\n \"\"\"\n Compute the paramters for the reparamterization of the sigmas, such that \\sigma = L_lower_init @ L_lower_init.T + torch.exp(log_diag_init) where log_diag_init is a diagonal matrix \n \"\"\"\n\n", "probing input new": " def get_reparametrization_parameters(self, sigmas_init, eps = 1e-4):\n \"\"\"\n Compute the paramters for the reparamterization of the sigmas, such that \\sigma = L_lower_init @ L_lower_init.T + torch.exp(log_diag_init) where log_diag_init is a diagonal matrix \n \"\"\"\n\n L_lower_init = torch.", "reference": "L_lower_init=torch.linalg.cholesky(sigmas_init)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "nnf.upsample": "torch.nn.functional.upsample", "nnf.interpolate": "torch.nn.functional.interpolate", "nnf.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nnf.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_lower_init=torch.linalg.cholesky(sigmas_init)", "y_neg": " L_lower_init = torch.cholesky(sigmas_init)", "retain": " def get_reparametrization_parameters(self, sigmas_init, eps = 1e-4):\n \"\"\"\n Compute the paramters for the reparamterization of the sigmas, such that \\sigma = L_lower_init @ L_lower_init.T + torch.exp(log_diag_init) where log_diag_init is a diagonal matrix \n \"\"\"\n\n L_lower_init = torch.linalg.cholesky(sigmas_init)\n log_diag_init = torch.log(torch.ones(self.n_topics, self.n_dims)*1e-4) # initialize diag = (1,...,1)*eps, such that only a small value is added to the diagonal\n\n return L_lower_init, log_diag_init" }, { "id": 8180, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def affine_invariant_distance_torch(x1, x2, diagonal_distance=False):\n \"\"\"\n Compute the affine invariant distance between points on the SPD manifold\n\n Parameters\n ----------\n :param x1: set of SPD matrices (N1 x d x d or b1 x ... x bk x N1 x d x d)\n :param x2: set of SPD matrices (N2 x d x d or b1 x ... x bk x N1 x d x d)\n\n Optional parameters\n -------------------\n :param diagonal_distance: Whole distance matrix, or just the diagonal? If True, we must have `x1 == x2`.\n\n Returns\n -------\n :return: matrix of manifold affine-invariante distance between points in x1 and x2 (N1 x N2 or b1 x ... x bk x N1 x N2)\n \"\"\"\n # If diag, x1 must be equal to x2 and we can return zeros.\n if diagonal_distance is True:\n shape = list(x2.shape)[:-2]\n shape.append(1)\n return torch.zeros(shape, dtype=x1.dtype)\n\n dim = x1.shape[-1]\n\n # Expand dimensions to compute all matrix-matrix distances\n x1 = x1.unsqueeze(-3)\n x2 = x2.unsqueeze(-4)\n\n # Method 1: compute x1^(-1)\n # x1_inv = torch.inverse(x1) # method 1: uses inv(x1)x2\n\n # Method 2: uses the Cholesky decomposition to compute x1^(-0.5)\n x1_chol = torch.linalg.cholesky(x1)\n x1_chol_inv = torch.inverse(x1_chol)\n\n # Repeat x and y data along 1- and 0- dimensions to have ndata_x x ndata_y x dim x dim arrays\n # x1_inv = torch.cat(x2.shape[-3] * [x1_inv], dim=-3) # method 1\n x1_chol_inv = torch.cat(x2.shape[-3] * [x1_chol_inv], dim=-3)\n x2 = torch.cat(x1.shape[-4] * [x2], dim=-4)\n\n # Compute the distance between each pair of matrices\n # Method 1: compute x1\\x2\n # x1_inv_x2 = torch.bmm(x1_inv.view(-1, dim, dim), x2.view(-1, dim, dim)) # method 1\n # x1_inv_x2 = torch.solve(x1, x2).solution.view(-1, dim, dim)\n\n # Method 2: compute x1^(-0.5)*x2*x1^(-0.5)\n # The advantage of this method is that the resulting matrix is symmetric => we can use symeig for the eigenvalues.\n x1_inv_x2_x1_inv = torch.bmm(torch.bmm(x1_chol_inv.view(-1, dim, dim), x2.view(-1, dim, dim)),\n x1_chol_inv.view(-1, dim, dim).transpose(-2, -1))\n\n # x1_inv_x2_x1_inv += 1e-10 * torch.rand(x1_inv_x2_x1_inv.shape)\n\n # Compute norm(logm(x1\\x2))\n eig_values = torch.zeros(x1_inv_x2_x1_inv.shape[0], dim).to(device)\n for i in range(x1_inv_x2_x1_inv.shape[0]):\n eig_values[i] = torch.linalg.eigvalsh(x1_inv_x2_x1_inv[i])\n # eig_values[i] = torch.symeig(x1_inv_x2_x1_inv[i], eigenvectors=True).eigenvalues # Eigenvalue True necessary for derivation\n # eigv[i] = torch.svd(x1_inv_x2_x1_inv[i], some=False).S\n # eigv[i] = torch.eig(x1_inv_x2[i]).eigenvalues[:, 0] # Method 1: first/second column of eigenvalues = real/imaginary parts. Problem: the gradient of eig is not implemented.\n\n # Reshape\n shape = list(x2.shape)[:-2]\n shape.append(eig_values.shape[-1])\n eigv = eig_values.view(shape)\n\n logeigv = torch.log(eigv)\n logeigv2 = logeigv * logeigv\n sumlogeigv2 = torch.sum(logeigv2, dim=-1)\n return torch.sqrt(sumlogeigv2 + 1e-15).double()", "probing input": "def affine_invariant_distance_torch(x1, x2, diagonal_distance=False):\n \"\"\"\n Compute the affine invariant distance between points on the SPD manifold\n\n Parameters\n ----------\n :param x1: set of SPD matrices (N1 x d x d or b1 x ... x bk x N1 x d x d)\n :param x2: set of SPD matrices (N2 x d x d or b1 x ... x bk x N1 x d x d)\n\n Optional parameters\n -------------------\n :param diagonal_distance: Whole distance matrix, or just the diagonal? If True, we must have `x1 == x2`.\n\n Returns\n -------\n :return: matrix of manifold affine-invariante distance between points in x1 and x2 (N1 x N2 or b1 x ... x bk x N1 x N2)\n \"\"\"\n # If diag, x1 must be equal to x2 and we can return zeros.\n if diagonal_distance is True:\n shape = list(x2.shape)[:-2]\n shape.append(1)\n return torch.zeros(shape, dtype=x1.dtype)\n\n dim = x1.shape[-1]\n\n # Expand dimensions to compute all matrix-matrix distances\n x1 = x1.unsqueeze(-3)\n x2 = x2.unsqueeze(-4)\n\n # Method 1: compute x1^(-1)\n # x1_inv = torch.inverse(x1) # method 1: uses inv(x1)x2\n\n # Method 2: uses the Cholesky decomposition to compute x1^(-0.5)\n", "probing input new": "def affine_invariant_distance_torch(x1, x2, diagonal_distance=False):\n \"\"\"\n Compute the affine invariant distance between points on the SPD manifold\n\n Parameters\n ----------\n :param x1: set of SPD matrices (N1 x d x d or b1 x ... x bk x N1 x d x d)\n :param x2: set of SPD matrices (N2 x d x d or b1 x ... x bk x N1 x d x d)\n\n Optional parameters\n -------------------\n :param diagonal_distance: Whole distance matrix, or just the diagonal? If True, we must have `x1 == x2`.\n\n Returns\n -------\n :return: matrix of manifold affine-invariante distance between points in x1 and x2 (N1 x N2 or b1 x ... x bk x N1 x N2)\n \"\"\"\n # If diag, x1 must be equal to x2 and we can return zeros.\n if diagonal_distance is True:\n shape = list(x2.shape)[:-2]\n shape.append(1)\n return torch.zeros(shape, dtype=x1.dtype)\n\n dim = x1.shape[-1]\n\n # Expand dimensions to compute all matrix-matrix distances\n x1 = x1.unsqueeze(-3)\n x2 = x2.unsqueeze(-4)\n\n # Method 1: compute x1^(-1)\n # x1_inv = torch.inverse(x1) # method 1: uses inv(x1)x2\n\n # Method 2: uses the Cholesky decomposition to compute x1^(-0.5)\n x1_chol = torch.", "reference": "x1_chol=torch.linalg.cholesky(x1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "x1_chol=torch.linalg.cholesky(x1)", "y_neg": " x1_chol = torch.cholesky(x1)", "retain": "def affine_invariant_distance_torch(x1, x2, diagonal_distance=False):\n \"\"\"\n Compute the affine invariant distance between points on the SPD manifold\n\n Parameters\n ----------\n :param x1: set of SPD matrices (N1 x d x d or b1 x ... x bk x N1 x d x d)\n :param x2: set of SPD matrices (N2 x d x d or b1 x ... x bk x N1 x d x d)\n\n Optional parameters\n -------------------\n :param diagonal_distance: Whole distance matrix, or just the diagonal? If True, we must have `x1 == x2`.\n\n Returns\n -------\n :return: matrix of manifold affine-invariante distance between points in x1 and x2 (N1 x N2 or b1 x ... x bk x N1 x N2)\n \"\"\"\n # If diag, x1 must be equal to x2 and we can return zeros.\n if diagonal_distance is True:\n shape = list(x2.shape)[:-2]\n shape.append(1)\n return torch.zeros(shape, dtype=x1.dtype)\n\n dim = x1.shape[-1]\n\n # Expand dimensions to compute all matrix-matrix distances\n x1 = x1.unsqueeze(-3)\n x2 = x2.unsqueeze(-4)\n\n # Method 1: compute x1^(-1)\n # x1_inv = torch.inverse(x1) # method 1: uses inv(x1)x2\n\n # Method 2: uses the Cholesky decomposition to compute x1^(-0.5)\n x1_chol = torch.linalg.cholesky(x1)\n x1_chol_inv = torch.inverse(x1_chol)\n\n # Repeat x and y data along 1- and 0- dimensions to have ndata_x x ndata_y x dim x dim arrays\n # x1_inv = torch.cat(x2.shape[-3] * [x1_inv], dim=-3) # method 1\n x1_chol_inv = torch.cat(x2.shape[-3] * [x1_chol_inv], dim=-3)\n x2 = torch.cat(x1.shape[-4] * [x2], dim=-4)\n\n # Compute the distance between each pair of matrices\n # Method 1: compute x1\\x2\n # x1_inv_x2 = torch.bmm(x1_inv.view(-1, dim, dim), x2.view(-1, dim, dim)) # method 1\n # x1_inv_x2 = torch.solve(x1, x2).solution.view(-1, dim, dim)\n\n # Method 2: compute x1^(-0.5)*x2*x1^(-0.5)\n # The advantage of this method is that the resulting matrix is symmetric => we can use symeig for the eigenvalues.\n x1_inv_x2_x1_inv = torch.bmm(torch.bmm(x1_chol_inv.view(-1, dim, dim), x2.view(-1, dim, dim)),\n x1_chol_inv.view(-1, dim, dim).transpose(-2, -1))\n\n # x1_inv_x2_x1_inv += 1e-10 * torch.rand(x1_inv_x2_x1_inv.shape)\n\n # Compute norm(logm(x1\\x2))\n eig_values = torch.zeros(x1_inv_x2_x1_inv.shape[0], dim).to(device)\n for i in range(x1_inv_x2_x1_inv.shape[0]):\n eig_values[i] = torch.linalg.eigvalsh(x1_inv_x2_x1_inv[i])\n # eig_values[i] = torch.symeig(x1_inv_x2_x1_inv[i], eigenvectors=True).eigenvalues # Eigenvalue True necessary for derivation\n # eigv[i] = torch.svd(x1_inv_x2_x1_inv[i], some=False).S\n # eigv[i] = torch.eig(x1_inv_x2[i]).eigenvalues[:, 0] # Method 1: first/second column of eigenvalues = real/imaginary parts. Problem: the gradient of eig is not implemented.\n\n # Reshape\n shape = list(x2.shape)[:-2]\n shape.append(eig_values.shape[-1])\n eigv = eig_values.view(shape)\n\n logeigv = torch.log(eigv)\n logeigv2 = logeigv * logeigv\n sumlogeigv2 = torch.sum(logeigv2, dim=-1)\n return torch.sqrt(sumlogeigv2 + 1e-15).double()" }, { "id": 8181, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def is_pos_def(x):\n if torch.equal(x, x.t()):\n try:\n torch.linalg.cholesky(x)\n return True\n except RuntimeError:\n return False\n else:\n return False", "probing input": "def is_pos_def(x):\n if torch.equal(x, x.t()):\n try:\n", "probing input new": "def is_pos_def(x):\n if torch.equal(x, x.t()):\n try:\n torch.", "reference": "torch.linalg.cholesky(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(x)", "y_neg": " torch.cholesky(x)", "retain": "def is_pos_def(x):\n if torch.equal(x, x.t()):\n try:\n torch.linalg.cholesky(x)\n return True\n except RuntimeError:\n return False\n else:\n return False" }, { "id": 8182, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n if gpr.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += gpr.jitter + gpr.noise # add noise to the diagonal\n elif gpr.noise.dim() ==2:\n Kff = Kff + gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter \n Lff = torch.linalg.cholesky(Kff)\n \n output = []\n for kernel in kernels:\n Kfs = kernel(gpr.X, pred_matrix)\n pack = torch.cat((f_loc_2D, Kfs), dim=1)\n Lffinv_pack = pack.triangular_solve(Lff, upper=False)[0]\n W = Lffinv_pack[:, f_loc_2D.size(1):f_loc_2D.size(1) + M].t()\n Qss = W.matmul(W.t())\n v_2D = Lffinv_pack[:, :f_loc_2D.size(1)]\n loc = W.matmul(v_2D).t().reshape(loc_shape)\n Kss = kernel(pred_matrix)\n cov = Kss - Qss\n output.append((loc, cov))\n \n return output", "probing input": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n if gpr.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += gpr.jitter + gpr.noise # add noise to the diagonal\n elif gpr.noise.dim() ==2:\n Kff = Kff + gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter \n", "probing input new": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n if gpr.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += gpr.jitter + gpr.noise # add noise to the diagonal\n elif gpr.noise.dim() ==2:\n Kff = Kff + gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter \n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": "def decompose_kernels(gpr,pred_matrix,kernels):\n '''\n A function to calculate different kernels contribution to final prediction\n\n ------------------Inputs----------------------------\n gpr: an optimized pyro GP regression model\n pred_matrix: a torch tensor of prediction matrix containing the data points for prediction\n kernels: a list of pyro kernels for decomposition\n\n ------------------Outputs---------------------------\n output: a list of tuples, each tuple contains the mean and covariance of the prediction for each kernel \n '''\n N = len(gpr.X)\n M = pred_matrix.size(0)\n f_loc = gpr.y - gpr.mean_function(gpr.X)\n latent_shape = f_loc.shape[:-1]\n loc_shape = latent_shape + (M,)\n f_loc = f_loc.permute(-1, *range(len(latent_shape)))\n f_loc_2D = f_loc.reshape(N, -1)\n loc_shape = latent_shape + (M,)\n v_2D = f_loc_2D\n Kff = gpr.kernel(gpr.X).contiguous()\n if gpr.noise.dim() <=1:\n Kff.view(-1)[:: N + 1] += gpr.jitter + gpr.noise # add noise to the diagonal\n elif gpr.noise.dim() ==2:\n Kff = Kff + gpr.noise\n Kff.view(-1)[:: N + 1] += gpr.jitter \n Lff = torch.linalg.cholesky(Kff)\n \n output = []\n for kernel in kernels:\n Kfs = kernel(gpr.X, pred_matrix)\n pack = torch.cat((f_loc_2D, Kfs), dim=1)\n Lffinv_pack = pack.triangular_solve(Lff, upper=False)[0]\n W = Lffinv_pack[:, f_loc_2D.size(1):f_loc_2D.size(1) + M].t()\n Qss = W.matmul(W.t())\n v_2D = Lffinv_pack[:, :f_loc_2D.size(1)]\n loc = W.matmul(v_2D).t().reshape(loc_shape)\n Kss = kernel(pred_matrix)\n cov = Kss - Qss\n output.append((loc, cov))\n \n return output" }, { "id": 8183, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, C, v):\n ## iterates are in c, the number of concepts\n c = C.shape[0]\n\n ## size: c x c\n Q = 2*C @ C.T + (torch.eye(c)*self.rho).to(self.device)\n\n # factor Q for quicker solve -- this is critical.\n Q_cho = torch.linalg.cholesky(Q)\n\n # iterates, size: c x batch\n x = torch.randn((c, v.shape[0])).to(self.device)\n z = torch.randn((c, v.shape[0])).to(self.device)\n u = torch.randn((c, v.shape[0])).to(self.device)\n\n for ix in range(self.max_iter):\n z_old = z\n x, z, u = self.step(C@v.T, Q_cho, z, u)\n\n res_prim = torch.linalg.norm(x-z, dim=0)\n res_dual = torch.linalg.norm(self.rho*(z-z_old), dim=0)\n\n if (res_prim.max() < self.tol) and (res_dual.max() < self.tol):\n break\n if self.verbose:\n print(\"Stopping at iteration {}\".format(ix))\n print(\"Prime Residual, r_k: {}\".format(res_prim.mean()))\n print(\"Dual Residual, s_k: {}\".format(res_dual.mean()))\n return z.T", "probing input": " def fit(self, C, v):\n ## iterates are in c, the number of concepts\n c = C.shape[0]\n\n ## size: c x c\n Q = 2*C @ C.T + (torch.eye(c)*self.rho).to(self.device)\n\n # factor Q for quicker solve -- this is critical.\n", "probing input new": " def fit(self, C, v):\n ## iterates are in c, the number of concepts\n c = C.shape[0]\n\n ## size: c x c\n Q = 2*C @ C.T + (torch.eye(c)*self.rho).to(self.device)\n\n # factor Q for quicker solve -- this is critical.\n Q_cho = torch.", "reference": "Q_cho=torch.linalg.cholesky(Q)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Q_cho=torch.linalg.cholesky(Q)", "y_neg": " Q_cho = torch.cholesky(Q)", "retain": " def fit(self, C, v):\n ## iterates are in c, the number of concepts\n c = C.shape[0]\n\n ## size: c x c\n Q = 2*C @ C.T + (torch.eye(c)*self.rho).to(self.device)\n\n # factor Q for quicker solve -- this is critical.\n Q_cho = torch.linalg.cholesky(Q)\n\n # iterates, size: c x batch\n x = torch.randn((c, v.shape[0])).to(self.device)\n z = torch.randn((c, v.shape[0])).to(self.device)\n u = torch.randn((c, v.shape[0])).to(self.device)\n\n for ix in range(self.max_iter):\n z_old = z\n x, z, u = self.step(C@v.T, Q_cho, z, u)\n\n res_prim = torch.linalg.norm(x-z, dim=0)\n res_dual = torch.linalg.norm(self.rho*(z-z_old), dim=0)\n\n if (res_prim.max() < self.tol) and (res_dual.max() < self.tol):\n break\n if self.verbose:\n print(\"Stopping at iteration {}\".format(ix))\n print(\"Prime Residual, r_k: {}\".format(res_prim.mean()))\n print(\"Dual Residual, s_k: {}\".format(res_dual.mean()))\n return z.T" }, { "id": 8185, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def to_cholesky(diag_vector=None, off_diag_vector=None,\n L=None, cov_matrix=None):\n \"\"\"\n Compute Cholesky matrix\n Args:\n diag_vector: diag elements in a vector\n off_diag_vector: off-diagonal elements in a vector\n L: Cholesky matrix\n cov_matrix: Covariance matrix\n\n Returns:\n Cholesky matrix L\n \"\"\"\n if L is not None:\n pass\n elif cov_matrix is None:\n assert diag_vector is not None and off_diag_vector is not None\n L = build_lower_matrix(diag_vector, off_diag_vector)\n elif diag_vector is None and off_diag_vector is None:\n L = torch.linalg.cholesky(cov_matrix)\n else:\n raise RuntimeError(\"Unexpected behaviours\")\n return L", "probing input": "def to_cholesky(diag_vector=None, off_diag_vector=None,\n L=None, cov_matrix=None):\n \"\"\"\n Compute Cholesky matrix\n Args:\n diag_vector: diag elements in a vector\n off_diag_vector: off-diagonal elements in a vector\n L: Cholesky matrix\n cov_matrix: Covariance matrix\n\n Returns:\n Cholesky matrix L\n \"\"\"\n if L is not None:\n pass\n elif cov_matrix is None:\n assert diag_vector is not None and off_diag_vector is not None\n L = build_lower_matrix(diag_vector, off_diag_vector)\n elif diag_vector is None and off_diag_vector is None:\n", "probing input new": "def to_cholesky(diag_vector=None, off_diag_vector=None,\n L=None, cov_matrix=None):\n \"\"\"\n Compute Cholesky matrix\n Args:\n diag_vector: diag elements in a vector\n off_diag_vector: off-diagonal elements in a vector\n L: Cholesky matrix\n cov_matrix: Covariance matrix\n\n Returns:\n Cholesky matrix L\n \"\"\"\n if L is not None:\n pass\n elif cov_matrix is None:\n assert diag_vector is not None and off_diag_vector is not None\n L = build_lower_matrix(diag_vector, off_diag_vector)\n elif diag_vector is None and off_diag_vector is None:\n L = torch.", "reference": "L=torch.linalg.cholesky(cov_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov_matrix)", "y_neg": " L = torch.cholesky(cov_matrix)", "retain": "def to_cholesky(diag_vector=None, off_diag_vector=None,\n L=None, cov_matrix=None):\n \"\"\"\n Compute Cholesky matrix\n Args:\n diag_vector: diag elements in a vector\n off_diag_vector: off-diagonal elements in a vector\n L: Cholesky matrix\n cov_matrix: Covariance matrix\n\n Returns:\n Cholesky matrix L\n \"\"\"\n if L is not None:\n pass\n elif cov_matrix is None:\n assert diag_vector is not None and off_diag_vector is not None\n L = build_lower_matrix(diag_vector, off_diag_vector)\n elif diag_vector is None and off_diag_vector is None:\n L = torch.linalg.cholesky(cov_matrix)\n else:\n raise RuntimeError(\"Unexpected behaviours\")\n return L" }, { "id": 8190, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def gmm(all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + args.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += args.epsilon * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma", "probing input": "def gmm(all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + args.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n", "probing input new": "def gmm(all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + args.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.", "reference": "chol=torch.linalg.cholesky(Covi)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(Covi)", "y_neg": " chol = torch.cholesky(Covi)", "retain": "def gmm(all_fea, pi, mu, all_output): \n Cov = []\n dist = []\n log_probs = []\n \n for i in range(len(mu)):\n temp = all_fea - mu[i]\n predi = all_output[:,i].unsqueeze(dim=-1)\n Covi = torch.matmul(temp.t(), temp * predi.expand_as(temp)) / (predi.sum()) + args.epsilon * torch.eye(temp.shape[1]).cuda()\n try:\n chol = torch.linalg.cholesky(Covi)\n except RuntimeError:\n Covi += args.epsilon * torch.eye(temp.shape[1]).cuda() * 100\n chol = torch.linalg.cholesky(Covi)\n chol_inv = torch.inverse(chol)\n Covi_inv = torch.matmul(chol_inv.t(), chol_inv)\n logdet = torch.logdet(Covi)\n mah_dist = (torch.matmul(temp, Covi_inv) * temp).sum(dim=1)\n log_prob = -0.5*(Covi.shape[0] * np.log(2*math.pi) + logdet + mah_dist) + torch.log(pi)[i]\n Cov.append(Covi)\n log_probs.append(log_prob)\n dist.append(mah_dist)\n Cov = torch.stack(Cov, dim=0)\n dist = torch.stack(dist, dim=0).t()\n log_probs = torch.stack(log_probs, dim=0).t()\n zz = log_probs - torch.logsumexp(log_probs, dim=1, keepdim=True).expand_as(log_probs)\n gamma = torch.exp(zz)\n \n return zz, gamma" }, { "id": 8193, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def jitcholesky(A, jit=1e-6, jitbase=2):\n ridge = 0\n try:\n L = torch.linalg.cholesky(A)\n except RuntimeError:\n scale = A.diag().mean()\n if scale == torch.zeros(1):\n scale = torch.finfo().eps\n ridge = jit * scale\n done = False\n while not done:\n try:\n L = torch.linalg.cholesky(A + ridge * torch.eye(*A.size(), dtype=A.dtype))\n done = True\n except RuntimeError:\n ridge *= jitbase\n if ridge > scale:\n raise RuntimeError(\"cholesky was not successful!\")\n return L, ridge", "probing input": "def jitcholesky(A, jit=1e-6, jitbase=2):\n ridge = 0\n try:\n", "probing input new": "def jitcholesky(A, jit=1e-6, jitbase=2):\n ridge = 0\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A)", "y_neg": " L = torch.cholesky(A + jit * torch.eye(A.size(0), device=A.device),", "retain": "def jitcholesky(A, jit=1e-6, jitbase=2):\n ridge = 0\n try:\n L = torch.linalg.cholesky(A)\n except RuntimeError:\n scale = A.diag().mean()\n if scale == torch.zeros(1):\n scale = torch.finfo().eps\n ridge = jit * scale\n done = False\n while not done:\n try:\n L = torch.linalg.cholesky(A + ridge * torch.eye(*A.size(), dtype=A.dtype))\n done = True\n except RuntimeError:\n ridge *= jitbase\n if ridge > scale:\n raise RuntimeError(\"cholesky was not successful!\")\n return L, ridge" }, { "id": 8197, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky(a: ArrayLike):\n a = _atleast_float_1(a)\n return torch.linalg.cholesky(a)", "probing input": "def cholesky(a: ArrayLike):\n a = _atleast_float_1(a)\n", "probing input new": "def cholesky(a: ArrayLike):\n a = _atleast_float_1(a)\n return torch.", "reference": "returntorch.linalg.cholesky(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(a)", "y_neg": " return torch.cholesky(a)", "retain": "def cholesky(a: ArrayLike):\n a = _atleast_float_1(a)\n return torch.linalg.cholesky(a)" }, { "id": 8199, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def mvn_hellinger_distance(\n p_mean: Tensor, q_mean: Tensor, p_covar: Tensor, q_covar: Tensor\n) -> Tensor:\n \"\"\"Computes the (2)-Hellinger distance between two multivariate normal\n distributions.\n Args:\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the first distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the first distribution, where the covariances\n are (optionally) in the q-batch dim.\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the second distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the second distribution where the covariances\n are (optionally) in the q-batch dim.\n Returns:\n A tensor of shape `batch_shape x dist_shape` denoting the KL-divergence\n between the multivariate Gaussian distributions p and q.\n \"\"\"\n p_logdet = torch.logdet(p_covar).unsqueeze(-1)\n q_logdet = torch.logdet(q_covar).unsqueeze(-1)\n avg_covar = (p_covar + q_covar) / 2\n\n # we need to re-use the cholesky decomp, so we compute it once here\n L_avg = torch.linalg.cholesky(avg_covar)\n L_inv = torch.inverse(L_avg)\n\n # removes one dimension, which needs to be recouped\n pq_logdet = (\n torch.pow(torch.diagonal(L_avg, dim1=-2, dim2=-1), 2)\n .prod(dim=-1, keepdim=True)\n .log()\n )\n base_logterm = 0.25 * (p_logdet + q_logdet) - 0.5 * pq_logdet\n\n mean_diff = p_mean - q_mean\n L_mean_diff = torch.matmul(L_inv, mean_diff)\n exp_logterm = -0.125 * torch.matmul(L_mean_diff.transpose(-2, -1), L_mean_diff)\n sq_hdist = 1 - (base_logterm + exp_logterm.squeeze(-1)).exp()\n return sq_hdist.sqrt()", "probing input": "def mvn_hellinger_distance(\n p_mean: Tensor, q_mean: Tensor, p_covar: Tensor, q_covar: Tensor\n) -> Tensor:\n \"\"\"Computes the (2)-Hellinger distance between two multivariate normal\n distributions.\n Args:\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the first distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the first distribution, where the covariances\n are (optionally) in the q-batch dim.\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the second distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the second distribution where the covariances\n are (optionally) in the q-batch dim.\n Returns:\n A tensor of shape `batch_shape x dist_shape` denoting the KL-divergence\n between the multivariate Gaussian distributions p and q.\n \"\"\"\n p_logdet = torch.logdet(p_covar).unsqueeze(-1)\n q_logdet = torch.logdet(q_covar).unsqueeze(-1)\n avg_covar = (p_covar + q_covar) / 2\n\n # we need to re-use the cholesky decomp, so we compute it once here\n", "probing input new": "def mvn_hellinger_distance(\n p_mean: Tensor, q_mean: Tensor, p_covar: Tensor, q_covar: Tensor\n) -> Tensor:\n \"\"\"Computes the (2)-Hellinger distance between two multivariate normal\n distributions.\n Args:\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the first distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the first distribution, where the covariances\n are (optionally) in the q-batch dim.\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the second distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the second distribution where the covariances\n are (optionally) in the q-batch dim.\n Returns:\n A tensor of shape `batch_shape x dist_shape` denoting the KL-divergence\n between the multivariate Gaussian distributions p and q.\n \"\"\"\n p_logdet = torch.logdet(p_covar).unsqueeze(-1)\n q_logdet = torch.logdet(q_covar).unsqueeze(-1)\n avg_covar = (p_covar + q_covar) / 2\n\n # we need to re-use the cholesky decomp, so we compute it once here\n L_avg = torch.", "reference": "L_avg=torch.linalg.cholesky(avg_covar)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_avg=torch.linalg.cholesky(avg_covar)", "y_neg": " L_avg = torch.cholesky(avg_covar)", "retain": "def mvn_hellinger_distance(\n p_mean: Tensor, q_mean: Tensor, p_covar: Tensor, q_covar: Tensor\n) -> Tensor:\n \"\"\"Computes the (2)-Hellinger distance between two multivariate normal\n distributions.\n Args:\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the first distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the first distribution, where the covariances\n are (optionally) in the q-batch dim.\n p_mean: A `batch_shape x dist_shape x 1`-dim Tensor of means of\n the second distribution.\n q_mean: A `batch_shape x dist_shape x dist_shape`-dim Tensor of\n covariances of the second distribution where the covariances\n are (optionally) in the q-batch dim.\n Returns:\n A tensor of shape `batch_shape x dist_shape` denoting the KL-divergence\n between the multivariate Gaussian distributions p and q.\n \"\"\"\n p_logdet = torch.logdet(p_covar).unsqueeze(-1)\n q_logdet = torch.logdet(q_covar).unsqueeze(-1)\n avg_covar = (p_covar + q_covar) / 2\n\n # we need to re-use the cholesky decomp, so we compute it once here\n L_avg = torch.linalg.cholesky(avg_covar)\n L_inv = torch.inverse(L_avg)\n\n # removes one dimension, which needs to be recouped\n pq_logdet = (\n torch.pow(torch.diagonal(L_avg, dim1=-2, dim2=-1), 2)\n .prod(dim=-1, keepdim=True)\n .log()\n )\n base_logterm = 0.25 * (p_logdet + q_logdet) - 0.5 * pq_logdet\n\n mean_diff = p_mean - q_mean\n L_mean_diff = torch.matmul(L_inv, mean_diff)\n exp_logterm = -0.125 * torch.matmul(L_mean_diff.transpose(-2, -1), L_mean_diff)\n sq_hdist = 1 - (base_logterm + exp_logterm.squeeze(-1)).exp()\n return sq_hdist.sqrt()" }, { "id": 8200, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def update_dict_ridge(x, z, lambd=1e-4):\n \"\"\"Update an (unconstrained) dictionary with ridge regression\n\n This is equivalent to a Newton step with the (L2-regularized) squared\n error objective:\n f(V) = (1/2N) * ||Vz - x||_2^2 + (lambd/2) * ||V||_2^2\n\n x : a batch of observations with shape (n_samples, n_features)\n z : a batch of code vectors with shape (n_samples, n_components)\n lambd : weight decay parameter\n \"\"\"\n rhs = torch.mm(z.T, x)\n M = torch.mm(z.T, z)\n M.diagonal().add_(lambd * x.size(0))\n L = torch.linalg.cholesky(M)\n V = torch.cholesky_solve(rhs, L).T\n\n return V", "probing input": "def update_dict_ridge(x, z, lambd=1e-4):\n \"\"\"Update an (unconstrained) dictionary with ridge regression\n\n This is equivalent to a Newton step with the (L2-regularized) squared\n error objective:\n f(V) = (1/2N) * ||Vz - x||_2^2 + (lambd/2) * ||V||_2^2\n\n x : a batch of observations with shape (n_samples, n_features)\n z : a batch of code vectors with shape (n_samples, n_components)\n lambd : weight decay parameter\n \"\"\"\n rhs = torch.mm(z.T, x)\n M = torch.mm(z.T, z)\n M.diagonal().add_(lambd * x.size(0))\n", "probing input new": "def update_dict_ridge(x, z, lambd=1e-4):\n \"\"\"Update an (unconstrained) dictionary with ridge regression\n\n This is equivalent to a Newton step with the (L2-regularized) squared\n error objective:\n f(V) = (1/2N) * ||Vz - x||_2^2 + (lambd/2) * ||V||_2^2\n\n x : a batch of observations with shape (n_samples, n_features)\n z : a batch of code vectors with shape (n_samples, n_components)\n lambd : weight decay parameter\n \"\"\"\n rhs = torch.mm(z.T, x)\n M = torch.mm(z.T, z)\n M.diagonal().add_(lambd * x.size(0))\n L = torch.", "reference": "L=torch.linalg.cholesky(M)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(M)", "y_neg": " L = torch.cholesky(M)", "retain": "def update_dict_ridge(x, z, lambd=1e-4):\n \"\"\"Update an (unconstrained) dictionary with ridge regression\n\n This is equivalent to a Newton step with the (L2-regularized) squared\n error objective:\n f(V) = (1/2N) * ||Vz - x||_2^2 + (lambd/2) * ||V||_2^2\n\n x : a batch of observations with shape (n_samples, n_features)\n z : a batch of code vectors with shape (n_samples, n_components)\n lambd : weight decay parameter\n \"\"\"\n rhs = torch.mm(z.T, x)\n M = torch.mm(z.T, z)\n M.diagonal().add_(lambd * x.size(0))\n L = torch.linalg.cholesky(M)\n V = torch.cholesky_solve(rhs, L).T\n\n return V" }, { "id": 8205, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, X, return_prior_samples=False):\n \n \n Ku = self.kernel(self.inducing_points) + 2e-6 * torch.eye(self.num_inducing)\n\n Kf = self.kernel(X) + 2e-6 * torch.eye(X.shape[0])\n Kfu = self.kernel(X, self.inducing_points)\n \n self.Lu = torch.linalg.cholesky(Ku + 1e-4 * torch.eye(self.num_inducing))\n\n A = torch.linalg.solve_triangular(self.Lu.permute(0,2,1), Kfu, upper=True, left= False)\n A = torch.linalg.solve_triangular(self.Lu, A, upper=False, left = False)\n\n mean = torch.einsum(\"dnm, md -> nd\", A, self.q_mu)\n\n # Shape (S, S, D)\n self.q_sqrt = (\n torch.zeros((self.num_inducing, self.num_inducing, self.output_dim))\n .to(self.dtype)\n .to(self.device)\n )\n li, lj = torch.tril_indices(self.num_inducing, self.num_inducing)\n self.q_sqrt[li, lj] = self.q_sqrt_tri\n \n SK = torch.einsum(\"nmd, bmd->dnb\", self.q_sqrt, self.q_sqrt) - Ku\n \n B = torch.einsum(\"dmb, dnb -> dmn\", SK, A)\n \n delta_cov = torch.sum(A * B.permute(0, 2, 1), -1)\n K = torch.diagonal(Kf, dim1=1, dim2=2) + delta_cov\n \n # Add layer noise to variance\n if self.log_layer_noise is not None:\n K = K + torch.exp(self.log_layer_noise)\n\n # Add mean function\n if self.mean_function is not None:\n mean = mean + self.mean_function(X)\n \n if return_prior_samples:\n return mean, K, torch.zeros(20, X.shape[0], 1)\n return mean, K", "probing input": " def forward(self, X, return_prior_samples=False):\n \n \n Ku = self.kernel(self.inducing_points) + 2e-6 * torch.eye(self.num_inducing)\n\n Kf = self.kernel(X) + 2e-6 * torch.eye(X.shape[0])\n Kfu = self.kernel(X, self.inducing_points)\n \n", "probing input new": " def forward(self, X, return_prior_samples=False):\n \n \n Ku = self.kernel(self.inducing_points) + 2e-6 * torch.eye(self.num_inducing)\n\n Kf = self.kernel(X) + 2e-6 * torch.eye(X.shape[0])\n Kfu = self.kernel(X, self.inducing_points)\n \n self.Lu = torch.", "reference": "self.Lu=torch.linalg.cholesky(Ku+1e-4*torch.eye(self.num_inducing))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.Lu=torch.linalg.cholesky(Ku+1e-4*torch.eye(self.num_inducing))", "y_neg": " self.Lu = torch.cholesky(Ku)", "retain": " def forward(self, X, return_prior_samples=False):\n \n \n Ku = self.kernel(self.inducing_points) + 2e-6 * torch.eye(self.num_inducing)\n\n Kf = self.kernel(X) + 2e-6 * torch.eye(X.shape[0])\n Kfu = self.kernel(X, self.inducing_points)\n \n self.Lu = torch.linalg.cholesky(Ku + 1e-4 * torch.eye(self.num_inducing))\n\n A = torch.linalg.solve_triangular(self.Lu.permute(0,2,1), Kfu, upper=True, left= False)\n A = torch.linalg.solve_triangular(self.Lu, A, upper=False, left = False)\n\n mean = torch.einsum(\"dnm, md -> nd\", A, self.q_mu)\n\n # Shape (S, S, D)\n self.q_sqrt = (\n torch.zeros((self.num_inducing, self.num_inducing, self.output_dim))\n .to(self.dtype)\n .to(self.device)\n )\n li, lj = torch.tril_indices(self.num_inducing, self.num_inducing)\n self.q_sqrt[li, lj] = self.q_sqrt_tri\n \n SK = torch.einsum(\"nmd, bmd->dnb\", self.q_sqrt, self.q_sqrt) - Ku\n \n B = torch.einsum(\"dmb, dnb -> dmn\", SK, A)\n \n delta_cov = torch.sum(A * B.permute(0, 2, 1), -1)\n K = torch.diagonal(Kf, dim1=1, dim2=2) + delta_cov\n \n # Add layer noise to variance\n if self.log_layer_noise is not None:\n K = K + torch.exp(self.log_layer_noise)\n\n # Add mean function\n if self.mean_function is not None:\n mean = mean + self.mean_function(X)\n \n if return_prior_samples:\n return mean, K, torch.zeros(20, X.shape[0], 1)\n return mean, K" }, { "id": 8206, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, mu, sigma):\n chol_sigma = torch.linalg.cholesky(sigma)\n\n self._mu = torch.nn.Parameter(mu)\n self._chol_sigma = torch.nn.Parameter(chol_sigma)\n\n super().__init__()\n\n self._add_save_attr(\n _mu='torch',\n _chol_sigma='torch'\n )", "probing input": " def __init__(self, mu, sigma):\n", "probing input new": " def __init__(self, mu, sigma):\n chol_sigma = torch.", "reference": "chol_sigma=torch.linalg.cholesky(sigma)", "reference dict": { "self._mu": "torch.nn.Parameter", "self._chol_sigma": "torch.nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_sigma=torch.linalg.cholesky(sigma)", "y_neg": " chol_sigma = torch.cholesky(sigma)", "retain": " def __init__(self, mu, sigma):\n chol_sigma = torch.linalg.cholesky(sigma)\n\n self._mu = torch.nn.Parameter(mu)\n self._chol_sigma = torch.nn.Parameter(chol_sigma)\n\n super().__init__()\n\n self._add_save_attr(\n _mu='torch',\n _chol_sigma='torch'\n )" }, { "id": 8211, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def thompson_sampling_multivariate(\n f_mean: torch.Tensor, f_cov: torch.Tensor,\n gamma: float = 1., random_state: int = 1\n) -> torch.Tensor:\n \"\"\"\n Multi objective sampling.\n\n Parameters:\n -----------\n f_mean: torch.Tensor\n Shape (B, K)\n\n f_cov: torch.Tensor\n Shape (B, K, K)\n\n Returns:\n --------\n ts: torch.Tensor\n Shape (B, K)\n \"\"\"\n assert len(f_mean.shape) == 2 and len(f_cov.shape) == 3\n device = f_mean.device\n generator = torch.Generator(device=device).manual_seed(random_state)\n return f_mean + gamma * torch.einsum(\n 'bij,bj->bi',\n torch.linalg.cholesky(f_cov), # (B, K, K)\n torch.randn(f_mean.shape, device=device, generator=generator) # (B, K)\n )", "probing input": "def thompson_sampling_multivariate(\n f_mean: torch.Tensor, f_cov: torch.Tensor,\n gamma: float = 1., random_state: int = 1\n) -> torch.Tensor:\n \"\"\"\n Multi objective sampling.\n\n Parameters:\n -----------\n f_mean: torch.Tensor\n Shape (B, K)\n\n f_cov: torch.Tensor\n Shape (B, K, K)\n\n Returns:\n --------\n ts: torch.Tensor\n Shape (B, K)\n \"\"\"\n assert len(f_mean.shape) == 2 and len(f_cov.shape) == 3\n device = f_mean.device\n generator = torch.Generator(device=device).manual_seed(random_state)\n return f_mean + gamma * torch.einsum(\n 'bij,bj->bi',\n", "probing input new": "def thompson_sampling_multivariate(\n f_mean: torch.Tensor, f_cov: torch.Tensor,\n gamma: float = 1., random_state: int = 1\n) -> torch.Tensor:\n \"\"\"\n Multi objective sampling.\n\n Parameters:\n -----------\n f_mean: torch.Tensor\n Shape (B, K)\n\n f_cov: torch.Tensor\n Shape (B, K, K)\n\n Returns:\n --------\n ts: torch.Tensor\n Shape (B, K)\n \"\"\"\n assert len(f_mean.shape) == 2 and len(f_cov.shape) == 3\n device = f_mean.device\n generator = torch.Generator(device=device).manual_seed(random_state)\n return f_mean + gamma * torch.einsum(\n 'bij,bj->bi',\n torch.", "reference": "torch.linalg.cholesky(f_cov),", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(f_cov),", "y_neg": " torch.cholesky(f_cov),", "retain": "def thompson_sampling_multivariate(\n f_mean: torch.Tensor, f_cov: torch.Tensor,\n gamma: float = 1., random_state: int = 1\n) -> torch.Tensor:\n \"\"\"\n Multi objective sampling.\n\n Parameters:\n -----------\n f_mean: torch.Tensor\n Shape (B, K)\n\n f_cov: torch.Tensor\n Shape (B, K, K)\n\n Returns:\n --------\n ts: torch.Tensor\n Shape (B, K)\n \"\"\"\n assert len(f_mean.shape) == 2 and len(f_cov.shape) == 3\n device = f_mean.device\n generator = torch.Generator(device=device).manual_seed(random_state)\n return f_mean + gamma * torch.einsum(\n 'bij,bj->bi',\n torch.linalg.cholesky(f_cov), # (B, K, K)\n torch.randn(f_mean.shape, device=device, generator=generator) # (B, K)\n )" }, { "id": 8212, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky(\n x: torch.Tensor, /, *, upper: bool = False, out: Optional[torch.Tensor] = None\n) -> torch.Tensor:\n if not upper:\n return torch.linalg.cholesky(x, out=out)\n else:\n ret = torch.transpose(\n torch.linalg.cholesky(\n torch.transpose(x, dim0=len(x.shape) - 1, dim1=len(x.shape) - 2)\n ),\n dim0=len(x.shape) - 1,\n dim1=len(x.shape) - 2,\n )\n if ivy.exists(out):\n return ivy.inplace_update(out, ret)\n return ret", "probing input": "def cholesky(\n x: torch.Tensor, /, *, upper: bool = False, out: Optional[torch.Tensor] = None\n) -> torch.Tensor:\n if not upper:\n", "probing input new": "def cholesky(\n x: torch.Tensor, /, *, upper: bool = False, out: Optional[torch.Tensor] = None\n) -> torch.Tensor:\n if not upper:\n return torch.", "reference": "returntorch.linalg.cholesky(x,out=out)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(x,out=out)", "y_neg": " return torch.cholesky(x)", "retain": "def cholesky(\n x: torch.Tensor, /, *, upper: bool = False, out: Optional[torch.Tensor] = None\n) -> torch.Tensor:\n if not upper:\n return torch.linalg.cholesky(x, out=out)\n else:\n ret = torch.transpose(\n torch.linalg.cholesky(\n torch.transpose(x, dim0=len(x.shape) - 1, dim1=len(x.shape) - 2)\n ),\n dim0=len(x.shape) - 1,\n dim1=len(x.shape) - 2,\n )\n if ivy.exists(out):\n return ivy.inplace_update(out, ret)\n return ret" }, { "id": 8216, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def estimate_c_tilde_matrix(data: torch.Tensor, data_lagged: torch.Tensor, reversible = True):\n \"\"\" This method can be applied to compute the C\\tilde matrix from time-instant and time-lagged data.\n\n Parameters\n ----------\n data : torch.Tensor\n The time-instant data of shape [batch_size, num_basis].\n data_lagged : torch.Tensor\n The time-lagged data of shape [batch_size, num_basis].\n\n Returns\n -------\n C_tilde : torch.Tensor\n The C tilde matrix of shape [num_basis, num_basis].\n \"\"\"\n \n cov_00, cov_01, cov_11 = compute_covariance_matrix(data, data_lagged)\n _, cov_10, _ = compute_covariance_matrix(data_lagged, data)\n if reversible:\n c_0 = 0.5 * (cov_00 + cov_11)\n c_1 = 0.5 * (cov_01 + cov_10)\n else:\n c_0 = cov_00\n c_1 = cov_01\n\n L = torch.linalg.cholesky(c_0)\n L_inv = torch.inverse(L)\n\n try:\n # C_tilde = torch.chain_matmul(L_inv, c_1, L_inv.t())\n C_tilde = torch.linalg.multi_dot((L_inv, c_1, L_inv.t()))\n except:\n C_tilde = torch.chain_matmul(L_inv, c_1, L_inv.t())\n\n return C_tilde", "probing input": "def estimate_c_tilde_matrix(data: torch.Tensor, data_lagged: torch.Tensor, reversible = True):\n \"\"\" This method can be applied to compute the C\\tilde matrix from time-instant and time-lagged data.\n\n Parameters\n ----------\n data : torch.Tensor\n The time-instant data of shape [batch_size, num_basis].\n data_lagged : torch.Tensor\n The time-lagged data of shape [batch_size, num_basis].\n\n Returns\n -------\n C_tilde : torch.Tensor\n The C tilde matrix of shape [num_basis, num_basis].\n \"\"\"\n \n cov_00, cov_01, cov_11 = compute_covariance_matrix(data, data_lagged)\n _, cov_10, _ = compute_covariance_matrix(data_lagged, data)\n if reversible:\n c_0 = 0.5 * (cov_00 + cov_11)\n c_1 = 0.5 * (cov_01 + cov_10)\n else:\n c_0 = cov_00\n c_1 = cov_01\n\n", "probing input new": "def estimate_c_tilde_matrix(data: torch.Tensor, data_lagged: torch.Tensor, reversible = True):\n \"\"\" This method can be applied to compute the C\\tilde matrix from time-instant and time-lagged data.\n\n Parameters\n ----------\n data : torch.Tensor\n The time-instant data of shape [batch_size, num_basis].\n data_lagged : torch.Tensor\n The time-lagged data of shape [batch_size, num_basis].\n\n Returns\n -------\n C_tilde : torch.Tensor\n The C tilde matrix of shape [num_basis, num_basis].\n \"\"\"\n \n cov_00, cov_01, cov_11 = compute_covariance_matrix(data, data_lagged)\n _, cov_10, _ = compute_covariance_matrix(data_lagged, data)\n if reversible:\n c_0 = 0.5 * (cov_00 + cov_11)\n c_1 = 0.5 * (cov_01 + cov_10)\n else:\n c_0 = cov_00\n c_1 = cov_01\n\n L = torch.", "reference": "L=torch.linalg.cholesky(c_0)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(c_0)", "y_neg": " L = torch.cholesky(c_0)", "retain": "def estimate_c_tilde_matrix(data: torch.Tensor, data_lagged: torch.Tensor, reversible = True):\n \"\"\" This method can be applied to compute the C\\tilde matrix from time-instant and time-lagged data.\n\n Parameters\n ----------\n data : torch.Tensor\n The time-instant data of shape [batch_size, num_basis].\n data_lagged : torch.Tensor\n The time-lagged data of shape [batch_size, num_basis].\n\n Returns\n -------\n C_tilde : torch.Tensor\n The C tilde matrix of shape [num_basis, num_basis].\n \"\"\"\n \n cov_00, cov_01, cov_11 = compute_covariance_matrix(data, data_lagged)\n _, cov_10, _ = compute_covariance_matrix(data_lagged, data)\n if reversible:\n c_0 = 0.5 * (cov_00 + cov_11)\n c_1 = 0.5 * (cov_01 + cov_10)\n else:\n c_0 = cov_00\n c_1 = cov_01\n\n L = torch.linalg.cholesky(c_0)\n L_inv = torch.inverse(L)\n\n try:\n # C_tilde = torch.chain_matmul(L_inv, c_1, L_inv.t())\n C_tilde = torch.linalg.multi_dot((L_inv, c_1, L_inv.t()))\n except:\n C_tilde = torch.chain_matmul(L_inv, c_1, L_inv.t())\n\n return C_tilde" }, { "id": 8217, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _cholesky(a: Numeric):\n return torch.linalg.cholesky(a)", "probing input": "def _cholesky(a: Numeric):\n", "probing input new": "def _cholesky(a: Numeric):\n return torch.", "reference": "returntorch.linalg.cholesky(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(a)", "y_neg": " return torch.cholesky(a)", "retain": "def _cholesky(a: Numeric):\n return torch.linalg.cholesky(a)" }, { "id": 8220, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def safe_cholesky(covariance_matrix, jitter=1e-6):\n \"\"\"Perform a safe cholesky decomposition of the covariance matrix.\n\n If cholesky decomposition raises Runtime error, it adds jitter to the covariance\n matrix.\n\n Parameters\n ----------\n covariance_matrix: torch.Tensor.\n Tensor with dimensions batch x dim x dim.\n jitter: float, optional.\n Jitter to add to the covariance matrix.\n \"\"\"\n try:\n return torch.linalg.cholesky(covariance_matrix)\n except RuntimeError:\n dim = covariance_matrix.shape[-1]\n if jitter > 1:\n # When jitter is too big, then there is some numerical issue and this avoids\n # stack overflow.\n warnings.warn(\"Jitter too big. Maybe some numerical issue somewhere.\")\n return torch.eye(dim)\n return safe_cholesky(\n covariance_matrix + jitter * torch.eye(dim), jitter=10 * jitter\n )", "probing input": "def safe_cholesky(covariance_matrix, jitter=1e-6):\n \"\"\"Perform a safe cholesky decomposition of the covariance matrix.\n\n If cholesky decomposition raises Runtime error, it adds jitter to the covariance\n matrix.\n\n Parameters\n ----------\n covariance_matrix: torch.Tensor.\n Tensor with dimensions batch x dim x dim.\n jitter: float, optional.\n Jitter to add to the covariance matrix.\n \"\"\"\n try:\n", "probing input new": "def safe_cholesky(covariance_matrix, jitter=1e-6):\n \"\"\"Perform a safe cholesky decomposition of the covariance matrix.\n\n If cholesky decomposition raises Runtime error, it adds jitter to the covariance\n matrix.\n\n Parameters\n ----------\n covariance_matrix: torch.Tensor.\n Tensor with dimensions batch x dim x dim.\n jitter: float, optional.\n Jitter to add to the covariance matrix.\n \"\"\"\n try:\n return torch.", "reference": "returntorch.linalg.cholesky(covariance_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(covariance_matrix)", "y_neg": " return torch.cholesky(covariance_matrix + jitter * torch.eye(covariance_matrix.size(1), device=covariance_matrix.device))", "retain": "def safe_cholesky(covariance_matrix, jitter=1e-6):\n \"\"\"Perform a safe cholesky decomposition of the covariance matrix.\n\n If cholesky decomposition raises Runtime error, it adds jitter to the covariance\n matrix.\n\n Parameters\n ----------\n covariance_matrix: torch.Tensor.\n Tensor with dimensions batch x dim x dim.\n jitter: float, optional.\n Jitter to add to the covariance matrix.\n \"\"\"\n try:\n return torch.linalg.cholesky(covariance_matrix)\n except RuntimeError:\n dim = covariance_matrix.shape[-1]\n if jitter > 1:\n # When jitter is too big, then there is some numerical issue and this avoids\n # stack overflow.\n warnings.warn(\"Jitter too big. Maybe some numerical issue somewhere.\")\n return torch.eye(dim)\n return safe_cholesky(\n covariance_matrix + jitter * torch.eye(dim), jitter=10 * jitter\n )" }, { "id": 8221, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cg(self):\n size = 100\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # set up vector rhs\n rhs = torch.randn(size, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs.unsqueeze(dim=1), matrix_chol).squeeze()\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))\n\n # set up matrix rhs\n numcols = 50\n rhs = torch.randn(size, numcols, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, numcols, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))", "probing input": " def test_cg(self):\n size = 100\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # set up vector rhs\n rhs = torch.randn(size, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n", "probing input new": " def test_cg(self):\n size = 100\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # set up vector rhs\n rhs = torch.randn(size, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix, upper=True)", "retain": " def test_cg(self):\n size = 100\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # set up vector rhs\n rhs = torch.randn(size, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs.unsqueeze(dim=1), matrix_chol).squeeze()\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))\n\n # set up matrix rhs\n numcols = 50\n rhs = torch.randn(size, numcols, dtype=torch.float64)\n\n # basic solve\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # solve with init value\n init = torch.randn(size, numcols, dtype=torch.float64)\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, initial_guess=init)\n\n # Check cg\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))" }, { "id": 8222, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=5, max_tridiag_iter=10, max_iter=size, tolerance=0, eps=1e-15\n )\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n eigs = torch.linalg.eigvalsh(matrix)\n for i in range(5):\n approx_eigs = torch.linalg.eigvalsh(t_mats[i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))", "probing input": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=5, max_tridiag_iter=10, max_iter=size, tolerance=0, eps=1e-15\n )\n\n # Check cg\n", "probing input new": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=5, max_tridiag_iter=10, max_iter=size, tolerance=0, eps=1e-15\n )\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix)", "retain": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=5, max_tridiag_iter=10, max_iter=size, tolerance=0, eps=1e-15\n )\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n eigs = torch.linalg.eigvalsh(matrix)\n for i in range(5):\n approx_eigs = torch.linalg.eigvalsh(t_mats[i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))" }, { "id": 8223, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_batch_cg(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))", "probing input": " def test_batch_cg(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # Check cg\n", "probing input new": " def test_batch_cg(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix)", "retain": " def test_batch_cg(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))" }, { "id": 8224, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=8, max_iter=size, max_tridiag_iter=10, tolerance=0, eps=1e-30\n )\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n for i in range(5):\n eigs = torch.linalg.eigvalsh(matrix[i])\n for j in range(8):\n approx_eigs = torch.linalg.eigvalsh(t_mats[j, i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))", "probing input": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=8, max_iter=size, max_tridiag_iter=10, tolerance=0, eps=1e-30\n )\n\n # Check cg\n", "probing input new": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=8, max_iter=size, max_tridiag_iter=10, tolerance=0, eps=1e-30\n )\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix)", "retain": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n solves, t_mats = linear_cg(\n matrix.matmul, rhs=rhs, n_tridiag=8, max_iter=size, max_tridiag_iter=10, tolerance=0, eps=1e-30\n )\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n for i in range(5):\n eigs = torch.linalg.eigvalsh(matrix[i])\n for j in range(8):\n approx_eigs = torch.linalg.eigvalsh(t_mats[j, i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))" }, { "id": 8225, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_batch_cg_init(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # Initial solve\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, max_tridiag_iter=0)\n\n # Initialize with solve\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=1, initial_guess=solves, max_tridiag_iter=0)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))", "probing input": " def test_batch_cg_init(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # Initial solve\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, max_tridiag_iter=0)\n\n # Initialize with solve\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=1, initial_guess=solves, max_tridiag_iter=0)\n\n # Check cg\n", "probing input new": " def test_batch_cg_init(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # Initial solve\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, max_tridiag_iter=0)\n\n # Initialize with solve\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=1, initial_guess=solves, max_tridiag_iter=0)\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix, upper=True)", "retain": " def test_batch_cg_init(self):\n batch = 5\n size = 100\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n # Initial solve\n rhs = torch.randn(batch, size, 50, dtype=torch.float64)\n solves = linear_cg(matrix.matmul, rhs=rhs, max_iter=size, max_tridiag_iter=0)\n\n # Initialize with solve\n solves_with_init = linear_cg(matrix.matmul, rhs=rhs, max_iter=1, initial_guess=solves, max_tridiag_iter=0)\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves_with_init, actual, atol=1e-3, rtol=1e-4))" }, { "id": 8230, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, :: m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)", "probing input": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, :: m + 1] += 1 # add identity matrix to K\n", "probing input new": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, :: m + 1] += 1 # add identity matrix to K\n return torch.", "reference": "returntorch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(K)", "y_neg": " return torch.cholesky(K)", "retain": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.mT / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, :: m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)" }, { "id": 8231, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, :: n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(\n self._batch_shape + self._event_shape + self._event_shape\n )", "probing input": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, :: n + 1] += 1 # add identity matrix to K\n", "probing input new": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, :: n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.", "reference": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "y_neg": " scale_tril = cov_diag_sqrt_unsqueeze * torch.cholesky(K)", "retain": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.mT).contiguous()\n K.view(-1, n * n)[:, :: n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(\n self._batch_shape + self._event_shape + self._event_shape\n )" }, { "id": 8235, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def logdet(self, X):\n\n if self.faster_logdet:\n return 2 * torch.sum(torch.log(torch.diag(torch.linalg.cholesky(X, upper=True))))\n else:\n return torch.logdet(X)", "probing input": " def logdet(self, X):\n\n if self.faster_logdet:\n", "probing input new": " def logdet(self, X):\n\n if self.faster_logdet:\n return 2 * torch.sum(torch.log(torch.diag(torch.", "reference": "return2*torch.sum(torch.log(torch.diag(torch.linalg.cholesky(X,upper=True))))", "reference dict": { "dataset": "torch.utils.data.dataset.Subset", "dataloader": "torch.utils.data.DataLoader", "optD": "optim.Adam", "optG": "optim.Adam", "trainer": "MCRTrainer" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "return2*torch.sum(torch.log(torch.diag(torch.linalg.cholesky(X,upper=True))))", "y_neg": " return 2 * torch.sum(torch.log(torch.diag(torch.cholesky(X).diag())))", "retain": " def logdet(self, X):\n\n if self.faster_logdet:\n return 2 * torch.sum(torch.log(torch.diag(torch.linalg.cholesky(X, upper=True))))\n else:\n return torch.logdet(X)" }, { "id": 8240, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _predict_step(self, *, controls: types.ControlsTorch) -> None:\n # Get previous belief\n prev_mean = self._belief_mean\n prev_covariance = self.belief_covariance\n N, state_dim = prev_mean.shape\n\n # Compute mu_{t+1|t}, covariance, and Jacobian\n pred_mean, dynamics_tril = self.dynamics_model(\n initial_states=prev_mean, controls=controls\n )\n dynamics_covariance = dynamics_tril @ dynamics_tril.transpose(-1, -2)\n dynamics_A_matrix = self.dynamics_model.jacobian(\n initial_states=prev_mean, controls=controls\n )\n assert dynamics_covariance.shape == (N, state_dim, state_dim)\n assert dynamics_A_matrix.shape == (N, state_dim, state_dim)\n\n # Calculate Sigma_{t+1|t}\n pred_information_matrix = fannypack.utils.cholesky_inverse(\n torch.linalg.cholesky(\n dynamics_A_matrix\n @ prev_covariance\n @ dynamics_A_matrix.transpose(-1, -2)\n + dynamics_covariance\n )\n )\n pred_information_vector = (\n pred_information_matrix @ pred_mean[:, :, None]\n ).squeeze(-1)\n\n # Update internal state\n self._belief_mean = pred_mean\n self.information_matrix = pred_information_matrix\n self.information_vector = pred_information_vector", "probing input": " def _predict_step(self, *, controls: types.ControlsTorch) -> None:\n # Get previous belief\n prev_mean = self._belief_mean\n prev_covariance = self.belief_covariance\n N, state_dim = prev_mean.shape\n\n # Compute mu_{t+1|t}, covariance, and Jacobian\n pred_mean, dynamics_tril = self.dynamics_model(\n initial_states=prev_mean, controls=controls\n )\n dynamics_covariance = dynamics_tril @ dynamics_tril.transpose(-1, -2)\n dynamics_A_matrix = self.dynamics_model.jacobian(\n initial_states=prev_mean, controls=controls\n )\n assert dynamics_covariance.shape == (N, state_dim, state_dim)\n assert dynamics_A_matrix.shape == (N, state_dim, state_dim)\n\n # Calculate Sigma_{t+1|t}\n pred_information_matrix = fannypack.utils.cholesky_inverse(\n", "probing input new": " def _predict_step(self, *, controls: types.ControlsTorch) -> None:\n # Get previous belief\n prev_mean = self._belief_mean\n prev_covariance = self.belief_covariance\n N, state_dim = prev_mean.shape\n\n # Compute mu_{t+1|t}, covariance, and Jacobian\n pred_mean, dynamics_tril = self.dynamics_model(\n initial_states=prev_mean, controls=controls\n )\n dynamics_covariance = dynamics_tril @ dynamics_tril.transpose(-1, -2)\n dynamics_A_matrix = self.dynamics_model.jacobian(\n initial_states=prev_mean, controls=controls\n )\n assert dynamics_covariance.shape == (N, state_dim, state_dim)\n assert dynamics_A_matrix.shape == (N, state_dim, state_dim)\n\n # Calculate Sigma_{t+1|t}\n pred_information_matrix = fannypack.utils.cholesky_inverse(\n torch.", "reference": "torch.linalg.cholesky(dynamics_A_matrix@prev_covariance@dynamics_A_matrix.transpose(-1,-2)+dynamics_covariance)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(dynamics_A_matrix@prev_covariance@dynamics_A_matrix.transpose(-1,-2)+dynamics_covariance)", "y_neg": " torch.cholesky(dynamics_covariance + 1e-6 * torch.eye(state_dim))", "retain": " def _predict_step(self, *, controls: types.ControlsTorch) -> None:\n # Get previous belief\n prev_mean = self._belief_mean\n prev_covariance = self.belief_covariance\n N, state_dim = prev_mean.shape\n\n # Compute mu_{t+1|t}, covariance, and Jacobian\n pred_mean, dynamics_tril = self.dynamics_model(\n initial_states=prev_mean, controls=controls\n )\n dynamics_covariance = dynamics_tril @ dynamics_tril.transpose(-1, -2)\n dynamics_A_matrix = self.dynamics_model.jacobian(\n initial_states=prev_mean, controls=controls\n )\n assert dynamics_covariance.shape == (N, state_dim, state_dim)\n assert dynamics_A_matrix.shape == (N, state_dim, state_dim)\n\n # Calculate Sigma_{t+1|t}\n pred_information_matrix = fannypack.utils.cholesky_inverse(\n torch.linalg.cholesky(\n dynamics_A_matrix\n @ prev_covariance\n @ dynamics_A_matrix.transpose(-1, -2)\n + dynamics_covariance\n )\n )\n pred_information_vector = (\n pred_information_matrix @ pred_mean[:, :, None]\n ).squeeze(-1)\n\n # Update internal state\n self._belief_mean = pred_mean\n self.information_matrix = pred_information_matrix\n self.information_vector = pred_information_vector" }, { "id": 8241, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _cholesky(x):\n return x.sqrt() if x.dim() == 1 else torch.linalg.cholesky(x)", "probing input": "def _cholesky(x):\n", "probing input new": "def _cholesky(x):\n return x.sqrt() if x.dim() == 1 else torch.", "reference": "returnx.sqrt()ifx.dim()==1elsetorch.linalg.cholesky(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returnx.sqrt()ifx.dim()==1elsetorch.linalg.cholesky(x)", "y_neg": " return x.sqrt() if x.dim() == 1 else torch.cholesky(x)", "retain": "def _cholesky(x):\n return x.sqrt() if x.dim() == 1 else torch.linalg.cholesky(x)" }, { "id": 8247, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, X, y):\n if self.use_Trans:\n Xm = self.F_transform(X)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n self.Xm_bar = self.X_bar\n K, B = self.GlobalKernel(Xm, Xm)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2 + self.jitter\n # print(K)\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y, L)\n \n Apart1 = y.T@alpha\n Apart2 = torch.sum(torch.log(L.diagonal()))\n\n A = 0.5*( Apart1 + Apart2)[0, 0]\n \n return (A+B)/X.nelement()", "probing input": " def forward(self, X, y):\n if self.use_Trans:\n Xm = self.F_transform(X)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n self.Xm_bar = self.X_bar\n K, B = self.GlobalKernel(Xm, Xm)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2 + self.jitter\n # print(K)\n", "probing input new": " def forward(self, X, y):\n if self.use_Trans:\n Xm = self.F_transform(X)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n self.Xm_bar = self.X_bar\n K, B = self.GlobalKernel(Xm, Xm)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2 + self.jitter\n # print(K)\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": { "K, B": "self.GlobalKernel", "Xm": "self.F_transform", "self.Xm_bar": "self.F_transform" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K + torch.diag(dK**0.5))", "retain": " def forward(self, X, y):\n if self.use_Trans:\n Xm = self.F_transform(X)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n self.Xm_bar = self.X_bar\n K, B = self.GlobalKernel(Xm, Xm)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2 + self.jitter\n # print(K)\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y, L)\n \n Apart1 = y.T@alpha\n Apart2 = torch.sum(torch.log(L.diagonal()))\n\n A = 0.5*( Apart1 + Apart2)[0, 0]\n \n return (A+B)/X.nelement()" }, { "id": 8248, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def predict(self, X, y, X_new): # Predict at new locations\n if self.use_Trans:\n Xm = self.F_transform(X)\n Xm_new = self.F_transform(X_new)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n Xm_new = X_new\n self.Xm_bar = self.X_bar\n\n K = self.GlobalKernel(Xm, Xm)\n K_star = self.GlobalKernel(Xm_new, Xm)\n K_star_star = self.GlobalKernel(Xm_new, Xm_new)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y, L)\n\n pred_mean = K_star@alpha\n\n v = torch.cholesky_solve(K_star.T, L)\n pred_var = K_star_star - K_star@v\n\n dpred_var = pred_var.diagonal()\n dpred_var += self.global_gp_noise_std**2\n return pred_mean, pred_var", "probing input": " def predict(self, X, y, X_new): # Predict at new locations\n if self.use_Trans:\n Xm = self.F_transform(X)\n Xm_new = self.F_transform(X_new)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n Xm_new = X_new\n self.Xm_bar = self.X_bar\n\n K = self.GlobalKernel(Xm, Xm)\n K_star = self.GlobalKernel(Xm_new, Xm)\n K_star_star = self.GlobalKernel(Xm_new, Xm_new)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2\n", "probing input new": " def predict(self, X, y, X_new): # Predict at new locations\n if self.use_Trans:\n Xm = self.F_transform(X)\n Xm_new = self.F_transform(X_new)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n Xm_new = X_new\n self.Xm_bar = self.X_bar\n\n K = self.GlobalKernel(Xm, Xm)\n K_star = self.GlobalKernel(Xm_new, Xm)\n K_star_star = self.GlobalKernel(Xm_new, Xm_new)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": { "K": "self.GlobalKernel", "K_star": "self.GlobalKernel", "K_star_star": "self.GlobalKernel", "Xm": "self.F_transform", "Xm_new": "self.F_transform", "self.Xm_bar": "self.F_transform" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K + dK * torch.eye(len(dK)))", "retain": " def predict(self, X, y, X_new): # Predict at new locations\n if self.use_Trans:\n Xm = self.F_transform(X)\n Xm_new = self.F_transform(X_new)\n self.Xm_bar = self.F_transform(self.X_bar)\n else:\n Xm = X\n Xm_new = X_new\n self.Xm_bar = self.X_bar\n\n K = self.GlobalKernel(Xm, Xm)\n K_star = self.GlobalKernel(Xm_new, Xm)\n K_star_star = self.GlobalKernel(Xm_new, Xm_new)\n\n dK = K.diagonal()\n dK += self.global_gp_noise_std**2\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y, L)\n\n pred_mean = K_star@alpha\n\n v = torch.cholesky_solve(K_star.T, L)\n pred_var = K_star_star - K_star@v\n\n dpred_var = pred_var.diagonal()\n dpred_var += self.global_gp_noise_std**2\n return pred_mean, pred_var" }, { "id": 8250, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_cholesky_inverse(input_data):\n m = torch.cholesky_inverse\n inp = torch.mm(input_data, input_data.t()) + 1e-05 * torch.eye(\n input_data.shape[0]\n ) # make symmetric positive definite\n u = torch.linalg.cholesky(inp) # pylint: disable=C0103\n output = m(u)\n output_musa = m(u.musa())\n assert testing.DefaultComparator(abs_diff=1e-5)(output, output_musa)", "probing input": "def test_cholesky_inverse(input_data):\n m = torch.cholesky_inverse\n inp = torch.mm(input_data, input_data.t()) + 1e-05 * torch.eye(\n input_data.shape[0]\n ) # make symmetric positive definite\n", "probing input new": "def test_cholesky_inverse(input_data):\n m = torch.cholesky_inverse\n inp = torch.mm(input_data, input_data.t()) + 1e-05 * torch.eye(\n input_data.shape[0]\n ) # make symmetric positive definite\n u = torch.", "reference": "u=torch.linalg.cholesky(inp)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "u=torch.linalg.cholesky(inp)", "y_neg": " u = torch.cholesky(inp)", "retain": "def test_cholesky_inverse(input_data):\n m = torch.cholesky_inverse\n inp = torch.mm(input_data, input_data.t()) + 1e-05 * torch.eye(\n input_data.shape[0]\n ) # make symmetric positive definite\n u = torch.linalg.cholesky(inp) # pylint: disable=C0103\n output = m(u)\n output_musa = m(u.musa())\n assert testing.DefaultComparator(abs_diff=1e-5)(output, output_musa)" }, { "id": 8251, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def set(self, distr): \n \"\"\"Sets distribution\"\"\"\n assert 'mean' in distr and 'cov' in distr\n \n self.distr = distr.copy()\n self.mean = distr['mean']\n assert isinstance(self.mean, np.ndarray)\n\n self.ndims = len(self.mean)\n self.cov = distr['cov']\n assert isinstance(self.cov, np.ndarray)\n\n # Bounds for denormalization\n self.low, self.high = None, None\n if 'low' in distr:\n assert 'high' in distr\n # Assume samples to be normalized from [low, high] to [0 , 1]\n # Save bounds to potentially denormalize samples\n self.low = np.array(distr['low'])\n self.high = np.array(distr['high'])\n\n # Transform sigma into L\n self.to_mean = torch.tensor(self.mean)\n\n to_cov = torch.tensor(self.cov)\n L = torch.linalg.cholesky(to_cov).double()\n D = L.size(0)\n mask = torch.ones(D, D).tril(-1).bool() # all elements strictly below the main diagonal\n self.L_low_diag = torch.zeros(D, D).double()\n\n self.L_off_diag = torch.tensor(L[mask]) # off-diagonal elements of the lower-side\n self.log_diag_L = torch.log(L.diag()) # log-transformed elements of diagional\n\n self.to_mean.requires_grad_(True) # optimize means\n self.L_off_diag.requires_grad_(True) # optimize lower off-diagonal elements of L\n self.log_diag_L.requires_grad_(True) # optimize log-diagonal elements of L\n\n self.L_low_diag[mask] = self.L_off_diag\n self.to_L = self.L_low_diag + torch.eye(D)*torch.exp(self.log_diag_L) # propagates gradients correctly, instead of using L\n self.L = self.to_L.clone().detach()\n\n self.to_distr = MultivariateNormal(loc=self.to_mean,\n covariance_matrix=None,\n precision_matrix=None,\n scale_tril=self.to_L)\n\n\n self.to_params = [self.to_mean, self.L_off_diag, self.log_diag_L]", "probing input": " def set(self, distr): \n \"\"\"Sets distribution\"\"\"\n assert 'mean' in distr and 'cov' in distr\n \n self.distr = distr.copy()\n self.mean = distr['mean']\n assert isinstance(self.mean, np.ndarray)\n\n self.ndims = len(self.mean)\n self.cov = distr['cov']\n assert isinstance(self.cov, np.ndarray)\n\n # Bounds for denormalization\n self.low, self.high = None, None\n if 'low' in distr:\n assert 'high' in distr\n # Assume samples to be normalized from [low, high] to [0 , 1]\n # Save bounds to potentially denormalize samples\n self.low = np.array(distr['low'])\n self.high = np.array(distr['high'])\n\n # Transform sigma into L\n self.to_mean = torch.tensor(self.mean)\n\n to_cov = torch.tensor(self.cov)\n", "probing input new": " def set(self, distr): \n \"\"\"Sets distribution\"\"\"\n assert 'mean' in distr and 'cov' in distr\n \n self.distr = distr.copy()\n self.mean = distr['mean']\n assert isinstance(self.mean, np.ndarray)\n\n self.ndims = len(self.mean)\n self.cov = distr['cov']\n assert isinstance(self.cov, np.ndarray)\n\n # Bounds for denormalization\n self.low, self.high = None, None\n if 'low' in distr:\n assert 'high' in distr\n # Assume samples to be normalized from [low, high] to [0 , 1]\n # Save bounds to potentially denormalize samples\n self.low = np.array(distr['low'])\n self.high = np.array(distr['high'])\n\n # Transform sigma into L\n self.to_mean = torch.tensor(self.mean)\n\n to_cov = torch.tensor(self.cov)\n L = torch.", "reference": "L=torch.linalg.cholesky(to_cov).double()", "reference dict": { "self.to_distr": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(to_cov).double()", "y_neg": " L = torch.cholesky(to_cov)", "retain": " def set(self, distr): \n \"\"\"Sets distribution\"\"\"\n assert 'mean' in distr and 'cov' in distr\n \n self.distr = distr.copy()\n self.mean = distr['mean']\n assert isinstance(self.mean, np.ndarray)\n\n self.ndims = len(self.mean)\n self.cov = distr['cov']\n assert isinstance(self.cov, np.ndarray)\n\n # Bounds for denormalization\n self.low, self.high = None, None\n if 'low' in distr:\n assert 'high' in distr\n # Assume samples to be normalized from [low, high] to [0 , 1]\n # Save bounds to potentially denormalize samples\n self.low = np.array(distr['low'])\n self.high = np.array(distr['high'])\n\n # Transform sigma into L\n self.to_mean = torch.tensor(self.mean)\n\n to_cov = torch.tensor(self.cov)\n L = torch.linalg.cholesky(to_cov).double()\n D = L.size(0)\n mask = torch.ones(D, D).tril(-1).bool() # all elements strictly below the main diagonal\n self.L_low_diag = torch.zeros(D, D).double()\n\n self.L_off_diag = torch.tensor(L[mask]) # off-diagonal elements of the lower-side\n self.log_diag_L = torch.log(L.diag()) # log-transformed elements of diagional\n\n self.to_mean.requires_grad_(True) # optimize means\n self.L_off_diag.requires_grad_(True) # optimize lower off-diagonal elements of L\n self.log_diag_L.requires_grad_(True) # optimize log-diagonal elements of L\n\n self.L_low_diag[mask] = self.L_off_diag\n self.to_L = self.L_low_diag + torch.eye(D)*torch.exp(self.log_diag_L) # propagates gradients correctly, instead of using L\n self.L = self.to_L.clone().detach()\n\n self.to_distr = MultivariateNormal(loc=self.to_mean,\n covariance_matrix=None,\n precision_matrix=None,\n scale_tril=self.to_L)\n\n\n self.to_params = [self.to_mean, self.L_off_diag, self.log_diag_L]" }, { "id": 8252, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def hist_match(target: Tensor, source: Tensor, mode: str = \"chol\", eps: float = 1):\n target = target.permute(3, 0, 1, 2)\n source = source.permute(3, 0, 1, 2)\n c, b, h, w = target.shape\n\n if mode == \"cdf\":\n matched = cdf_match(target.view(c, -1), source.view(c, -1)).view(c, b, h, w)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(c, -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=target.device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(c, -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=target.device)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.linalg.eigh(cov_s, UPLO=\"U\")\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n else: # mode == \"sym\"\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.linalg.eigh(Qt_Cs_Qt, UPLO=\"U\")\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(c, b, h, w) + mu_s\n\n return matched.permute(1, 2, 3, 0)", "probing input": "def hist_match(target: Tensor, source: Tensor, mode: str = \"chol\", eps: float = 1):\n target = target.permute(3, 0, 1, 2)\n source = source.permute(3, 0, 1, 2)\n c, b, h, w = target.shape\n\n if mode == \"cdf\":\n matched = cdf_match(target.view(c, -1), source.view(c, -1)).view(c, b, h, w)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(c, -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=target.device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(c, -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=target.device)\n\n if mode == \"chol\":\n", "probing input new": "def hist_match(target: Tensor, source: Tensor, mode: str = \"chol\", eps: float = 1):\n target = target.permute(3, 0, 1, 2)\n source = source.permute(3, 0, 1, 2)\n c, b, h, w = target.shape\n\n if mode == \"cdf\":\n matched = cdf_match(target.view(c, -1), source.view(c, -1)).view(c, b, h, w)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(c, -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=target.device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(c, -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=target.device)\n\n if mode == \"chol\":\n chol_t = torch.", "reference": "chol_t=torch.linalg.cholesky(cov_t)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_t=torch.linalg.cholesky(cov_t)", "y_neg": " chol_t = torch.cholesky(cov_t)", "retain": "def hist_match(target: Tensor, source: Tensor, mode: str = \"chol\", eps: float = 1):\n target = target.permute(3, 0, 1, 2)\n source = source.permute(3, 0, 1, 2)\n c, b, h, w = target.shape\n\n if mode == \"cdf\":\n matched = cdf_match(target.view(c, -1), source.view(c, -1)).view(c, b, h, w)\n\n else:\n # based on https://github.com/ProGamerGov/Neural-Tools/blob/master/linear-color-transfer.py#L36\n\n mu_t = target.mean((2, 3), keepdim=True)\n hist_t = (target - mu_t).view(c, -1) # [c, b * h * w]\n cov_t = hist_t @ hist_t.T / hist_t.shape[1] + eps * torch.eye(hist_t.shape[0], device=target.device)\n\n mu_s = source.mean((2, 3), keepdim=True)\n hist_s = (source - mu_s).view(c, -1)\n cov_s = hist_s @ hist_s.T / hist_s.shape[1] + eps * torch.eye(hist_s.shape[0], device=target.device)\n\n if mode == \"chol\":\n chol_t = torch.linalg.cholesky(cov_t)\n chol_s = torch.linalg.cholesky(cov_s)\n matched = chol_s @ torch.inverse(chol_t) @ hist_t\n\n elif mode == \"pca\":\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n eva_s, eve_s = torch.linalg.eigh(cov_s, UPLO=\"U\")\n Qs = eve_s @ torch.sqrt(torch.diag(eva_s)) @ eve_s.T\n matched = Qs @ torch.inverse(Qt) @ hist_t\n\n else: # mode == \"sym\"\n eva_t, eve_t = torch.linalg.eigh(cov_t, UPLO=\"U\")\n Qt = eve_t @ torch.sqrt(torch.diag(eva_t)) @ eve_t.T\n Qt_Cs_Qt = Qt @ cov_s @ Qt\n eva_QtCsQt, eve_QtCsQt = torch.linalg.eigh(Qt_Cs_Qt, UPLO=\"U\")\n QtCsQt = eve_QtCsQt @ torch.sqrt(torch.diag(eva_QtCsQt)) @ eve_QtCsQt.T\n matched = torch.inverse(Qt) @ QtCsQt @ torch.inverse(Qt) @ hist_t\n\n matched = matched.view(c, b, h, w) + mu_s\n\n return matched.permute(1, 2, 3, 0)" }, { "id": 8253, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n L = torch.linalg.cholesky(K)\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n Alpha = torch.cholesky_solve(y_train, L, upper = False)\n \n # return - 0.5 * (Alpha.T @ Alpha + log_det_K + len(x_train) * np.log(2 * np.pi))\n return - 0.5 * ( (Alpha ** 2).sum() + log_det_K + len(x_train) * np.log(2 * np.pi))", "probing input": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n", "probing input new": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K)", "retain": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n L = torch.linalg.cholesky(K)\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n Alpha = torch.cholesky_solve(y_train, L, upper = False)\n \n # return - 0.5 * (Alpha.T @ Alpha + log_det_K + len(x_train) * np.log(2 * np.pi))\n return - 0.5 * ( (Alpha ** 2).sum() + log_det_K + len(x_train) * np.log(2 * np.pi))" }, { "id": 8258, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky_inv(X, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.linalg.cholesky(X)\n diag -= damping\n return torch.cholesky_inverse(u)", "probing input": "def cholesky_inv(X, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n", "probing input new": "def cholesky_inv(X, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.", "reference": "u=torch.linalg.cholesky(X)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "u=torch.linalg.cholesky(X)", "y_neg": " u = torch.cholesky(X / diag.unsqueeze(-1).expand_as(X))", "retain": "def cholesky_inv(X, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.linalg.cholesky(X)\n diag -= damping\n return torch.cholesky_inverse(u)" }, { "id": 8259, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky_solve(X, b, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.linalg.cholesky(X)\n diag -= damping\n return torch.cholesky_solve(b, u)", "probing input": "def cholesky_solve(X, b, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n", "probing input new": "def cholesky_solve(X, b, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.", "reference": "u=torch.linalg.cholesky(X)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "u=torch.linalg.cholesky(X)", "y_neg": " u = torch.cholesky(X + torch.diag(diag))", "retain": "def cholesky_solve(X, b, damping=1e-7):\n diag = torch.diagonal(X)\n diag += damping\n u = torch.linalg.cholesky(X)\n diag -= damping\n return torch.cholesky_solve(b, u)" }, { "id": 8264, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y_train\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n var = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y_train, L)\n mu = K_s.T @ alpha\n v = L.inverse() @ K_s\n var = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n mu = K_s.T @ K_inv @ y_train\n var = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n \n return mu.squeeze(), var", "probing input": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n", "probing input new": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K_s + torch.eye(len(K_s)))", "retain": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y_train\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n var = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y_train, L)\n mu = K_s.T @ alpha\n v = L.inverse() @ K_s\n var = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n mu = K_s.T @ K_inv @ y_train\n var = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n \n return mu.squeeze(), var" }, { "id": 8265, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var \n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y_train.T @ K_inv @ y_train + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * ((gamma.T @ gamma).sum() + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky3':\n L = torch.linalg.cholesky(K)\n if y_train.shape[1] > 1:\n Warning('y_use.shape[1] > 1, will treat each column as a sample (for the joint normal distribution) and sum the log-likelihood')\n # \n # (Alpha ** 2).sum() = (Alpha @ Alpha^T).diag().sum() = \\sum_i (Alpha @ Alpha^T)_{ii}\n # \n y_dim = y_train.shape[1]\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n gamma = torch.cholesky_solve(y_train, L, upper = False)\n return - 0.5 * ( (gamma ** 2).sum() + log_det_K * y_dim + len(y_train) * y_dim * np.log(2 * np.pi) )\n else:\n gamma = torch.cholesky_solve(y_train, L, upper = False)\n return -0.5 * (gamma.T @ gamma + 2 * L.diag().log().sum() + len(y_train) * np.log(2 * np.pi))\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n return -0.5 * (y_train.T @ K_inv @ y_train + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.linalg.cholesky(K)\n return torch.distributions.MultivariateNormal(y_train, scale_tril=L).log_prob(y_train)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y_train, K).log_prob(y_train)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')", "probing input": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var \n \n if Kinv_method == 'cholesky1':\n", "probing input new": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var \n \n if Kinv_method == 'cholesky1':\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K)", "retain": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n if isinstance(y_train, list):\n y_train_var = y_train[1]\n y_train = y_train[0]\n else:\n y_train_var = None\n\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n if y_train_var is not None:\n K = K + y_train_var \n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y_train.T @ K_inv @ y_train + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * ((gamma.T @ gamma).sum() + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky3':\n L = torch.linalg.cholesky(K)\n if y_train.shape[1] > 1:\n Warning('y_use.shape[1] > 1, will treat each column as a sample (for the joint normal distribution) and sum the log-likelihood')\n # \n # (Alpha ** 2).sum() = (Alpha @ Alpha^T).diag().sum() = \\sum_i (Alpha @ Alpha^T)_{ii}\n # \n y_dim = y_train.shape[1]\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n gamma = torch.cholesky_solve(y_train, L, upper = False)\n return - 0.5 * ( (gamma ** 2).sum() + log_det_K * y_dim + len(y_train) * y_dim * np.log(2 * np.pi) )\n else:\n gamma = torch.cholesky_solve(y_train, L, upper = False)\n return -0.5 * (gamma.T @ gamma + 2 * L.diag().log().sum() + len(y_train) * np.log(2 * np.pi))\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n return -0.5 * (y_train.T @ K_inv @ y_train + 2 * torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.linalg.cholesky(K)\n return torch.distributions.MultivariateNormal(y_train, scale_tril=L).log_prob(y_train)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y_train, K).log_prob(y_train)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')" }, { "id": 8269, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n L = torch.linalg.cholesky(K)\n \n # y_dim = y_train.shape[1]\n # log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n # Alpha = torch.cholesky_solve(y_train, L, upper = False)\n # return - 0.5 * ( (Alpha ** 2).sum() + log_det_K * y_dim + len(x_train) * y_dim * np.log(2 * np.pi) )\n \n # L = torch.linalg.cholesky(K)\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n Alpha = torch.cholesky_solve(y_train, L, upper = False)\n \n # return - 0.5 * (Alpha.T @ Alpha + log_det_K + len(x_train) * np.log(2 * np.pi))\n return - 0.5 * ( (Alpha ** 2).sum() + log_det_K + len(x_train) * np.log(2 * np.pi))", "probing input": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n", "probing input new": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K)", "retain": " def log_likelihood(self, x_train, y_train):\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n L = torch.linalg.cholesky(K)\n \n # y_dim = y_train.shape[1]\n # log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n # Alpha = torch.cholesky_solve(y_train, L, upper = False)\n # return - 0.5 * ( (Alpha ** 2).sum() + log_det_K * y_dim + len(x_train) * y_dim * np.log(2 * np.pi) )\n \n # L = torch.linalg.cholesky(K)\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n Alpha = torch.cholesky_solve(y_train, L, upper = False)\n \n # return - 0.5 * (Alpha.T @ Alpha + log_det_K + len(x_train) * np.log(2 * np.pi))\n return - 0.5 * ( (Alpha ** 2).sum() + log_det_K + len(x_train) * np.log(2 * np.pi))" }, { "id": 8275, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def multivariate_stats(x):\n \"\"\"\n Given a time series x, estimate the mean (mu) and the square root of\n the covariance (sigma) for that time series.\n Inputs:\n x: tensor of shape (tensor(mb_size, channels)) containing the sequence values\n Outputs:\n mu: tensor of shape: (channels,) containing the mean estimates\n sigma: tensor of shape: ((channels, channels) containing an estimate of\n the lower Cholesky factor of the covariance matrix.\n\n TODO: To improve numerical stability, Use an SVD to compute the Cholesky\n factor rather than the naive formula.\n \"\"\"\n # Create tensor version of x in case it isn't already\n if not isinstance(x, torch.Tensor):\n x = torch.tensor(x)\n\n mb_size, channels = x.shape\n mu = torch.mean(x, dim=0)\n error = x - mu.unsqueeze(0).expand((mb_size, channels))\n # error is mb_size x channels\n error1 = error.unsqueeze(2)\n # error1 represents e (mb_size, channels, 1)\n error2 = error.unsqueeze(1)\n # error2 represents e^T (mb_size, 1, channels)\n cov = torch.mean(torch.matmul(error1, error2), dim=0)\n # cov is (channels, channels)\n\n # Return cholesky factor\n sigma = torch.linalg.cholesky(cov)\n return mu, sigma", "probing input": "def multivariate_stats(x):\n \"\"\"\n Given a time series x, estimate the mean (mu) and the square root of\n the covariance (sigma) for that time series.\n Inputs:\n x: tensor of shape (tensor(mb_size, channels)) containing the sequence values\n Outputs:\n mu: tensor of shape: (channels,) containing the mean estimates\n sigma: tensor of shape: ((channels, channels) containing an estimate of\n the lower Cholesky factor of the covariance matrix.\n\n TODO: To improve numerical stability, Use an SVD to compute the Cholesky\n factor rather than the naive formula.\n \"\"\"\n # Create tensor version of x in case it isn't already\n if not isinstance(x, torch.Tensor):\n x = torch.tensor(x)\n\n mb_size, channels = x.shape\n mu = torch.mean(x, dim=0)\n error = x - mu.unsqueeze(0).expand((mb_size, channels))\n # error is mb_size x channels\n error1 = error.unsqueeze(2)\n # error1 represents e (mb_size, channels, 1)\n error2 = error.unsqueeze(1)\n # error2 represents e^T (mb_size, 1, channels)\n cov = torch.mean(torch.matmul(error1, error2), dim=0)\n # cov is (channels, channels)\n\n # Return cholesky factor\n", "probing input new": "def multivariate_stats(x):\n \"\"\"\n Given a time series x, estimate the mean (mu) and the square root of\n the covariance (sigma) for that time series.\n Inputs:\n x: tensor of shape (tensor(mb_size, channels)) containing the sequence values\n Outputs:\n mu: tensor of shape: (channels,) containing the mean estimates\n sigma: tensor of shape: ((channels, channels) containing an estimate of\n the lower Cholesky factor of the covariance matrix.\n\n TODO: To improve numerical stability, Use an SVD to compute the Cholesky\n factor rather than the naive formula.\n \"\"\"\n # Create tensor version of x in case it isn't already\n if not isinstance(x, torch.Tensor):\n x = torch.tensor(x)\n\n mb_size, channels = x.shape\n mu = torch.mean(x, dim=0)\n error = x - mu.unsqueeze(0).expand((mb_size, channels))\n # error is mb_size x channels\n error1 = error.unsqueeze(2)\n # error1 represents e (mb_size, channels, 1)\n error2 = error.unsqueeze(1)\n # error2 represents e^T (mb_size, 1, channels)\n cov = torch.mean(torch.matmul(error1, error2), dim=0)\n # cov is (channels, channels)\n\n # Return cholesky factor\n sigma = torch.", "reference": "sigma=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "sigma=torch.linalg.cholesky(cov)", "y_neg": " sigma = torch.cholesky(cov + 1e-6 * torch.eye(channels).unsqueeze(0).unsqueeze(0).expand(channels, channels, channels, channels))", "retain": "def multivariate_stats(x):\n \"\"\"\n Given a time series x, estimate the mean (mu) and the square root of\n the covariance (sigma) for that time series.\n Inputs:\n x: tensor of shape (tensor(mb_size, channels)) containing the sequence values\n Outputs:\n mu: tensor of shape: (channels,) containing the mean estimates\n sigma: tensor of shape: ((channels, channels) containing an estimate of\n the lower Cholesky factor of the covariance matrix.\n\n TODO: To improve numerical stability, Use an SVD to compute the Cholesky\n factor rather than the naive formula.\n \"\"\"\n # Create tensor version of x in case it isn't already\n if not isinstance(x, torch.Tensor):\n x = torch.tensor(x)\n\n mb_size, channels = x.shape\n mu = torch.mean(x, dim=0)\n error = x - mu.unsqueeze(0).expand((mb_size, channels))\n # error is mb_size x channels\n error1 = error.unsqueeze(2)\n # error1 represents e (mb_size, channels, 1)\n error2 = error.unsqueeze(1)\n # error2 represents e^T (mb_size, 1, channels)\n cov = torch.mean(torch.matmul(error1, error2), dim=0)\n # cov is (channels, channels)\n\n # Return cholesky factor\n sigma = torch.linalg.cholesky(cov)\n return mu, sigma" }, { "id": 8276, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __cholesky(self):\n weight = self.weight.squeeze(dim=0)\n pos_semidef_matrix = torch.matmul(weight, weight.permute(0, 1, 3, 2))\n return torch.linalg.cholesky(pos_semidef_matrix + self.eps_eye)", "probing input": " def __cholesky(self):\n weight = self.weight.squeeze(dim=0)\n pos_semidef_matrix = torch.matmul(weight, weight.permute(0, 1, 3, 2))\n", "probing input new": " def __cholesky(self):\n weight = self.weight.squeeze(dim=0)\n pos_semidef_matrix = torch.matmul(weight, weight.permute(0, 1, 3, 2))\n return torch.", "reference": "returntorch.linalg.cholesky(pos_semidef_matrix+self.eps_eye)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(pos_semidef_matrix+self.eps_eye)", "y_neg": " return torch.cholesky(pos_semidef_matrix + self.diag_matrix)", "retain": " def __cholesky(self):\n weight = self.weight.squeeze(dim=0)\n pos_semidef_matrix = torch.matmul(weight, weight.permute(0, 1, 3, 2))\n return torch.linalg.cholesky(pos_semidef_matrix + self.eps_eye)" }, { "id": 8277, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __cholesky(self):\n return torch.linalg.cholesky(self.__covariance())", "probing input": " def __cholesky(self):\n", "probing input new": " def __cholesky(self):\n return torch.", "reference": "returntorch.linalg.cholesky(self.__covariance())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(self.__covariance())", "y_neg": " return torch.cholesky(self.A)", "retain": " def __cholesky(self):\n return torch.linalg.cholesky(self.__covariance())" }, { "id": 8281, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7,1e-6,1e-5,1e-4,1e-3,1e-2]:#,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.linalg.cholesky(self.kzz + kx @ kx.t() / self.sigma + self.eye*reg)\n L = torch.linalg.cholesky(torch.cholesky_inverse(chol_L))\n # L = torch.linalg.cholesky(torch.inverse(self.kzz + self.eye*self.sigma))\n self.L = torch.nn.Parameter(L)\n L_set = True\n except Exception as e:\n gc.collect()\n print('cholesky init error: ',reg)\n print(e)\n # torch.cuda.empty_cache()\n if not L_set:\n print(\"Welp this is awkward, it don't want to factorize\")\n\n gc.collect()\n # torch.cuda.empty_cache()\n L = torch.randn_like(self.kzz) * 0.1\n self.L = torch.nn.Parameter(L)\n inv_set=False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:#, 1e-1, 1.0,2.5,5.0,10.]:\n self.reg=reg\n try:\n if not self.parametrize_Z:\n with torch.no_grad():\n self.register_buffer('inv_L', torch.linalg.cholesky(self.kzz + self.eye * self.reg))\n self.register_buffer('inv_Z',torch.cholesky_inverse(self.inv_L))\n inv_set=True\n except Exception as e:\n gc.collect()\n print(e)\n print('cholesky inv error: ',reg)\n pass\n if not inv_set:\n gc.collect()\n self.parametrize_Z=True", "probing input": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7,1e-6,1e-5,1e-4,1e-3,1e-2]:#,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n", "probing input new": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7,1e-6,1e-5,1e-4,1e-3,1e-2]:#,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.", "reference": "chol_L=torch.linalg.cholesky(self.kzz+kx@kx.t()/self.sigma+self.eye*reg)", "reference dict": { "self.L": "torch.nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_L=torch.linalg.cholesky(self.kzz+kx@kx.t()/self.sigma+self.eye*reg)", "y_neg": " chol_L = torch.cholesky(self.kzz + reg * torch.eye(self.N))", "retain": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7,1e-6,1e-5,1e-4,1e-3,1e-2]:#,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.linalg.cholesky(self.kzz + kx @ kx.t() / self.sigma + self.eye*reg)\n L = torch.linalg.cholesky(torch.cholesky_inverse(chol_L))\n # L = torch.linalg.cholesky(torch.inverse(self.kzz + self.eye*self.sigma))\n self.L = torch.nn.Parameter(L)\n L_set = True\n except Exception as e:\n gc.collect()\n print('cholesky init error: ',reg)\n print(e)\n # torch.cuda.empty_cache()\n if not L_set:\n print(\"Welp this is awkward, it don't want to factorize\")\n\n gc.collect()\n # torch.cuda.empty_cache()\n L = torch.randn_like(self.kzz) * 0.1\n self.L = torch.nn.Parameter(L)\n inv_set=False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]:#, 1e-1, 1.0,2.5,5.0,10.]:\n self.reg=reg\n try:\n if not self.parametrize_Z:\n with torch.no_grad():\n self.register_buffer('inv_L', torch.linalg.cholesky(self.kzz + self.eye * self.reg))\n self.register_buffer('inv_Z',torch.cholesky_inverse(self.inv_L))\n inv_set=True\n except Exception as e:\n gc.collect()\n print(e)\n print('cholesky inv error: ',reg)\n pass\n if not inv_set:\n gc.collect()\n self.parametrize_Z=True" }, { "id": 8282, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self,x1,x2=None):\n L = torch.tril(self.L)+self.eye*self.reg\n L = ensure_pos_diag(L)\n Z= self.Z\n if x2 is None:\n kzx = self.k(Z, x1).evaluate()\n t= L.t() @ kzx #L\\cdot k(Z,X)\n\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n chol_z = torch.linalg.cholesky(kzz+self.eye*self.reg)\n sol = torch.cholesky_solve(kzx,chol_z)\n else:\n # sol = torch.cholesky_solve(kzx, self.inv_L)\n sol = self.inv_Z @ kzx\n if len(t.shape)==3: #t=[L^T k(Z,X_i),L^T k(Z,X_{i+1}),]\n T_mat = t.permute(0,2,1) @ t #T_mat ok\n inverse_part = kzx.permute(0,2,1)@sol\n out = self.k(x1).evaluate()- inverse_part + T_mat#/self.sigma\n return out\n else:\n T_mat = t.t() @ t\n out =self.k(x1).evaluate()- kzx.t()@sol + T_mat#/self.sigma\n return out\n else:\n kzx_1 = self.k(Z, x1).evaluate()\n kzx_2 = self.k(Z, x2).evaluate()\n t= L.t() @ kzx_2\n t_ = kzx_1.t() @ L\n T_mat = t_ @ t\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n chol_z = torch.linalg.cholesky(kzz + self.eye * self.reg)\n sol = torch.cholesky_solve(kzx_2, chol_z)\n else:\n # sol = torch.cholesky_solve(kzx_2, self.inv_L)\n sol = self.inv_Z @ kzx_2\n out=self.k(x1, x2).evaluate() - kzx_1.t() @ sol +T_mat#/self.sigma\n return out", "probing input": " def forward(self,x1,x2=None):\n L = torch.tril(self.L)+self.eye*self.reg\n L = ensure_pos_diag(L)\n Z= self.Z\n if x2 is None:\n kzx = self.k(Z, x1).evaluate()\n t= L.t() @ kzx #L\\cdot k(Z,X)\n\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n", "probing input new": " def forward(self,x1,x2=None):\n L = torch.tril(self.L)+self.eye*self.reg\n L = ensure_pos_diag(L)\n Z= self.Z\n if x2 is None:\n kzx = self.k(Z, x1).evaluate()\n t= L.t() @ kzx #L\\cdot k(Z,X)\n\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n chol_z = torch.", "reference": "chol_z=torch.linalg.cholesky(kzz+self.eye*self.reg)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_z=torch.linalg.cholesky(kzz+self.eye*self.reg)", "y_neg": " chol_z = torch.cholesky(kzz)", "retain": " def forward(self,x1,x2=None):\n L = torch.tril(self.L)+self.eye*self.reg\n L = ensure_pos_diag(L)\n Z= self.Z\n if x2 is None:\n kzx = self.k(Z, x1).evaluate()\n t= L.t() @ kzx #L\\cdot k(Z,X)\n\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n chol_z = torch.linalg.cholesky(kzz+self.eye*self.reg)\n sol = torch.cholesky_solve(kzx,chol_z)\n else:\n # sol = torch.cholesky_solve(kzx, self.inv_L)\n sol = self.inv_Z @ kzx\n if len(t.shape)==3: #t=[L^T k(Z,X_i),L^T k(Z,X_{i+1}),]\n T_mat = t.permute(0,2,1) @ t #T_mat ok\n inverse_part = kzx.permute(0,2,1)@sol\n out = self.k(x1).evaluate()- inverse_part + T_mat#/self.sigma\n return out\n else:\n T_mat = t.t() @ t\n out =self.k(x1).evaluate()- kzx.t()@sol + T_mat#/self.sigma\n return out\n else:\n kzx_1 = self.k(Z, x1).evaluate()\n kzx_2 = self.k(Z, x2).evaluate()\n t= L.t() @ kzx_2\n t_ = kzx_1.t() @ L\n T_mat = t_ @ t\n if self.parametrize_Z:\n kzz = self.k(Z).evaluate()\n chol_z = torch.linalg.cholesky(kzz + self.eye * self.reg)\n sol = torch.cholesky_solve(kzx_2, chol_z)\n else:\n # sol = torch.cholesky_solve(kzx_2, self.inv_L)\n sol = self.inv_Z @ kzx_2\n out=self.k(x1, x2).evaluate() - kzx_1.t() @ sol +T_mat#/self.sigma\n return out" }, { "id": 8283, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(S, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term", "probing input": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n", "probing input new": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.", "reference": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "y_neg": " K_mm_chol = torch.cholesky(K_mm + _add_diagonal_jitter(torch.eye(m, device=x.device), self.jitter))", "retain": " def variational_loss(self, x, y, noise, mu_hat, A_hat):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(S, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term" }, { "id": 8284, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def ortho_norm(weight):\n wtw = torch.mm(weight.t(), weight) + 1e-4 * torch.eye(weight.shape[1]).to(weight.device)\n L = torch.linalg.cholesky(wtw)\n weight_ortho = torch.mm(weight, L.inverse().t())\n return weight_ortho", "probing input": "def ortho_norm(weight):\n wtw = torch.mm(weight.t(), weight) + 1e-4 * torch.eye(weight.shape[1]).to(weight.device)\n", "probing input new": "def ortho_norm(weight):\n wtw = torch.mm(weight.t(), weight) + 1e-4 * torch.eye(weight.shape[1]).to(weight.device)\n L = torch.", "reference": "L=torch.linalg.cholesky(wtw)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(wtw)", "y_neg": " L = torch.cholesky(wtw)", "retain": "def ortho_norm(weight):\n wtw = torch.mm(weight.t(), weight) + 1e-4 * torch.eye(weight.shape[1]).to(weight.device)\n L = torch.linalg.cholesky(wtw)\n weight_ortho = torch.mm(weight, L.inverse().t())\n return weight_ortho" }, { "id": 8285, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def stable_kalman_gain(H, P, Sigma_pred):\n # Kalman gain, a more stable implementation than naive P @ H^T @ y_sigma^{-1}\n L = torch.linalg.cholesky(Sigma_pred)\n K = torch.triangular_solve(H @ P.transpose(1, 2), L, upper=False)[0]\n K = torch.triangular_solve(K, L.transpose(1, 2))[0].transpose(1, 2)\n return K", "probing input": "def stable_kalman_gain(H, P, Sigma_pred):\n # Kalman gain, a more stable implementation than naive P @ H^T @ y_sigma^{-1}\n", "probing input new": "def stable_kalman_gain(H, P, Sigma_pred):\n # Kalman gain, a more stable implementation than naive P @ H^T @ y_sigma^{-1}\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma_pred)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma_pred)", "y_neg": " L = torch.cholesky(Sigma_pred + H.T @ P @ H)", "retain": "def stable_kalman_gain(H, P, Sigma_pred):\n # Kalman gain, a more stable implementation than naive P @ H^T @ y_sigma^{-1}\n L = torch.linalg.cholesky(Sigma_pred)\n K = torch.triangular_solve(H @ P.transpose(1, 2), L, upper=False)[0]\n K = torch.triangular_solve(K, L.transpose(1, 2))[0].transpose(1, 2)\n return K" }, { "id": 8291, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_det_by_cholesky(matrix):\n \"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)", "probing input": "def log_det_by_cholesky(matrix):\n \"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n", "probing input new": "def log_det_by_cholesky(matrix):\n \"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.", "reference": "chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(matrix)", "y_neg": " chol = torch.cholesky(matrix)", "retain": "def log_det_by_cholesky(matrix):\n \"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)" }, { "id": 8292, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_cholesky_inverse(matrix):\n \"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n chol_low = torch.linalg.cholesky(matrix)\n # chol_low = torch.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)", "probing input": "def batch_cholesky_inverse(matrix):\n \"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n", "probing input new": "def batch_cholesky_inverse(matrix):\n \"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n chol_low = torch.", "reference": "chol_low=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_low=torch.linalg.cholesky(matrix)", "y_neg": " chol_low = torch.cholesky(matrix)", "retain": "def batch_cholesky_inverse(matrix):\n \"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n chol_low = torch.linalg.cholesky(matrix)\n # chol_low = torch.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)" }, { "id": 8293, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # ,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.linalg.cholesky(self.kzz + kx @ kx.t() / self.sigma + self.eye * reg)\n L = torch.linalg.cholesky(torch.cholesky_inverse(chol_L))\n # L = torch.linalg.cholesky(torch.inverse(self.kzz + self.eye*self.sigma))\n self.L = torch.nn.Parameter(L)\n L_set = True\n except Exception as e:\n gc.collect()\n print('cholesky init error: ', reg)\n print(e)\n # torch.cuda.empty_cache()\n if not L_set:\n print(\"Welp this is awkward, it don't want to factorize\")\n\n gc.collect()\n # torch.cuda.empty_cache()\n L = torch.randn_like(self.kzz) * 0.1\n self.L = torch.nn.Parameter(L)\n inv_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # , 1e-1, 1.0,2.5,5.0,10.]:\n self.reg = reg\n try:\n if not self.parametrize_Z:\n with torch.no_grad():\n self.register_buffer('inv_L', torch.linalg.cholesky(self.kzz + self.eye * self.reg))\n self.register_buffer('inv_Z', torch.cholesky_inverse(self.inv_L))\n inv_set = True\n except Exception as e:\n gc.collect()\n print(e)\n print('cholesky inv error: ', reg)\n pass\n if not inv_set:\n gc.collect()\n self.parametrize_Z = True", "probing input": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # ,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n", "probing input new": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # ,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.", "reference": "chol_L=torch.linalg.cholesky(self.kzz+kx@kx.t()/self.sigma+self.eye*reg)", "reference dict": { "self.L": "torch.nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_L=torch.linalg.cholesky(self.kzz+kx@kx.t()/self.sigma+self.eye*reg)", "y_neg": " chol_L = torch.cholesky(self.kzz + reg * torch.eye(self.N))", "retain": " def init_L(self):\n with torch.no_grad():\n kx = self.k(self.Z, self.X).evaluate()\n self.kzz = self.k(self.Z).evaluate()\n L_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # ,1e-1,1.0,5.0,10.]:\n try:\n with torch.no_grad():\n chol_L = torch.linalg.cholesky(self.kzz + kx @ kx.t() / self.sigma + self.eye * reg)\n L = torch.linalg.cholesky(torch.cholesky_inverse(chol_L))\n # L = torch.linalg.cholesky(torch.inverse(self.kzz + self.eye*self.sigma))\n self.L = torch.nn.Parameter(L)\n L_set = True\n except Exception as e:\n gc.collect()\n print('cholesky init error: ', reg)\n print(e)\n # torch.cuda.empty_cache()\n if not L_set:\n print(\"Welp this is awkward, it don't want to factorize\")\n\n gc.collect()\n # torch.cuda.empty_cache()\n L = torch.randn_like(self.kzz) * 0.1\n self.L = torch.nn.Parameter(L)\n inv_set = False\n for reg in [1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2]: # , 1e-1, 1.0,2.5,5.0,10.]:\n self.reg = reg\n try:\n if not self.parametrize_Z:\n with torch.no_grad():\n self.register_buffer('inv_L', torch.linalg.cholesky(self.kzz + self.eye * self.reg))\n self.register_buffer('inv_Z', torch.cholesky_inverse(self.inv_L))\n inv_set = True\n except Exception as e:\n gc.collect()\n print(e)\n print('cholesky inv error: ', reg)\n pass\n if not inv_set:\n gc.collect()\n self.parametrize_Z = True" }, { "id": 8296, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_log_prob(batch_shape, dim):\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.linalg.cholesky(A.matmul(A.transpose(-2, -1)))\n x = torch.randn(batch_shape + (dim,))\n df = torch.randn(batch_shape).exp() + 2\n actual_log_prob = MultivariateStudentT(df, loc, scale_tril).log_prob(x)\n\n if dim == 1:\n expected_log_prob = (\n StudentT(df.unsqueeze(-1), loc, scale_tril[..., 0]).log_prob(x).sum(-1)\n )\n assert_equal(actual_log_prob, expected_log_prob)\n\n # test the fact MVT(df, loc, scale)(x) = int MVN(loc, scale / m)(x) Gamma(df/2,df/2)(m) dm\n num_samples = 100000\n gamma_samples = Gamma(df / 2, df / 2).sample(sample_shape=(num_samples,))\n mvn_scale_tril = scale_tril / gamma_samples.sqrt().unsqueeze(-1).unsqueeze(-1)\n mvn = MultivariateNormal(loc, scale_tril=mvn_scale_tril)\n expected_log_prob = mvn.log_prob(x).logsumexp(0) - math.log(num_samples)\n assert_equal(actual_log_prob, expected_log_prob, prec=0.01)", "probing input": "def test_log_prob(batch_shape, dim):\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n", "probing input new": "def test_log_prob(batch_shape, dim):\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(A.matmul(A.transpose(-2,-1)))", "reference dict": { "mvn": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(A.matmul(A.transpose(-2,-1)))", "y_neg": " scale_tril = torch.cholesky(A)", "retain": "def test_log_prob(batch_shape, dim):\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.linalg.cholesky(A.matmul(A.transpose(-2, -1)))\n x = torch.randn(batch_shape + (dim,))\n df = torch.randn(batch_shape).exp() + 2\n actual_log_prob = MultivariateStudentT(df, loc, scale_tril).log_prob(x)\n\n if dim == 1:\n expected_log_prob = (\n StudentT(df.unsqueeze(-1), loc, scale_tril[..., 0]).log_prob(x).sum(-1)\n )\n assert_equal(actual_log_prob, expected_log_prob)\n\n # test the fact MVT(df, loc, scale)(x) = int MVN(loc, scale / m)(x) Gamma(df/2,df/2)(m) dm\n num_samples = 100000\n gamma_samples = Gamma(df / 2, df / 2).sample(sample_shape=(num_samples,))\n mvn_scale_tril = scale_tril / gamma_samples.sqrt().unsqueeze(-1).unsqueeze(-1)\n mvn = MultivariateNormal(loc, scale_tril=mvn_scale_tril)\n expected_log_prob = mvn.log_prob(x).logsumexp(0) - math.log(num_samples)\n assert_equal(actual_log_prob, expected_log_prob, prec=0.01)" }, { "id": 8297, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_mean_var(batch_shape):\n dim = 2\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.linalg.cholesky(A.matmul(A.transpose(-2, -1)))\n df = torch.randn(batch_shape).exp() + 4\n num_samples = 100000\n d = MultivariateStudentT(df, loc, scale_tril)\n samples = d.sample(sample_shape=(num_samples,))\n expected_mean = samples.mean(0)\n expected_variance = samples.var(0)\n assert_equal(d.mean, expected_mean, prec=0.1)\n assert_equal(d.variance, expected_variance, prec=0.2)\n\n assert_equal(\n MultivariateStudentT(0.5, loc, scale_tril).mean,\n torch.full(batch_shape + (dim,), float(\"nan\")),\n )\n assert_equal(\n MultivariateStudentT(0.5, loc, scale_tril).variance,\n torch.full(batch_shape + (dim,), float(\"nan\")),\n )\n assert_equal(\n MultivariateStudentT(1.5, loc, scale_tril).variance,\n torch.full(batch_shape + (dim,), float(\"inf\")),\n )", "probing input": "def test_mean_var(batch_shape):\n dim = 2\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n", "probing input new": "def test_mean_var(batch_shape):\n dim = 2\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(A.matmul(A.transpose(-2,-1)))", "reference dict": { "d": "MultivariateStudentT" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(A.matmul(A.transpose(-2,-1)))", "y_neg": " scale_tril = torch.cholesky(A)", "retain": "def test_mean_var(batch_shape):\n dim = 2\n loc = torch.randn(batch_shape + (dim,))\n A = torch.randn(batch_shape + (dim, dim + dim))\n scale_tril = torch.linalg.cholesky(A.matmul(A.transpose(-2, -1)))\n df = torch.randn(batch_shape).exp() + 4\n num_samples = 100000\n d = MultivariateStudentT(df, loc, scale_tril)\n samples = d.sample(sample_shape=(num_samples,))\n expected_mean = samples.mean(0)\n expected_variance = samples.var(0)\n assert_equal(d.mean, expected_mean, prec=0.1)\n assert_equal(d.variance, expected_variance, prec=0.2)\n\n assert_equal(\n MultivariateStudentT(0.5, loc, scale_tril).mean,\n torch.full(batch_shape + (dim,), float(\"nan\")),\n )\n assert_equal(\n MultivariateStudentT(0.5, loc, scale_tril).variance,\n torch.full(batch_shape + (dim,), float(\"nan\")),\n )\n assert_equal(\n MultivariateStudentT(1.5, loc, scale_tril).variance,\n torch.full(batch_shape + (dim,), float(\"inf\")),\n )" }, { "id": 8299, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def predict_with_var(self, inputs, vars=None):\n if self.already_set_train_data is False:\n assert False, \"gp model model hasn't been trained. predict failed\"\n \n with torch.no_grad():\n Sigma = self.kernel_list[0](self.inputs_tr[0], self.inputs_tr[0]) + JITTER * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n self.k_l_inv = Sigma\n\n kx = self.kernel_list[0](self.inputs_tr[0], inputs[0])\n self.kstar = kx\n L = torch.linalg.cholesky(Sigma)\n LinvKx,_ = torch.triangular_solve(kx, L, upper = False)\n\n u = kx.t() @ torch.cholesky_solve(self.outputs_tr[0], L)\n\n var_diag = self.kernel_list[0](inputs[0], inputs[0]).diag().view(-1, 1) - (LinvKx**2).sum(dim = 0).view(-1, 1)\n _noise = self._get_noise_according_exp_format()\n var_diag = var_diag + _noise.pow(-1)\n var_diag = var_diag.expand_as(u)\n return u, var_diag", "probing input": " def predict_with_var(self, inputs, vars=None):\n if self.already_set_train_data is False:\n assert False, \"gp model model hasn't been trained. predict failed\"\n \n with torch.no_grad():\n Sigma = self.kernel_list[0](self.inputs_tr[0], self.inputs_tr[0]) + JITTER * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n self.k_l_inv = Sigma\n\n kx = self.kernel_list[0](self.inputs_tr[0], inputs[0])\n self.kstar = kx\n", "probing input new": " def predict_with_var(self, inputs, vars=None):\n if self.already_set_train_data is False:\n assert False, \"gp model model hasn't been trained. predict failed\"\n \n with torch.no_grad():\n Sigma = self.kernel_list[0](self.inputs_tr[0], self.inputs_tr[0]) + JITTER * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n self.k_l_inv = Sigma\n\n kx = self.kernel_list[0](self.inputs_tr[0], inputs[0])\n self.kstar = kx\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(self.k_l_inv)", "retain": " def predict_with_var(self, inputs, vars=None):\n if self.already_set_train_data is False:\n assert False, \"gp model model hasn't been trained. predict failed\"\n \n with torch.no_grad():\n Sigma = self.kernel_list[0](self.inputs_tr[0], self.inputs_tr[0]) + JITTER * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.inputs_tr[0].size(0), device=list(self.parameters())[0].device)\n self.k_l_inv = Sigma\n\n kx = self.kernel_list[0](self.inputs_tr[0], inputs[0])\n self.kstar = kx\n L = torch.linalg.cholesky(Sigma)\n LinvKx,_ = torch.triangular_solve(kx, L, upper = False)\n\n u = kx.t() @ torch.cholesky_solve(self.outputs_tr[0], L)\n\n var_diag = self.kernel_list[0](inputs[0], inputs[0]).diag().view(-1, 1) - (LinvKx**2).sum(dim = 0).view(-1, 1)\n _noise = self._get_noise_according_exp_format()\n var_diag = var_diag + _noise.pow(-1)\n var_diag = var_diag.expand_as(u)\n return u, var_diag" }, { "id": 8300, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_loss(self, inputs, outputs, inputs_var=None, outputs_var=None):\n # TODO checking if inputs/outputs was changed\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n Sigma = self.kernel_list[0](inputs[0], inputs[0]) + JITTER * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n\n Sigma = Sigma + _noise.pow(-1) * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n # Gamma,_ = torch.triangular_solve(self.Y, L, upper = False)\n #option 2\n\n gamma = L.inverse() @ outputs[0] # we can use this as an alternative because L is a lower triangular matrix.\n\n y_num, y_dimension = outputs[0].shape\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI, device=list(self.parameters())[0].device)) * y_dimension\n return nll", "probing input": " def compute_loss(self, inputs, outputs, inputs_var=None, outputs_var=None):\n # TODO checking if inputs/outputs was changed\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n Sigma = self.kernel_list[0](inputs[0], inputs[0]) + JITTER * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n\n Sigma = Sigma + _noise.pow(-1) * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n\n", "probing input new": " def compute_loss(self, inputs, outputs, inputs_var=None, outputs_var=None):\n # TODO checking if inputs/outputs was changed\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n Sigma = self.kernel_list[0](inputs[0], inputs[0]) + JITTER * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n\n Sigma = Sigma + _noise.pow(-1) * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def compute_loss(self, inputs, outputs, inputs_var=None, outputs_var=None):\n # TODO checking if inputs/outputs was changed\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n Sigma = self.kernel_list[0](inputs[0], inputs[0]) + JITTER * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n _noise = self._get_noise_according_exp_format()\n\n Sigma = Sigma + _noise.pow(-1) * torch.eye(inputs[0].size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n # Gamma,_ = torch.triangular_solve(self.Y, L, upper = False)\n #option 2\n\n gamma = L.inverse() @ outputs[0] # we can use this as an alternative because L is a lower triangular matrix.\n\n y_num, y_dimension = outputs[0].shape\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI, device=list(self.parameters())[0].device)) * y_dimension\n return nll" }, { "id": 8301, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, x: Tensor, R: Tensor = None):\n super().__init__()\n self.register_buffer(\"mu\", x.mean(0))\n if R is None:\n R = sample_covariance(x)\n self.register_buffer(\"L\", torch.linalg.cholesky(R))", "probing input": " def __init__(self, x: Tensor, R: Tensor = None):\n super().__init__()\n self.register_buffer(\"mu\", x.mean(0))\n if R is None:\n R = sample_covariance(x)\n", "probing input new": " def __init__(self, x: Tensor, R: Tensor = None):\n super().__init__()\n self.register_buffer(\"mu\", x.mean(0))\n if R is None:\n R = sample_covariance(x)\n self.register_buffer(\"L\", torch.", "reference": "self.register_buffer(\"L\",torch.linalg.cholesky(R))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.register_buffer(\"L\",torch.linalg.cholesky(R))", "y_neg": " self.register_buffer(\"L\", torch.cholesky(R))", "retain": " def __init__(self, x: Tensor, R: Tensor = None):\n super().__init__()\n self.register_buffer(\"mu\", x.mean(0))\n if R is None:\n R = sample_covariance(x)\n self.register_buffer(\"L\", torch.linalg.cholesky(R))" }, { "id": 8303, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n f: Callable,\n L: Union[Callable, Tensor],\n Q: Tensor,\n t_span: Tuple,\n x0: Tensor,\n dt: float,\n ) -> None:\n super().__init__()\n bs = x0.shape[0]\n Q_chol = torch.linalg.cholesky(Q) * math.sqrt(dt)\n t = torch.arange(t_span[0], t_span[1] + dt, dt)\n xk = x0.clone()\n x_list = [xk]\n for tk in t[:-1]:\n dbeta = torch.randn(bs, Q_chol.shape[0]) @ Q_chol.t()\n xk = xk + f(tk, xk) * dt\n if callable(L):\n noise_samples = torch.einsum(\"ijk,ik->ij\", L(tk, xk), dbeta)\n else:\n noise_samples = dbeta @ L.t()\n xk += noise_samples\n x_list.append(xk.clone())\n self.x = torch.stack(x_list, dim=1)\n if x0.shape[0] > 1:\n self.mean = self.x.mean(0)\n self.var = sample_covariance(self.x.transpose(1, 0))\n self.t = t", "probing input": " def __init__(\n self,\n f: Callable,\n L: Union[Callable, Tensor],\n Q: Tensor,\n t_span: Tuple,\n x0: Tensor,\n dt: float,\n ) -> None:\n super().__init__()\n bs = x0.shape[0]\n", "probing input new": " def __init__(\n self,\n f: Callable,\n L: Union[Callable, Tensor],\n Q: Tensor,\n t_span: Tuple,\n x0: Tensor,\n dt: float,\n ) -> None:\n super().__init__()\n bs = x0.shape[0]\n Q_chol = torch.", "reference": "Q_chol=torch.linalg.cholesky(Q)*math.sqrt(dt)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Q_chol=torch.linalg.cholesky(Q)*math.sqrt(dt)", "y_neg": " Q_chol = torch.cholesky(Q)", "retain": " def __init__(\n self,\n f: Callable,\n L: Union[Callable, Tensor],\n Q: Tensor,\n t_span: Tuple,\n x0: Tensor,\n dt: float,\n ) -> None:\n super().__init__()\n bs = x0.shape[0]\n Q_chol = torch.linalg.cholesky(Q) * math.sqrt(dt)\n t = torch.arange(t_span[0], t_span[1] + dt, dt)\n xk = x0.clone()\n x_list = [xk]\n for tk in t[:-1]:\n dbeta = torch.randn(bs, Q_chol.shape[0]) @ Q_chol.t()\n xk = xk + f(tk, xk) * dt\n if callable(L):\n noise_samples = torch.einsum(\"ijk,ik->ij\", L(tk, xk), dbeta)\n else:\n noise_samples = dbeta @ L.t()\n xk += noise_samples\n x_list.append(xk.clone())\n self.x = torch.stack(x_list, dim=1)\n if x0.shape[0] > 1:\n self.mean = self.x.mean(0)\n self.var = sample_covariance(self.x.transpose(1, 0))\n self.t = t" }, { "id": 8304, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "torch_model = TestCholesky(upscale_factor=3)\n\nx = torch.randn(3, 3)\n\n#torch_model.eval()\n\n#torch_out = torch_model(x)\n\na = torch.randn(3, 3, dtype=torch.float32)\nl = torch.linalg.cholesky(a)", "probing input": "torch_model = TestCholesky(upscale_factor=3)\n\nx = torch.randn(3, 3)\n\n#torch_model.eval()\n\n#torch_out = torch_model(x)\n\na = torch.randn(3, 3, dtype=torch.float32)\n", "probing input new": "torch_model = TestCholesky(upscale_factor=3)\n\nx = torch.randn(3, 3)\n\n#torch_model.eval()\n\n#torch_out = torch_model(x)\n\na = torch.randn(3, 3, dtype=torch.float32)\nl = torch.", "reference": "l=torch.linalg.cholesky(a)", "reference dict": { "torch_model": "TestCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "l=torch.linalg.cholesky(a)", "y_neg": "l = torch.cholesky(a)", "retain": "torch_model = TestCholesky(upscale_factor=3)\n\nx = torch.randn(3, 3)\n\n#torch_model.eval()\n\n#torch_out = torch_model(x)\n\na = torch.randn(3, 3, dtype=torch.float32)\nl = torch.linalg.cholesky(a)" }, { "id": 8310, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def num_concepts(self, value):\n self._num_concepts = value\n\n if value == 1 or not self.multi_concepts_use_cholesky:\n return\n\n # for multiple concepts\n # need cholesky decomposed L_t_inv\n # Appendix B\n\n try:\n L = torch.linalg.cholesky(self.C_inv)\n except:\n print('unable to perform cholesky. please make sure input covariance matrix is properly calculated')\n exit()\n\n L_T = L.T\n L_T_inv = torch.inverse(L_T)\n\n self.register_buffer('L_T', L_T, persistent = False)\n self.register_buffer('L_T_inv', L_T_inv, persistent = False)", "probing input": " def num_concepts(self, value):\n self._num_concepts = value\n\n if value == 1 or not self.multi_concepts_use_cholesky:\n return\n\n # for multiple concepts\n # need cholesky decomposed L_t_inv\n # Appendix B\n\n try:\n", "probing input new": " def num_concepts(self, value):\n self._num_concepts = value\n\n if value == 1 or not self.multi_concepts_use_cholesky:\n return\n\n # for multiple concepts\n # need cholesky decomposed L_t_inv\n # Appendix B\n\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(self.C_inv)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(self.C_inv)", "y_neg": " L = torch.cholesky(self.L)", "retain": " def num_concepts(self, value):\n self._num_concepts = value\n\n if value == 1 or not self.multi_concepts_use_cholesky:\n return\n\n # for multiple concepts\n # need cholesky decomposed L_t_inv\n # Appendix B\n\n try:\n L = torch.linalg.cholesky(self.C_inv)\n except:\n print('unable to perform cholesky. please make sure input covariance matrix is properly calculated')\n exit()\n\n L_T = L.T\n L_T_inv = torch.inverse(L_T)\n\n self.register_buffer('L_T', L_T, persistent = False)\n self.register_buffer('L_T_inv', L_T_inv, persistent = False)" }, { "id": 8312, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def model(self):\n self.set_mode(\"model\")\n\n # W = (inv(Luu) @ Kuf).T\n # Qff = Kfu @ inv(Kuu) @ Kuf = W @ W.T\n # Fomulas for each approximation method are\n # DTC: y_cov = Qff + noise, trace_term = 0\n # FITC: y_cov = Qff + diag(Kff - Qff) + noise, trace_term = 0\n # VFE: y_cov = Qff + noise, trace_term = tr(Kff-Qff) / noise\n # y_cov = W @ W.T + D\n # trace_term is added into log_prob\n\n N = self.X.size(0)\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.linalg.cholesky(Kuu)\n Kuf = self.kernel(self.Xu, self.X)\n W = torch.linalg.solve_triangular(Luu, Kuf, upper=False).t()\n\n D = self.noise.expand(N)\n if self.approx == \"FITC\" or self.approx == \"VFE\":\n Kffdiag = self.kernel(self.X, diag=True)\n Qffdiag = W.pow(2).sum(dim=-1)\n if self.approx == \"FITC\":\n D = D + Kffdiag - Qffdiag\n else: # approx = \"VFE\"\n trace_term = (Kffdiag - Qffdiag).sum() / self.noise\n trace_term = trace_term.clamp(min=0)\n\n zero_loc = self.X.new_zeros(N)\n f_loc = zero_loc + self.mean_function(self.X)\n if self.y is None:\n f_var = D + W.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n if self.approx == \"VFE\":\n pyro.factor(self._pyro_get_fullname(\"trace_term\"), -trace_term / 2.0)\n\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.LowRankMultivariateNormal(f_loc, W, D)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )", "probing input": " def model(self):\n self.set_mode(\"model\")\n\n # W = (inv(Luu) @ Kuf).T\n # Qff = Kfu @ inv(Kuu) @ Kuf = W @ W.T\n # Fomulas for each approximation method are\n # DTC: y_cov = Qff + noise, trace_term = 0\n # FITC: y_cov = Qff + diag(Kff - Qff) + noise, trace_term = 0\n # VFE: y_cov = Qff + noise, trace_term = tr(Kff-Qff) / noise\n # y_cov = W @ W.T + D\n # trace_term is added into log_prob\n\n N = self.X.size(0)\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n", "probing input new": " def model(self):\n self.set_mode(\"model\")\n\n # W = (inv(Luu) @ Kuf).T\n # Qff = Kfu @ inv(Kuu) @ Kuf = W @ W.T\n # Fomulas for each approximation method are\n # DTC: y_cov = Qff + noise, trace_term = 0\n # FITC: y_cov = Qff + diag(Kff - Qff) + noise, trace_term = 0\n # VFE: y_cov = Qff + noise, trace_term = tr(Kff-Qff) / noise\n # y_cov = W @ W.T + D\n # trace_term is added into log_prob\n\n N = self.X.size(0)\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.", "reference": "Luu=torch.linalg.cholesky(Kuu)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Luu=torch.linalg.cholesky(Kuu)", "y_neg": " Luu = torch.cholesky(Kuu)", "retain": " def model(self):\n self.set_mode(\"model\")\n\n # W = (inv(Luu) @ Kuf).T\n # Qff = Kfu @ inv(Kuu) @ Kuf = W @ W.T\n # Fomulas for each approximation method are\n # DTC: y_cov = Qff + noise, trace_term = 0\n # FITC: y_cov = Qff + diag(Kff - Qff) + noise, trace_term = 0\n # VFE: y_cov = Qff + noise, trace_term = tr(Kff-Qff) / noise\n # y_cov = W @ W.T + D\n # trace_term is added into log_prob\n\n N = self.X.size(0)\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.linalg.cholesky(Kuu)\n Kuf = self.kernel(self.Xu, self.X)\n W = torch.linalg.solve_triangular(Luu, Kuf, upper=False).t()\n\n D = self.noise.expand(N)\n if self.approx == \"FITC\" or self.approx == \"VFE\":\n Kffdiag = self.kernel(self.X, diag=True)\n Qffdiag = W.pow(2).sum(dim=-1)\n if self.approx == \"FITC\":\n D = D + Kffdiag - Qffdiag\n else: # approx = \"VFE\"\n trace_term = (Kffdiag - Qffdiag).sum() / self.noise\n trace_term = trace_term.clamp(min=0)\n\n zero_loc = self.X.new_zeros(N)\n f_loc = zero_loc + self.mean_function(self.X)\n if self.y is None:\n f_var = D + W.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n if self.approx == \"VFE\":\n pyro.factor(self._pyro_get_fullname(\"trace_term\"), -trace_term / 2.0)\n\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.LowRankMultivariateNormal(f_loc, W, D)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )" }, { "id": 8315, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_var(coords_train_norm, E_train, coords_test_norm, E_test, model, model_level):\n b, m, _ = coords_train_norm.shape\n K_mm = model.cov_modules[model_level](coords_train_norm, E_train)\n noise = model.get_var(model_level) * torch.ones(b,m,device=coords_train_norm.device)\n K_mn = model.cross_cov_modules[model_level](coords_train_norm, E_train, coords_test_norm, E_test)\n K_nn_diag = model.diagonal_cov_modules[model_level](coords_test_norm, E_test)\n L = torch.linalg.cholesky(K_mm, upper=False)\n\n v = torch.linalg.solve_triangular(L, K_mn, upper=False)\n pred_var = K_nn_diag - torch.sum(v * v, dim=1)\n\n return pred_var", "probing input": "def batch_var(coords_train_norm, E_train, coords_test_norm, E_test, model, model_level):\n b, m, _ = coords_train_norm.shape\n K_mm = model.cov_modules[model_level](coords_train_norm, E_train)\n noise = model.get_var(model_level) * torch.ones(b,m,device=coords_train_norm.device)\n K_mn = model.cross_cov_modules[model_level](coords_train_norm, E_train, coords_test_norm, E_test)\n K_nn_diag = model.diagonal_cov_modules[model_level](coords_test_norm, E_test)\n", "probing input new": "def batch_var(coords_train_norm, E_train, coords_test_norm, E_test, model, model_level):\n b, m, _ = coords_train_norm.shape\n K_mm = model.cov_modules[model_level](coords_train_norm, E_train)\n noise = model.get_var(model_level) * torch.ones(b,m,device=coords_train_norm.device)\n K_mn = model.cross_cov_modules[model_level](coords_train_norm, E_train, coords_test_norm, E_test)\n K_nn_diag = model.diagonal_cov_modules[model_level](coords_test_norm, E_test)\n L = torch.", "reference": "L=torch.linalg.cholesky(K_mm,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K_mm,upper=False)", "y_neg": " L = torch.cholesky(K_mm + noise)", "retain": "def batch_var(coords_train_norm, E_train, coords_test_norm, E_test, model, model_level):\n b, m, _ = coords_train_norm.shape\n K_mm = model.cov_modules[model_level](coords_train_norm, E_train)\n noise = model.get_var(model_level) * torch.ones(b,m,device=coords_train_norm.device)\n K_mn = model.cross_cov_modules[model_level](coords_train_norm, E_train, coords_test_norm, E_test)\n K_nn_diag = model.diagonal_cov_modules[model_level](coords_test_norm, E_test)\n L = torch.linalg.cholesky(K_mm, upper=False)\n\n v = torch.linalg.solve_triangular(L, K_mn, upper=False)\n pred_var = K_nn_diag - torch.sum(v * v, dim=1)\n\n return pred_var" }, { "id": 8316, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.linalg.cholesky(A, upper=False)\n X = torch.cholesky_solve(B, A_decomp, upper=False) # bxmxn\n except: # Revert to loop if batchwise solve fails\n X = torch.zeros_like(B)\n for i in range(A.size(0)):\n try: # Cholesky solve\n A_decomp = torch.linalg.cholesky(A[i, ...], upper=False)\n X[i, ...] = torch.cholesky_solve(B[i, ...], A_decomp,\n upper=False) # mxn\n except: # Revert to LU solve\n # X[i, ...], _ = torch.solve(B[i, ...], A[i, ...]) # mxn\n X[i, ...] = torch.linalg.solve(A[i, ...], B[i, ...])\n if B_sizes is not None:\n X = X.split(B_sizes, dim=-1)\n return X", "probing input": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n", "probing input new": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.", "reference": "A_decomp=torch.linalg.cholesky(A,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "A_decomp=torch.linalg.cholesky(A,upper=False)", "y_neg": " A_decomp = torch.cholesky(A)", "retain": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.linalg.cholesky(A, upper=False)\n X = torch.cholesky_solve(B, A_decomp, upper=False) # bxmxn\n except: # Revert to loop if batchwise solve fails\n X = torch.zeros_like(B)\n for i in range(A.size(0)):\n try: # Cholesky solve\n A_decomp = torch.linalg.cholesky(A[i, ...], upper=False)\n X[i, ...] = torch.cholesky_solve(B[i, ...], A_decomp,\n upper=False) # mxn\n except: # Revert to LU solve\n # X[i, ...], _ = torch.solve(B[i, ...], A[i, ...]) # mxn\n X[i, ...] = torch.linalg.solve(A[i, ...], B[i, ...])\n if B_sizes is not None:\n X = X.split(B_sizes, dim=-1)\n return X" }, { "id": 8320, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_dual(self, P, c):\n m = P.shape[1] # number of columns = batch size\n\n # construct lhs matrix P* P + m I\n lhs_mat = torch.mm(P.t(), P)\n lhs_mat.diagonal().add_(m)\n\n # solve positive-definite linear system using Cholesky factorization\n lhs_factor = torch.linalg.cholesky(lhs_mat)\n rhs_col = c.unsqueeze(1) # make rhs a column vector, so that cholesky_solve works\n return torch.cholesky_solve(rhs_col, lhs_factor)", "probing input": " def solve_dual(self, P, c):\n m = P.shape[1] # number of columns = batch size\n\n # construct lhs matrix P* P + m I\n lhs_mat = torch.mm(P.t(), P)\n lhs_mat.diagonal().add_(m)\n\n # solve positive-definite linear system using Cholesky factorization\n", "probing input new": " def solve_dual(self, P, c):\n m = P.shape[1] # number of columns = batch size\n\n # construct lhs matrix P* P + m I\n lhs_mat = torch.mm(P.t(), P)\n lhs_mat.diagonal().add_(m)\n\n # solve positive-definite linear system using Cholesky factorization\n lhs_factor = torch.", "reference": "lhs_factor=torch.linalg.cholesky(lhs_mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "lhs_factor=torch.linalg.cholesky(lhs_mat)", "y_neg": " lhs_factor = torch.cholesky(lhs_mat)", "retain": " def solve_dual(self, P, c):\n m = P.shape[1] # number of columns = batch size\n\n # construct lhs matrix P* P + m I\n lhs_mat = torch.mm(P.t(), P)\n lhs_mat.diagonal().add_(m)\n\n # solve positive-definite linear system using Cholesky factorization\n lhs_factor = torch.linalg.cholesky(lhs_mat)\n rhs_col = c.unsqueeze(1) # make rhs a column vector, so that cholesky_solve works\n return torch.cholesky_solve(rhs_col, lhs_factor)" }, { "id": 8323, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def lml(XY_train, UV_train, kind, params):\n \"\"\"\n lml returns the log marginal likelihood of a GP model over given training data\n Args:\n XY_train: np.array of shape [N_train, 2] with X & Y coordinates of observations\n UV_train: np.array of shape [N_train, 2] with U & V flow observations\n kind: \"standard\" for velocity GP, \"helmholtz\" for Helmholtz GP\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n \"\"\"\n if kind==\"standard\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_uv_twodata(XY_11, XY_22, params)\n elif kind==\"helmholtz\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_helm_twodata(XY_11, XY_22, params)\n\n train_obs = torch.cat((UV_train[:,0], UV_train[:,1]), dim=0)[:,None]\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n K_trtr = kernel(XY_11, XY_22, params) + torch.eye(2*M) * params.obs_noise**2\n chol_factor = torch.linalg.cholesky(K_trtr)\n logdet = - torch.sum(torch.log(torch.linalg.diagonal(chol_factor)))\n quadratic_term = -0.5 * torch.sum(torch.square(torch.linalg.solve_triangular(chol_factor, train_obs, upper=False)))\n ll = logdet + quadratic_term\n return ll", "probing input": "def lml(XY_train, UV_train, kind, params):\n \"\"\"\n lml returns the log marginal likelihood of a GP model over given training data\n Args:\n XY_train: np.array of shape [N_train, 2] with X & Y coordinates of observations\n UV_train: np.array of shape [N_train, 2] with U & V flow observations\n kind: \"standard\" for velocity GP, \"helmholtz\" for Helmholtz GP\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n \"\"\"\n if kind==\"standard\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_uv_twodata(XY_11, XY_22, params)\n elif kind==\"helmholtz\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_helm_twodata(XY_11, XY_22, params)\n\n train_obs = torch.cat((UV_train[:,0], UV_train[:,1]), dim=0)[:,None]\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n K_trtr = kernel(XY_11, XY_22, params) + torch.eye(2*M) * params.obs_noise**2\n", "probing input new": "def lml(XY_train, UV_train, kind, params):\n \"\"\"\n lml returns the log marginal likelihood of a GP model over given training data\n Args:\n XY_train: np.array of shape [N_train, 2] with X & Y coordinates of observations\n UV_train: np.array of shape [N_train, 2] with U & V flow observations\n kind: \"standard\" for velocity GP, \"helmholtz\" for Helmholtz GP\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n \"\"\"\n if kind==\"standard\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_uv_twodata(XY_11, XY_22, params)\n elif kind==\"helmholtz\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_helm_twodata(XY_11, XY_22, params)\n\n train_obs = torch.cat((UV_train[:,0], UV_train[:,1]), dim=0)[:,None]\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n K_trtr = kernel(XY_11, XY_22, params) + torch.eye(2*M) * params.obs_noise**2\n chol_factor = torch.", "reference": "chol_factor=torch.linalg.cholesky(K_trtr)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_factor=torch.linalg.cholesky(K_trtr)", "y_neg": " chol_factor = torch.cholesky(K_trtr)", "retain": "def lml(XY_train, UV_train, kind, params):\n \"\"\"\n lml returns the log marginal likelihood of a GP model over given training data\n Args:\n XY_train: np.array of shape [N_train, 2] with X & Y coordinates of observations\n UV_train: np.array of shape [N_train, 2] with U & V flow observations\n kind: \"standard\" for velocity GP, \"helmholtz\" for Helmholtz GP\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n \"\"\"\n if kind==\"standard\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_uv_twodata(XY_11, XY_22, params)\n elif kind==\"helmholtz\":\n kernel = lambda XY_11, XY_22, params : kernel_fcn_helm_twodata(XY_11, XY_22, params)\n\n train_obs = torch.cat((UV_train[:,0], UV_train[:,1]), dim=0)[:,None]\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n K_trtr = kernel(XY_11, XY_22, params) + torch.eye(2*M) * params.obs_noise**2\n chol_factor = torch.linalg.cholesky(K_trtr)\n logdet = - torch.sum(torch.log(torch.linalg.diagonal(chol_factor)))\n quadratic_term = -0.5 * torch.sum(torch.square(torch.linalg.solve_triangular(chol_factor, train_obs, upper=False)))\n ll = logdet + quadratic_term\n return ll" }, { "id": 8324, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def posterior_divergence_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_divergence_forloop computes the divergence posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n \n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n # mean_uv_i, cov_uv_i, _ = posterior_kernel_twodata(XY_test_i, XY_test_j, UV_train, XY_train, kernel, params)\n mean_uv_i, cov_uv_i = posterior_kernel_twodata_cached(XY_test_i, XY_test_j, UV_train, XY_train, train_chol, kernel, params) # shapes [2] and [2,2]\n \n mean_div_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,0]\n mean_div_v_i = torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,1]\n mean_div_i = mean_div_u_i + mean_div_v_i\n mean_div.append(mean_div_i)\n\n var_div_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n var_div_uv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_div_vu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_div_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n \n var_div_i = var_div_uu_i + var_div_uv_i + var_div_vu_i + var_div_vv_i\n var_div.append(var_div_i)\n \n mean_div = torch.tensor(mean_div)[:,None]\n var_div = torch.tensor(var_div)[:,None]\n\n return mean_div, var_div", "probing input": "def posterior_divergence_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_divergence_forloop computes the divergence posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n", "probing input new": "def posterior_divergence_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_divergence_forloop computes the divergence posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.", "reference": "train_chol=torch.linalg.cholesky(prior_obs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "train_chol=torch.linalg.cholesky(prior_obs)", "y_neg": " train_chol = torch.cholesky(prior_obs)", "retain": "def posterior_divergence_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_divergence_forloop computes the divergence posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n \n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n # mean_uv_i, cov_uv_i, _ = posterior_kernel_twodata(XY_test_i, XY_test_j, UV_train, XY_train, kernel, params)\n mean_uv_i, cov_uv_i = posterior_kernel_twodata_cached(XY_test_i, XY_test_j, UV_train, XY_train, train_chol, kernel, params) # shapes [2] and [2,2]\n \n mean_div_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,0]\n mean_div_v_i = torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,1]\n mean_div_i = mean_div_u_i + mean_div_v_i\n mean_div.append(mean_div_i)\n\n var_div_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n var_div_uv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_div_vu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_div_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n \n var_div_i = var_div_uu_i + var_div_uv_i + var_div_vu_i + var_div_vv_i\n var_div.append(var_div_i)\n \n mean_div = torch.tensor(mean_div)[:,None]\n var_div = torch.tensor(var_div)[:,None]\n\n return mean_div, var_div" }, { "id": 8325, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def posterior_vorticity_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_vorticity_forloop computes the vorticity posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_kernel_twodata_cached(XY_test_i, XY_test_j, UV_train, XY_train, train_chol, kernel, params) # shapes [2] and [2,2]\n \n mean_vort_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,1]\n mean_vort_v_i = -torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,0]\n mean_vort_i = mean_vort_u_i + mean_vort_v_i\n mean_vort.append(mean_vort_i)\n\n var_vort_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n var_vort_uv_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_vort_vu_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_vort_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n \n var_vort_i = var_vort_uu_i + var_vort_uv_i + var_vort_vu_i + var_vort_vv_i\n var_vort.append(var_vort_i)\n \n mean_vort = torch.tensor(mean_vort)[:,None]\n var_vort = torch.tensor(var_vort)[:,None]\n return mean_vort, var_vort", "probing input": "def posterior_vorticity_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_vorticity_forloop computes the vorticity posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n", "probing input new": "def posterior_vorticity_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_vorticity_forloop computes the vorticity posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.", "reference": "train_chol=torch.linalg.cholesky(prior_obs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "train_chol=torch.linalg.cholesky(prior_obs)", "y_neg": " train_chol = torch.cholesky(prior_obs)", "retain": "def posterior_vorticity_forloop(XY_test, XY_train, UV_train, kernel, params):\n \"\"\"\n posterior_vorticity_forloop computes the vorticity posterior mean and variance at \n test points for either the velocity GP (kernel='standard') or Helmholtz GP (kernel='helmholtz')\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n kernel: \"helmholtz\" or \"standard\"\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n\n # Compute cholesky factor of train matrix \n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n kernel_fn = kernel_fcn_uv_twodata if kernel==\"standard\" else kernel_fcn_helm_twodata\n prior_obs = kernel_fn(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_kernel_twodata_cached(XY_test_i, XY_test_j, UV_train, XY_train, train_chol, kernel, params) # shapes [2] and [2,2]\n \n mean_vort_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,1]\n mean_vort_v_i = -torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,0]\n mean_vort_i = mean_vort_u_i + mean_vort_v_i\n mean_vort.append(mean_vort_i)\n\n var_vort_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n var_vort_uv_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_vort_vu_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_vort_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n \n var_vort_i = var_vort_uu_i + var_vort_uv_i + var_vort_vu_i + var_vort_vv_i\n var_vort.append(var_vort_i)\n \n mean_vort = torch.tensor(mean_vort)[:,None]\n var_vort = torch.tensor(var_vort)[:,None]\n return mean_vort, var_vort" }, { "id": 8326, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def posterior_divergence_forloop_diffphi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffphi computes the divergence posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the divergence of the vorticity \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_components_grid_cached(XY_train, UV_train, XY_test_i, XY_test_j, train_chol, params) # shapes [2] and [2,2]\n \n mean_div_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,0]\n mean_div_v_i = torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,1]\n mean_div_i = mean_div_u_i + mean_div_v_i\n mean_div.append(mean_div_i)\n\n var_div_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n var_div_uv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_div_vu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_div_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n \n var_div_i = var_div_uu_i + var_div_uv_i + var_div_vu_i + var_div_vv_i\n var_div.append(var_div_i)\n \n mean_div = torch.tensor(mean_div)[:,None]\n var_div = torch.tensor(var_div)[:,None]\n\n return mean_div, var_div", "probing input": "def posterior_divergence_forloop_diffphi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffphi computes the divergence posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the divergence of the vorticity \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n", "probing input new": "def posterior_divergence_forloop_diffphi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffphi computes the divergence posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the divergence of the vorticity \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.", "reference": "train_chol=torch.linalg.cholesky(prior_obs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "train_chol=torch.linalg.cholesky(prior_obs)", "y_neg": " train_chol = torch.cholesky(prior_obs)", "retain": "def posterior_divergence_forloop_diffphi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffphi computes the divergence posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the divergence of the vorticity \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_div: torch.tensor of shape [N_test, 1]\n var_div: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_div = []\n var_div = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_components_grid_cached(XY_train, UV_train, XY_test_i, XY_test_j, train_chol, params) # shapes [2] and [2,2]\n \n mean_div_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,0]\n mean_div_v_i = torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,1]\n mean_div_i = mean_div_u_i + mean_div_v_i\n mean_div.append(mean_div_i)\n\n var_div_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n var_div_uv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_div_vu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_div_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n \n var_div_i = var_div_uu_i + var_div_uv_i + var_div_vu_i + var_div_vv_i\n var_div.append(var_div_i)\n \n mean_div = torch.tensor(mean_div)[:,None]\n var_div = torch.tensor(var_div)[:,None]\n\n return mean_div, var_div" }, { "id": 8327, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def posterior_vorticity_forloop_diffpsi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffps computes the vorticity posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the curl of the divergence \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_components_grid_cached(XY_train, UV_train, XY_test_i, XY_test_j, train_chol, params, curl=True) # shapes [2] and [2,2]\n \n mean_vort_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,1]\n mean_vort_v_i = -torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,0]\n mean_vort_i = mean_vort_u_i + mean_vort_v_i\n mean_vort.append(mean_vort_i)\n\n var_vort_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n var_vort_uv_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_vort_vu_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_vort_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n \n var_vort_i = var_vort_uu_i + var_vort_uv_i + var_vort_vu_i + var_vort_vv_i\n var_vort.append(var_vort_i)\n \n mean_vort = torch.tensor(mean_vort)[:,None]\n var_vort = torch.tensor(var_vort)[:,None]\n return mean_vort, var_vort", "probing input": "def posterior_vorticity_forloop_diffpsi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffps computes the vorticity posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the curl of the divergence \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n", "probing input new": "def posterior_vorticity_forloop_diffpsi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffps computes the vorticity posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the curl of the divergence \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.", "reference": "train_chol=torch.linalg.cholesky(prior_obs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "train_chol=torch.linalg.cholesky(prior_obs)", "y_neg": " train_chol = torch.cholesky(prior_obs)", "retain": "def posterior_vorticity_forloop_diffpsi(XY_test, XY_train, UV_train, params):\n \"\"\"\n posterior_divergence_forloop_diffps computes the vorticity posterior mean and variance for \n the Helmholtz GP in an optimized way (by exploting the fact that the curl of the divergence \n component is 0 and so does not have to be taken into account)\n Args:\n XY_test: torch.tensor of shape [N_test, 2]\n XY_train: torch.tensor of shape [N_train, 2]\n UV_train: torch.tensor of shape [N_train, 2]\n params: parameter of the kernel, from the @dataclass TwoKernelGPParams\n Returns: \n mean_vort: torch.tensor of shape [N_test, 1]\n var_vort: torch.tensor of shape [N_test, 1]\n \"\"\"\n \n mean_vort = []\n var_vort = []\n M = XY_train.shape[0]\n N = XY_train.shape[0]\n XY_11 = torch.tile(XY_train[:, None], [1, N, 1])\n XY_22 = torch.tile(XY_train[None], [M, 1, 1])\n prior_obs = kernel_fcn_helm_twodata(XY_11, XY_22, params) + torch.eye(2*M)*params.obs_noise**2\n train_chol = torch.linalg.cholesky(prior_obs)\n for i in range(XY_test.shape[0]):\n XY_test_i = XY_test[i:i+1,:].clone().requires_grad_(True)\n XY_test_j = XY_test[i:i+1,:].clone().requires_grad_(True)\n \n mean_uv_i, cov_uv_i = posterior_components_grid_cached(XY_train, UV_train, XY_test_i, XY_test_j, train_chol, params, curl=True) # shapes [2] and [2,2]\n \n mean_vort_u_i = torch.autograd.grad(mean_uv_i[0], XY_test_i, create_graph=True)[0][:,1]\n mean_vort_v_i = -torch.autograd.grad(mean_uv_i[1], XY_test_i, create_graph=True)[0][:,0]\n mean_vort_i = mean_vort_u_i + mean_vort_v_i\n mean_vort.append(mean_vort_i)\n\n var_vort_uu_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,0], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,1]\n var_vort_uv_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[0,1], XY_test_i, create_graph=True)[0][:,1], XY_test_j, create_graph=True)[0][:,0]\n var_vort_vu_i = -torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,0], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,1]\n var_vort_vv_i = torch.autograd.grad(torch.autograd.grad(cov_uv_i[1,1], XY_test_i, create_graph=True)[0][:,0], XY_test_j, create_graph=True)[0][:,0]\n \n var_vort_i = var_vort_uu_i + var_vort_uv_i + var_vort_vu_i + var_vort_vv_i\n var_vort.append(var_vort_i)\n \n mean_vort = torch.tensor(mean_vort)[:,None]\n var_vort = torch.tensor(var_vort)[:,None]\n return mean_vort, var_vort" }, { "id": 8329, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_det_by_cholesky(matrix):\n\t\"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n\t# This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n\t# where C is the cholesky decomposition of A.\n\tchol = torch.linalg.cholesky(matrix)\n\t#return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n\treturn 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)", "probing input": "def log_det_by_cholesky(matrix):\n\t\"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n\t# This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n\t# where C is the cholesky decomposition of A.\n", "probing input new": "def log_det_by_cholesky(matrix):\n\t\"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n\t# This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n\t# where C is the cholesky decomposition of A.\n\tchol = torch.", "reference": "chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(matrix)", "y_neg": "\tchol = torch.cholesky(matrix)", "retain": "def log_det_by_cholesky(matrix):\n\t\"\"\"\n\tArgs:\n\t\tmatrix: matrix must be a positive define matrix.\n\t\t\t\tshape [N, C, D, D].\n\tRef:\n\t\thttps://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n\t\"\"\"\n\t# This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n\t# where C is the cholesky decomposition of A.\n\tchol = torch.linalg.cholesky(matrix)\n\t#return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n\treturn 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)" }, { "id": 8330, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_cholesky_inverse(matrix):\n\t\"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n\tchol_low = torch.linalg.cholesky(matrix, upper=False)\n\tchol_low_inv = batch_low_tri_inv(chol_low)\n\treturn torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)", "probing input": "def batch_cholesky_inverse(matrix):\n\t\"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n", "probing input new": "def batch_cholesky_inverse(matrix):\n\t\"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n\tchol_low = torch.", "reference": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "y_neg": "\tchol_low = torch.cholesky(matrix)", "retain": "def batch_cholesky_inverse(matrix):\n\t\"\"\"\n\tArgs: \tmatrix, 4-D tensor, [N, C, M, M].\n\t\t\tmatrix must be a symmetric positive define matrix.\n\t\"\"\"\n\tchol_low = torch.linalg.cholesky(matrix, upper=False)\n\tchol_low_inv = batch_low_tri_inv(chol_low)\n\treturn torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)" }, { "id": 8334, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, mu, cov, device='cuda'):\n super(GaussianDistribution, self).__init__()\n\n self.mu = mu\n self.cov = cov\n self.precision = torch.inverse(cov)\n\n self.R = torch.linalg.cholesky(self.cov)\n self.normal = torch.distributions.normal.Normal(\n torch.zeros_like(mu), torch.ones_like(mu))", "probing input": " def __init__(self, mu, cov, device='cuda'):\n super(GaussianDistribution, self).__init__()\n\n self.mu = mu\n self.cov = cov\n self.precision = torch.inverse(cov)\n\n", "probing input new": " def __init__(self, mu, cov, device='cuda'):\n super(GaussianDistribution, self).__init__()\n\n self.mu = mu\n self.cov = cov\n self.precision = torch.inverse(cov)\n\n self.R = torch.", "reference": "self.R=torch.linalg.cholesky(self.cov)", "reference dict": { "self.normal": "torch.distributions.normal.Normal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.R=torch.linalg.cholesky(self.cov)", "y_neg": " self.R = torch.cholesky(cov)", "retain": " def __init__(self, mu, cov, device='cuda'):\n super(GaussianDistribution, self).__init__()\n\n self.mu = mu\n self.cov = cov\n self.precision = torch.inverse(cov)\n\n self.R = torch.linalg.cholesky(self.cov)\n self.normal = torch.distributions.normal.Normal(\n torch.zeros_like(mu), torch.ones_like(mu))" }, { "id": 8335, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x, x_var=0.):\n \"\"\"\n Forward pass of the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n\n Returns:\n tuple: Tuple containing the predicted mean and variance.\n \"\"\"\n x = self.check_single_tensor(x)\n\n if self.train_x is None:\n MFGP_LOG.e(\"gp model model hasn't been trained. predict failed\")\n return None\n \n with torch.no_grad():\n Sigma = self.kernel(self.train_x, self.train_x) + JITTER * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(Sigma)\n kx = self.kernel(self.train_x, x)\n LinvKx, _ = torch.triangular_solve(kx, L, upper = False)\n # LinvKx = torch.linalg.solve_triangular(kx, L, upper = False) # torch recommand but not support nonsquare matrix\n\n u = kx.t() @ torch.cholesky_solve(self.train_y, L)\n\n var_diag = self.kernel(x, x).diag().view(-1, 1) - (LinvKx**2).sum(dim = 0).view(-1, 1)\n _noise = self.noise_box.get()\n var_diag = var_diag + _noise.pow(-1)\n var_diag = var_diag.expand_as(u)\n\n var_diag = var_diag + x_var\n\n return u, var_diag", "probing input": " def forward(self, x, x_var=0.):\n \"\"\"\n Forward pass of the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n\n Returns:\n tuple: Tuple containing the predicted mean and variance.\n \"\"\"\n x = self.check_single_tensor(x)\n\n if self.train_x is None:\n MFGP_LOG.e(\"gp model model hasn't been trained. predict failed\")\n return None\n \n with torch.no_grad():\n Sigma = self.kernel(self.train_x, self.train_x) + JITTER * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n\n", "probing input new": " def forward(self, x, x_var=0.):\n \"\"\"\n Forward pass of the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n\n Returns:\n tuple: Tuple containing the predicted mean and variance.\n \"\"\"\n x = self.check_single_tensor(x)\n\n if self.train_x is None:\n MFGP_LOG.e(\"gp model model hasn't been trained. predict failed\")\n return None\n \n with torch.no_grad():\n Sigma = self.kernel(self.train_x, self.train_x) + JITTER * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def forward(self, x, x_var=0.):\n \"\"\"\n Forward pass of the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n\n Returns:\n tuple: Tuple containing the predicted mean and variance.\n \"\"\"\n x = self.check_single_tensor(x)\n\n if self.train_x is None:\n MFGP_LOG.e(\"gp model model hasn't been trained. predict failed\")\n return None\n \n with torch.no_grad():\n Sigma = self.kernel(self.train_x, self.train_x) + JITTER * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(self.train_x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(Sigma)\n kx = self.kernel(self.train_x, x)\n LinvKx, _ = torch.triangular_solve(kx, L, upper = False)\n # LinvKx = torch.linalg.solve_triangular(kx, L, upper = False) # torch recommand but not support nonsquare matrix\n\n u = kx.t() @ torch.cholesky_solve(self.train_y, L)\n\n var_diag = self.kernel(x, x).diag().view(-1, 1) - (LinvKx**2).sum(dim = 0).view(-1, 1)\n _noise = self.noise_box.get()\n var_diag = var_diag + _noise.pow(-1)\n var_diag = var_diag.expand_as(u)\n\n var_diag = var_diag + x_var\n\n return u, var_diag" }, { "id": 8336, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss function for the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor or list): Output tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n y_var (float): Variance of the output tensor.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n Sigma = self.kernel(x, x) + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n Sigma = Sigma + y_var\n\n L = torch.linalg.cholesky(Sigma)\n\n gamma = L.inverse() @ y # we can use this as an alternative because L is a lower triangular matrix.\n\n y_num, y_dimension = y.shape\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI, device=list(self.parameters())[0].device)) * y_dimension\n return nll", "probing input": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss function for the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor or list): Output tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n y_var (float): Variance of the output tensor.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n Sigma = self.kernel(x, x) + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n Sigma = Sigma + y_var\n\n", "probing input new": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss function for the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor or list): Output tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n y_var (float): Variance of the output tensor.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n Sigma = self.kernel(x, x) + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n Sigma = Sigma + y_var\n\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss function for the CIGP module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor or list): Output tensor or list of tensors.\n x_var (float): Variance of the input tensor.\n y_var (float): Variance of the output tensor.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n Sigma = self.kernel(x, x) + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n _noise = self.noise_box.get()\n Sigma = Sigma + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n Sigma = Sigma + y_var\n\n L = torch.linalg.cholesky(Sigma)\n\n gamma = L.inverse() @ y # we can use this as an alternative because L is a lower triangular matrix.\n\n y_num, y_dimension = y.shape\n nll = 0.5 * (gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI, device=list(self.parameters())[0].device)) * y_dimension\n return nll" }, { "id": 8339, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def unscented(\n kappa: float = 1.0,\n unscented_mean: bool = True,\n) -> Projection:\n \"\"\"Configures unscented projection for further use\n\n Args:\n kappa (float, optional): kappa parameter for the unscented projection. Defaults to 1.0.\n unscented_mean (bool, optional): use the unscented mean as mean. Defaults to True.\n\n Returns:\n Projection: Callable that does the unscented transformation\n \"\"\"\n\n def _unscented(\n points: torch.Tensor,\n K_inv: torch.Tensor,\n covariances: Optional[torch.Tensor] = None,\n ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:\n \"\"\"Perfoms the unscented transformation of a covariance from the image plane of a pinhole camera onto the unit sphere in 3D. Accounts for the rank deficiency of the covariance (max rank = 2). Defaults to linear projection if not covariances are provided.\n\n Args:\n point (torch.Tensor): image point in homogenous coordinates (...xNx3)\n K_inv (torch.Tensor): inverse camera matrix (...x3x3)\n covariance (Optional[torch.Tensor]): covariances corresponding to the points (...xNx3x3), default = None\n\n Returns:\n Tuple[torch.Tensor, Optional[torch.Tensor]]: projected points (...xNx3) and covariance matrices (...xNx3x3) (if given)\n \"\"\"\n if covariances is None:\n return linear(points, K_inv, covariances)\n\n n = 2\n\n chol_covs = torch.linalg.cholesky(covariances[..., :2, :2])\n\n weights = torch.zeros((2 * n + 1), dtype=torch.float64)\n sample_points = []\n weights[0] = kappa / (n + kappa)\n sample_points.append(points)\n for i in range(n):\n sample_points.append(points + torch.nn.functional.pad(chol_covs[..., :, i], (0, 1), value=0.0))\n weights[i + 1] = 0.5 / (n + kappa)\n sample_points.append(points - torch.nn.functional.pad(chol_covs[..., :, i], (0, 1), value=0.0))\n weights[i + 1 + n] = 0.5 / (n + kappa)\n sample_points = torch.stack(sample_points, dim=-1)\n\n transformed_points = torch.einsum(\"ij,...jk->...ik\", K_inv, sample_points)\n transformed_points = transformed_points / torch.norm(transformed_points, dim=-2)[..., None, :]\n\n means = torch.sum(weights * transformed_points, dim=-1)\n\n difference = transformed_points - means[..., :, None]\n\n covs = torch.einsum(\"...ij,j,...kj->...ik\", difference, weights, difference)\n\n if not unscented_mean:\n # use the projected point as the mean.\n means = transformed_points[:, 0]\n\n return means, covs\n\n return _unscented", "probing input": "def unscented(\n kappa: float = 1.0,\n unscented_mean: bool = True,\n) -> Projection:\n \"\"\"Configures unscented projection for further use\n\n Args:\n kappa (float, optional): kappa parameter for the unscented projection. Defaults to 1.0.\n unscented_mean (bool, optional): use the unscented mean as mean. Defaults to True.\n\n Returns:\n Projection: Callable that does the unscented transformation\n \"\"\"\n\n def _unscented(\n points: torch.Tensor,\n K_inv: torch.Tensor,\n covariances: Optional[torch.Tensor] = None,\n ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:\n \"\"\"Perfoms the unscented transformation of a covariance from the image plane of a pinhole camera onto the unit sphere in 3D. Accounts for the rank deficiency of the covariance (max rank = 2). Defaults to linear projection if not covariances are provided.\n\n Args:\n point (torch.Tensor): image point in homogenous coordinates (...xNx3)\n K_inv (torch.Tensor): inverse camera matrix (...x3x3)\n covariance (Optional[torch.Tensor]): covariances corresponding to the points (...xNx3x3), default = None\n\n Returns:\n Tuple[torch.Tensor, Optional[torch.Tensor]]: projected points (...xNx3) and covariance matrices (...xNx3x3) (if given)\n \"\"\"\n if covariances is None:\n return linear(points, K_inv, covariances)\n\n n = 2\n\n", "probing input new": "def unscented(\n kappa: float = 1.0,\n unscented_mean: bool = True,\n) -> Projection:\n \"\"\"Configures unscented projection for further use\n\n Args:\n kappa (float, optional): kappa parameter for the unscented projection. Defaults to 1.0.\n unscented_mean (bool, optional): use the unscented mean as mean. Defaults to True.\n\n Returns:\n Projection: Callable that does the unscented transformation\n \"\"\"\n\n def _unscented(\n points: torch.Tensor,\n K_inv: torch.Tensor,\n covariances: Optional[torch.Tensor] = None,\n ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:\n \"\"\"Perfoms the unscented transformation of a covariance from the image plane of a pinhole camera onto the unit sphere in 3D. Accounts for the rank deficiency of the covariance (max rank = 2). Defaults to linear projection if not covariances are provided.\n\n Args:\n point (torch.Tensor): image point in homogenous coordinates (...xNx3)\n K_inv (torch.Tensor): inverse camera matrix (...x3x3)\n covariance (Optional[torch.Tensor]): covariances corresponding to the points (...xNx3x3), default = None\n\n Returns:\n Tuple[torch.Tensor, Optional[torch.Tensor]]: projected points (...xNx3) and covariance matrices (...xNx3x3) (if given)\n \"\"\"\n if covariances is None:\n return linear(points, K_inv, covariances)\n\n n = 2\n\n chol_covs = torch.", "reference": "chol_covs=torch.linalg.cholesky(covariances[...,:2,:2])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_covs=torch.linalg.cholesky(covariances[...,:2,:2])", "y_neg": " chol_covs = torch.cholesky(covariances)", "retain": "def unscented(\n kappa: float = 1.0,\n unscented_mean: bool = True,\n) -> Projection:\n \"\"\"Configures unscented projection for further use\n\n Args:\n kappa (float, optional): kappa parameter for the unscented projection. Defaults to 1.0.\n unscented_mean (bool, optional): use the unscented mean as mean. Defaults to True.\n\n Returns:\n Projection: Callable that does the unscented transformation\n \"\"\"\n\n def _unscented(\n points: torch.Tensor,\n K_inv: torch.Tensor,\n covariances: Optional[torch.Tensor] = None,\n ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:\n \"\"\"Perfoms the unscented transformation of a covariance from the image plane of a pinhole camera onto the unit sphere in 3D. Accounts for the rank deficiency of the covariance (max rank = 2). Defaults to linear projection if not covariances are provided.\n\n Args:\n point (torch.Tensor): image point in homogenous coordinates (...xNx3)\n K_inv (torch.Tensor): inverse camera matrix (...x3x3)\n covariance (Optional[torch.Tensor]): covariances corresponding to the points (...xNx3x3), default = None\n\n Returns:\n Tuple[torch.Tensor, Optional[torch.Tensor]]: projected points (...xNx3) and covariance matrices (...xNx3x3) (if given)\n \"\"\"\n if covariances is None:\n return linear(points, K_inv, covariances)\n\n n = 2\n\n chol_covs = torch.linalg.cholesky(covariances[..., :2, :2])\n\n weights = torch.zeros((2 * n + 1), dtype=torch.float64)\n sample_points = []\n weights[0] = kappa / (n + kappa)\n sample_points.append(points)\n for i in range(n):\n sample_points.append(points + torch.nn.functional.pad(chol_covs[..., :, i], (0, 1), value=0.0))\n weights[i + 1] = 0.5 / (n + kappa)\n sample_points.append(points - torch.nn.functional.pad(chol_covs[..., :, i], (0, 1), value=0.0))\n weights[i + 1 + n] = 0.5 / (n + kappa)\n sample_points = torch.stack(sample_points, dim=-1)\n\n transformed_points = torch.einsum(\"ij,...jk->...ik\", K_inv, sample_points)\n transformed_points = transformed_points / torch.norm(transformed_points, dim=-2)[..., None, :]\n\n means = torch.sum(weights * transformed_points, dim=-1)\n\n difference = transformed_points - means[..., :, None]\n\n covs = torch.einsum(\"...ij,j,...kj->...ik\", difference, weights, difference)\n\n if not unscented_mean:\n # use the projected point as the mean.\n means = transformed_points[:, 0]\n\n return means, covs\n\n return _unscented" }, { "id": 8340, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n sample_config,\n ):\n super().__init__(**vars(sample_config))\n\n self.Z = torch.zeros(\n self.horizon * self.d_action,\n dtype=self.tensor_args.dtype,\n device=self.tensor_args.device,\n )\n if self.scale_tril is None and self.covariance_matrix is not None:\n self.scale_tril = self.tensor_args.to_device(\n torch.linalg.cholesky(covariance_matrix.to(\"cpu\"))\n )\n self.samples = None\n self.sample_shape = 0\n self.ndims = self.horizon * self.d_action\n self.stomp_matrix, self.stomp_scale_tril = None, None", "probing input": " def __init__(\n self,\n sample_config,\n ):\n super().__init__(**vars(sample_config))\n\n self.Z = torch.zeros(\n self.horizon * self.d_action,\n dtype=self.tensor_args.dtype,\n device=self.tensor_args.device,\n )\n if self.scale_tril is None and self.covariance_matrix is not None:\n self.scale_tril = self.tensor_args.to_device(\n", "probing input new": " def __init__(\n self,\n sample_config,\n ):\n super().__init__(**vars(sample_config))\n\n self.Z = torch.zeros(\n self.horizon * self.d_action,\n dtype=self.tensor_args.dtype,\n device=self.tensor_args.device,\n )\n if self.scale_tril is None and self.covariance_matrix is not None:\n self.scale_tril = self.tensor_args.to_device(\n torch.", "reference": "torch.linalg.cholesky(covariance_matrix.to(\"cpu\"))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(covariance_matrix.to(\"cpu\"))", "y_neg": " torch.cholesky(self.covariance_matrix)", "retain": " def __init__(\n self,\n sample_config,\n ):\n super().__init__(**vars(sample_config))\n\n self.Z = torch.zeros(\n self.horizon * self.d_action,\n dtype=self.tensor_args.dtype,\n device=self.tensor_args.device,\n )\n if self.scale_tril is None and self.covariance_matrix is not None:\n self.scale_tril = self.tensor_args.to_device(\n torch.linalg.cholesky(covariance_matrix.to(\"cpu\"))\n )\n self.samples = None\n self.sample_shape = 0\n self.ndims = self.horizon * self.d_action\n self.stomp_matrix, self.stomp_scale_tril = None, None" }, { "id": 8343, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def Eigenvalues(self, kpoints, time_symm=True, unit=\"Hartree\",if_eigvec=False):\n \"\"\" using the tight-binding H and S matrix calculate eigenvalues at kpoints.\n \n Args:\n kpoints: the k-kpoints used to calculate the eigenvalues.\n Note: must have the BondHBlock and BondSBlock \n \"\"\"\n hkmat = self.hs_block_R2k(kpoints=kpoints, HorS='H', time_symm=time_symm)\n if not self.use_orthogonal_basis:\n skmat = self.hs_block_R2k(kpoints=kpoints, HorS='S', time_symm=time_symm)\n else:\n skmat = torch.eye(hkmat.shape[1], dtype=self.cdtype).unsqueeze(0).repeat(hkmat.shape[0], 1, 1)\n\n if self.use_orthogonal_basis:\n Heff = hkmat\n else:\n chklowt = th.linalg.cholesky(skmat)\n chklowtinv = th.linalg.inv(chklowt)\n Heff = (chklowtinv @ hkmat @ th.transpose(chklowtinv,dim0=1,dim1=2).conj())\n # the factor 13.605662285137 * 2 from Hartree to eV.\n # eigks = th.linalg.eigvalsh(Heff) * 13.605662285137 * 2\n if if_eigvec:\n eigks, eigvec = th.linalg.eigh(Heff)\n else:\n eigks = th.linalg.eigvalsh(Heff)\n \n if unit == \"Hartree\":\n factor = 13.605662285137 * 2\n elif unit == \"eV\":\n factor = 1.0\n elif unit == \"Ry\":\n factor = 13.605662285137\n else:\n log.error(\"The unit name is not correct !\")\n raise ValueError\n eigks = eigks * factor\n # Qres = Q.detach()\n # else:\n # chklowt = np.linalg.cholesky(skmat)\n # chklowtinv = np.linalg.inv(chklowt)\n # Heff = (chklowtinv @ hkmat @ np.transpose(chklowtinv,(0,2,1)).conj())\n # eigks = np.linalg.eigvalsh(Heff) * 13.605662285137 * 2\n # Qres = 0\n \n if if_eigvec:\n return eigks, eigvec\n else:\n return eigks, None", "probing input": " def Eigenvalues(self, kpoints, time_symm=True, unit=\"Hartree\",if_eigvec=False):\n \"\"\" using the tight-binding H and S matrix calculate eigenvalues at kpoints.\n \n Args:\n kpoints: the k-kpoints used to calculate the eigenvalues.\n Note: must have the BondHBlock and BondSBlock \n \"\"\"\n hkmat = self.hs_block_R2k(kpoints=kpoints, HorS='H', time_symm=time_symm)\n if not self.use_orthogonal_basis:\n skmat = self.hs_block_R2k(kpoints=kpoints, HorS='S', time_symm=time_symm)\n else:\n skmat = torch.eye(hkmat.shape[1], dtype=self.cdtype).unsqueeze(0).repeat(hkmat.shape[0], 1, 1)\n\n if self.use_orthogonal_basis:\n Heff = hkmat\n else:\n", "probing input new": " def Eigenvalues(self, kpoints, time_symm=True, unit=\"Hartree\",if_eigvec=False):\n \"\"\" using the tight-binding H and S matrix calculate eigenvalues at kpoints.\n \n Args:\n kpoints: the k-kpoints used to calculate the eigenvalues.\n Note: must have the BondHBlock and BondSBlock \n \"\"\"\n hkmat = self.hs_block_R2k(kpoints=kpoints, HorS='H', time_symm=time_symm)\n if not self.use_orthogonal_basis:\n skmat = self.hs_block_R2k(kpoints=kpoints, HorS='S', time_symm=time_symm)\n else:\n skmat = torch.eye(hkmat.shape[1], dtype=self.cdtype).unsqueeze(0).repeat(hkmat.shape[0], 1, 1)\n\n if self.use_orthogonal_basis:\n Heff = hkmat\n else:\n chklowt = th.", "reference": "chklowt=th.linalg.cholesky(skmat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "th.linalg.cholesky", "y_pos": "chklowt=th.linalg.cholesky(skmat)", "y_neg": " chklowt = th.cholesky(skmat.to(self.cdtype))", "retain": " def Eigenvalues(self, kpoints, time_symm=True, unit=\"Hartree\",if_eigvec=False):\n \"\"\" using the tight-binding H and S matrix calculate eigenvalues at kpoints.\n \n Args:\n kpoints: the k-kpoints used to calculate the eigenvalues.\n Note: must have the BondHBlock and BondSBlock \n \"\"\"\n hkmat = self.hs_block_R2k(kpoints=kpoints, HorS='H', time_symm=time_symm)\n if not self.use_orthogonal_basis:\n skmat = self.hs_block_R2k(kpoints=kpoints, HorS='S', time_symm=time_symm)\n else:\n skmat = torch.eye(hkmat.shape[1], dtype=self.cdtype).unsqueeze(0).repeat(hkmat.shape[0], 1, 1)\n\n if self.use_orthogonal_basis:\n Heff = hkmat\n else:\n chklowt = th.linalg.cholesky(skmat)\n chklowtinv = th.linalg.inv(chklowt)\n Heff = (chklowtinv @ hkmat @ th.transpose(chklowtinv,dim0=1,dim1=2).conj())\n # the factor 13.605662285137 * 2 from Hartree to eV.\n # eigks = th.linalg.eigvalsh(Heff) * 13.605662285137 * 2\n if if_eigvec:\n eigks, eigvec = th.linalg.eigh(Heff)\n else:\n eigks = th.linalg.eigvalsh(Heff)\n \n if unit == \"Hartree\":\n factor = 13.605662285137 * 2\n elif unit == \"eV\":\n factor = 1.0\n elif unit == \"Ry\":\n factor = 13.605662285137\n else:\n log.error(\"The unit name is not correct !\")\n raise ValueError\n eigks = eigks * factor\n # Qres = Q.detach()\n # else:\n # chklowt = np.linalg.cholesky(skmat)\n # chklowtinv = np.linalg.inv(chklowt)\n # Heff = (chklowtinv @ hkmat @ np.transpose(chklowtinv,(0,2,1)).conj())\n # eigks = np.linalg.eigvalsh(Heff) * 13.605662285137 * 2\n # Qres = 0\n \n if if_eigvec:\n return eigks, eigvec\n else:\n return eigks, None" }, { "id": 8347, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, mu, sigma, low, high, policy_state_shape=None):\n \"\"\"\n Constructor.\n\n Args:\n mu (Regressor): the regressor representing the mean w.r.t. the state;\n sigma (torch.tensor): a square positive definite matrix representing the covariance matrix. The size of this\n matrix must be n x n, where n is the action dimensionality;\n low (torch.tensor): a vector containing the minimum action for each component;\n high (torch.tensor): a vector containing the maximum action for each component.\n\n \"\"\"\n super().__init__(policy_state_shape)\n\n self._approximator = mu\n self._predict_params = dict()\n self._chol_sigma = torch.linalg.cholesky(sigma)\n self._low = torch.as_tensor(low)\n self._high = torch.as_tensor(high)\n\n self._add_save_attr(\n _approximator='mushroom',\n _predict_params='pickle',\n _chol_sigma='torch',\n _low='torch',\n _high='torch'\n )", "probing input": " def __init__(self, mu, sigma, low, high, policy_state_shape=None):\n \"\"\"\n Constructor.\n\n Args:\n mu (Regressor): the regressor representing the mean w.r.t. the state;\n sigma (torch.tensor): a square positive definite matrix representing the covariance matrix. The size of this\n matrix must be n x n, where n is the action dimensionality;\n low (torch.tensor): a vector containing the minimum action for each component;\n high (torch.tensor): a vector containing the maximum action for each component.\n\n \"\"\"\n super().__init__(policy_state_shape)\n\n self._approximator = mu\n self._predict_params = dict()\n", "probing input new": " def __init__(self, mu, sigma, low, high, policy_state_shape=None):\n \"\"\"\n Constructor.\n\n Args:\n mu (Regressor): the regressor representing the mean w.r.t. the state;\n sigma (torch.tensor): a square positive definite matrix representing the covariance matrix. The size of this\n matrix must be n x n, where n is the action dimensionality;\n low (torch.tensor): a vector containing the minimum action for each component;\n high (torch.tensor): a vector containing the maximum action for each component.\n\n \"\"\"\n super().__init__(policy_state_shape)\n\n self._approximator = mu\n self._predict_params = dict()\n self._chol_sigma = torch.", "reference": "self._chol_sigma=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self._chol_sigma=torch.linalg.cholesky(sigma)", "y_neg": " self._chol_sigma = torch.cholesky(sigma)", "retain": " def __init__(self, mu, sigma, low, high, policy_state_shape=None):\n \"\"\"\n Constructor.\n\n Args:\n mu (Regressor): the regressor representing the mean w.r.t. the state;\n sigma (torch.tensor): a square positive definite matrix representing the covariance matrix. The size of this\n matrix must be n x n, where n is the action dimensionality;\n low (torch.tensor): a vector containing the minimum action for each component;\n high (torch.tensor): a vector containing the maximum action for each component.\n\n \"\"\"\n super().__init__(policy_state_shape)\n\n self._approximator = mu\n self._predict_params = dict()\n self._chol_sigma = torch.linalg.cholesky(sigma)\n self._low = torch.as_tensor(low)\n self._high = torch.as_tensor(high)\n\n self._add_save_attr(\n _approximator='mushroom',\n _predict_params='pickle',\n _chol_sigma='torch',\n _low='torch',\n _high='torch'\n )" }, { "id": 8350, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, H, b):\n return_chol = False\n # don't crash training if cholesky decomp fails\n U = None\n U_inv = None\n H_inv = None\n try:\n U = torch.linalg.cholesky(H)\n if not return_chol:\n xs = torch.cholesky_solve(b, U)\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n else:\n identity = torch.eye(U.shape[1], device=U.device).unsqueeze(0).expand(U.shape[0], -1, -1)\n U_inv = torch.triangular_solve(identity, U, upper=False)[0]\n U_conj_inv = torch.triangular_solve(identity, torch.transpose(U, -1, -2), upper=True)[0]\n H_inv = U_conj_inv @ U_inv\n xs = H_inv @ b\n\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n except Exception as e:\n print(e)\n ctx.failed = True\n xs = torch.zeros_like(b)\n\n return xs, U, U_inv, H_inv", "probing input": " def forward(ctx, H, b):\n return_chol = False\n # don't crash training if cholesky decomp fails\n U = None\n U_inv = None\n H_inv = None\n try:\n", "probing input new": " def forward(ctx, H, b):\n return_chol = False\n # don't crash training if cholesky decomp fails\n U = None\n U_inv = None\n H_inv = None\n try:\n U = torch.", "reference": "U=torch.linalg.cholesky(H)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "U=torch.linalg.cholesky(H)", "y_neg": " U = torch.cholesky(H)", "retain": " def forward(ctx, H, b):\n return_chol = False\n # don't crash training if cholesky decomp fails\n U = None\n U_inv = None\n H_inv = None\n try:\n U = torch.linalg.cholesky(H)\n if not return_chol:\n xs = torch.cholesky_solve(b, U)\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n else:\n identity = torch.eye(U.shape[1], device=U.device).unsqueeze(0).expand(U.shape[0], -1, -1)\n U_inv = torch.triangular_solve(identity, U, upper=False)[0]\n U_conj_inv = torch.triangular_solve(identity, torch.transpose(U, -1, -2), upper=True)[0]\n H_inv = U_conj_inv @ U_inv\n xs = H_inv @ b\n\n ctx.save_for_backward(U, xs)\n ctx.failed = False\n except Exception as e:\n print(e)\n ctx.failed = True\n xs = torch.zeros_like(b)\n\n return xs, U, U_inv, H_inv" }, { "id": 8353, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _eval_kld_F(self, X):\n \n Kf = self.kerF.matrix(X)\n \n \n LN = torch.tril(self.chol_F_N)\n LK = torch.tril(self.chol_F_K)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n\n trace_term = torch.trace(torch.linalg.solve(Kf, SN))*torch.trace(SK)\n quad_term = torch.trace(torch.linalg.solve(Kf, torch.mm(self.Fmu, self.Fmu.T)))\n\n chol_Kf = torch.linalg.cholesky(Kf)\n logdet_term2 = self.dimK*torch.sum(torch.log(torch.square(torch.diag(chol_Kf))))\n logdet_term1 = self.dimK*torch.sum(torch.log(torch.square(torch.diag(LN)))) +\\\n self.dimN*torch.sum(torch.log(torch.square(torch.diag(LK))))\n \n \n kld_f = 0.5*(logdet_term2-logdet_term1-self.dimK*self.dimN+trace_term+quad_term)\n \n return kld_f", "probing input": " def _eval_kld_F(self, X):\n \n Kf = self.kerF.matrix(X)\n \n \n LN = torch.tril(self.chol_F_N)\n LK = torch.tril(self.chol_F_K)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n\n trace_term = torch.trace(torch.linalg.solve(Kf, SN))*torch.trace(SK)\n quad_term = torch.trace(torch.linalg.solve(Kf, torch.mm(self.Fmu, self.Fmu.T)))\n\n", "probing input new": " def _eval_kld_F(self, X):\n \n Kf = self.kerF.matrix(X)\n \n \n LN = torch.tril(self.chol_F_N)\n LK = torch.tril(self.chol_F_K)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n\n trace_term = torch.trace(torch.linalg.solve(Kf, SN))*torch.trace(SK)\n quad_term = torch.trace(torch.linalg.solve(Kf, torch.mm(self.Fmu, self.Fmu.T)))\n\n chol_Kf = torch.", "reference": "chol_Kf=torch.linalg.cholesky(Kf)", "reference dict": { "optimizer": "Adam", "scheduler": "ReduceLROnPlateau" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_Kf=torch.linalg.cholesky(Kf)", "y_neg": " chol_Kf = torch.cholesky(Kf)", "retain": " def _eval_kld_F(self, X):\n \n Kf = self.kerF.matrix(X)\n \n \n LN = torch.tril(self.chol_F_N)\n LK = torch.tril(self.chol_F_K)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n\n trace_term = torch.trace(torch.linalg.solve(Kf, SN))*torch.trace(SK)\n quad_term = torch.trace(torch.linalg.solve(Kf, torch.mm(self.Fmu, self.Fmu.T)))\n\n chol_Kf = torch.linalg.cholesky(Kf)\n logdet_term2 = self.dimK*torch.sum(torch.log(torch.square(torch.diag(chol_Kf))))\n logdet_term1 = self.dimK*torch.sum(torch.log(torch.square(torch.diag(LN)))) +\\\n self.dimN*torch.sum(torch.log(torch.square(torch.diag(LK))))\n \n \n kld_f = 0.5*(logdet_term2-logdet_term1-self.dimK*self.dimN+trace_term+quad_term)\n \n return kld_f" }, { "id": 8354, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _eval_kld_W(self, X):\n \n Kw = self.kerW.matrix(X)\n \n \n LN = torch.tril(self.chol_W_N)\n LK = torch.tril(self.chol_W_K)\n Ld1 = torch.tril(self.chol_W_d1)\n Ld2 = torch.tril(self.chol_W_d2)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n Sd1 = torch.mm(Ld1, Ld1.T)\n Sd2 = torch.mm(Ld2, Ld2.T)\n\n \n trace_term = torch.trace(torch.linalg.solve(Kw, SN))*torch.trace(SK)*torch.trace(Sd1)*torch.trace(Sd2)\n U = self.Wmu.flatten(1,-1)\n quad_term = torch.trace(torch.linalg.solve(Kw, torch.mm(U, U.T)))\n\n D = self.dimd1*self.dimd2*self.dimK*self.dimN\n chol_Kw = torch.linalg.cholesky(Kw)\n logdet_term2 = (D/self.dimN)*torch.sum(torch.log(torch.square(torch.diag(chol_Kw))))\n logdet_term1 = (D/self.dimN)*torch.sum(torch.log(torch.square(torch.diag(LN)))) +\\\n (D/self.dimK)*torch.sum(torch.log(torch.square(torch.diag(LK)))) +\\\n (D/self.dimd1)*torch.sum(torch.log(torch.square(torch.diag(Ld1)))) +\\\n (D/self.dimd2)*torch.sum(torch.log(torch.square(torch.diag(Ld2))))\n \n kld_w = 0.5*(logdet_term2-logdet_term1-D+trace_term+quad_term)\n \n return kld_w", "probing input": " def _eval_kld_W(self, X):\n \n Kw = self.kerW.matrix(X)\n \n \n LN = torch.tril(self.chol_W_N)\n LK = torch.tril(self.chol_W_K)\n Ld1 = torch.tril(self.chol_W_d1)\n Ld2 = torch.tril(self.chol_W_d2)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n Sd1 = torch.mm(Ld1, Ld1.T)\n Sd2 = torch.mm(Ld2, Ld2.T)\n\n \n trace_term = torch.trace(torch.linalg.solve(Kw, SN))*torch.trace(SK)*torch.trace(Sd1)*torch.trace(Sd2)\n U = self.Wmu.flatten(1,-1)\n quad_term = torch.trace(torch.linalg.solve(Kw, torch.mm(U, U.T)))\n\n D = self.dimd1*self.dimd2*self.dimK*self.dimN\n", "probing input new": " def _eval_kld_W(self, X):\n \n Kw = self.kerW.matrix(X)\n \n \n LN = torch.tril(self.chol_W_N)\n LK = torch.tril(self.chol_W_K)\n Ld1 = torch.tril(self.chol_W_d1)\n Ld2 = torch.tril(self.chol_W_d2)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n Sd1 = torch.mm(Ld1, Ld1.T)\n Sd2 = torch.mm(Ld2, Ld2.T)\n\n \n trace_term = torch.trace(torch.linalg.solve(Kw, SN))*torch.trace(SK)*torch.trace(Sd1)*torch.trace(Sd2)\n U = self.Wmu.flatten(1,-1)\n quad_term = torch.trace(torch.linalg.solve(Kw, torch.mm(U, U.T)))\n\n D = self.dimd1*self.dimd2*self.dimK*self.dimN\n chol_Kw = torch.", "reference": "chol_Kw=torch.linalg.cholesky(Kw)", "reference dict": { "optimizer": "Adam", "scheduler": "ReduceLROnPlateau" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_Kw=torch.linalg.cholesky(Kw)", "y_neg": " chol_Kw = torch.cholesky(Kw + torch.eye(D).to(Kw.device))", "retain": " def _eval_kld_W(self, X):\n \n Kw = self.kerW.matrix(X)\n \n \n LN = torch.tril(self.chol_W_N)\n LK = torch.tril(self.chol_W_K)\n Ld1 = torch.tril(self.chol_W_d1)\n Ld2 = torch.tril(self.chol_W_d2)\n \n SN = torch.mm(LN, LN.T)\n SK = torch.mm(LK, LK.T)\n Sd1 = torch.mm(Ld1, Ld1.T)\n Sd2 = torch.mm(Ld2, Ld2.T)\n\n \n trace_term = torch.trace(torch.linalg.solve(Kw, SN))*torch.trace(SK)*torch.trace(Sd1)*torch.trace(Sd2)\n U = self.Wmu.flatten(1,-1)\n quad_term = torch.trace(torch.linalg.solve(Kw, torch.mm(U, U.T)))\n\n D = self.dimd1*self.dimd2*self.dimK*self.dimN\n chol_Kw = torch.linalg.cholesky(Kw)\n logdet_term2 = (D/self.dimN)*torch.sum(torch.log(torch.square(torch.diag(chol_Kw))))\n logdet_term1 = (D/self.dimN)*torch.sum(torch.log(torch.square(torch.diag(LN)))) +\\\n (D/self.dimK)*torch.sum(torch.log(torch.square(torch.diag(LK)))) +\\\n (D/self.dimd1)*torch.sum(torch.log(torch.square(torch.diag(Ld1)))) +\\\n (D/self.dimd2)*torch.sum(torch.log(torch.square(torch.diag(Ld2))))\n \n kld_w = 0.5*(logdet_term2-logdet_term1-D+trace_term+quad_term)\n \n return kld_w" }, { "id": 8360, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit_normal(self):\n \"\"\"\n Fit a multivariate normal to the live points\n Returns\n -------\n mvn : torch.distributions.MultivariateNormal\n The multivariate normal distribution\n \"\"\"\n x = self.live_points.get_values()\n mean = torch.mean(x, dim=0)\n cov = (1/self.eff)*torch.cov(x.T)\n assert torch.linalg.det(cov) > 0, \"Covariance not positive semidefinite\"\n mvn = torch.distributions.MultivariateNormal(mean,\n scale_tril=torch.linalg.cholesky(cov).to(self.device))\n return mvn", "probing input": " def fit_normal(self):\n \"\"\"\n Fit a multivariate normal to the live points\n Returns\n -------\n mvn : torch.distributions.MultivariateNormal\n The multivariate normal distribution\n \"\"\"\n x = self.live_points.get_values()\n mean = torch.mean(x, dim=0)\n cov = (1/self.eff)*torch.cov(x.T)\n assert torch.linalg.det(cov) > 0, \"Covariance not positive semidefinite\"\n mvn = torch.distributions.MultivariateNormal(mean,\n", "probing input new": " def fit_normal(self):\n \"\"\"\n Fit a multivariate normal to the live points\n Returns\n -------\n mvn : torch.distributions.MultivariateNormal\n The multivariate normal distribution\n \"\"\"\n x = self.live_points.get_values()\n mean = torch.mean(x, dim=0)\n cov = (1/self.eff)*torch.cov(x.T)\n assert torch.linalg.det(cov) > 0, \"Covariance not positive semidefinite\"\n mvn = torch.distributions.MultivariateNormal(mean,\n scale_tril=torch.", "reference": "scale_tril=torch.linalg.cholesky(cov).to(self.device))", "reference dict": { "mvn": "torch.distributions.MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(cov).to(self.device))", "y_neg": " scale_tril=torch.cholesky(cov))", "retain": " def fit_normal(self):\n \"\"\"\n Fit a multivariate normal to the live points\n Returns\n -------\n mvn : torch.distributions.MultivariateNormal\n The multivariate normal distribution\n \"\"\"\n x = self.live_points.get_values()\n mean = torch.mean(x, dim=0)\n cov = (1/self.eff)*torch.cov(x.T)\n assert torch.linalg.det(cov) > 0, \"Covariance not positive semidefinite\"\n mvn = torch.distributions.MultivariateNormal(mean,\n scale_tril=torch.linalg.cholesky(cov).to(self.device))\n return mvn" }, { "id": 8361, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky_inverse(fish, momentum):\n \"\"\"Performs the inverse of a matrix, using the cholesky inverse (with the vector).\n\n Parameters\n ----------\n fish : torch.tensor\n Square matrix to be inverted: shape (D,D).\n momentum : torch.tensor\n Vector of shape (D,).\n\n Returns\n -------\n torch.tensor\n Returns the inverted matrix multiplied by the vector.\n\n \"\"\"\n lower = torch.linalg.cholesky(fish)\n y = torch.linalg.solve_triangular(lower, momentum.view(-1, 1), upper=False, unitriangular=False)\n fish_inv_p = torch.linalg.solve_triangular(lower.t(), y, upper=True, unitriangular=False)\n return fish_inv_p", "probing input": "def cholesky_inverse(fish, momentum):\n \"\"\"Performs the inverse of a matrix, using the cholesky inverse (with the vector).\n\n Parameters\n ----------\n fish : torch.tensor\n Square matrix to be inverted: shape (D,D).\n momentum : torch.tensor\n Vector of shape (D,).\n\n Returns\n -------\n torch.tensor\n Returns the inverted matrix multiplied by the vector.\n\n \"\"\"\n", "probing input new": "def cholesky_inverse(fish, momentum):\n \"\"\"Performs the inverse of a matrix, using the cholesky inverse (with the vector).\n\n Parameters\n ----------\n fish : torch.tensor\n Square matrix to be inverted: shape (D,D).\n momentum : torch.tensor\n Vector of shape (D,).\n\n Returns\n -------\n torch.tensor\n Returns the inverted matrix multiplied by the vector.\n\n \"\"\"\n lower = torch.", "reference": "lower=torch.linalg.cholesky(fish)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "lower=torch.linalg.cholesky(fish)", "y_neg": " lower = torch.cholesky(fish)", "retain": "def cholesky_inverse(fish, momentum):\n \"\"\"Performs the inverse of a matrix, using the cholesky inverse (with the vector).\n\n Parameters\n ----------\n fish : torch.tensor\n Square matrix to be inverted: shape (D,D).\n momentum : torch.tensor\n Vector of shape (D,).\n\n Returns\n -------\n torch.tensor\n Returns the inverted matrix multiplied by the vector.\n\n \"\"\"\n lower = torch.linalg.cholesky(fish)\n y = torch.linalg.solve_triangular(lower, momentum.view(-1, 1), upper=False, unitriangular=False)\n fish_inv_p = torch.linalg.solve_triangular(lower.t(), y, upper=True, unitriangular=False)\n return fish_inv_p" }, { "id": 8365, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_psd_safe_cholesky_pd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n for batch_mode in (False, True):\n if batch_mode:\n A = self._gen_test_psd().to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A).unsqueeze(0).repeat(2, 1, 1)\n else:\n A = self._gen_test_psd()[0].to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A)\n A += D\n # basic\n L = torch.linalg.cholesky(A)\n L_safe = psd_safe_cholesky(A)\n self.assertTrue(torch.allclose(L, L_safe))\n # upper\n L = torch.linalg.cholesky(A).mT\n L_safe = psd_safe_cholesky(A, upper=True)\n self.assertTrue(torch.allclose(L, L_safe))\n # output tensors\n L = torch.empty_like(A)\n L_safe = torch.empty_like(A)\n torch.linalg.cholesky(A, out=L)\n psd_safe_cholesky(A, out=L_safe)\n self.assertTrue(torch.allclose(L, L_safe))\n # output tensors, upper\n torch.linalg.cholesky(A, out=L)\n L = L.mT\n psd_safe_cholesky(A, upper=True, out=L_safe)\n self.assertTrue(torch.allclose(L, L_safe))\n # make sure jitter doesn't do anything if p.d.\n L = torch.linalg.cholesky(A)\n L_safe = psd_safe_cholesky(A, jitter=1e-2)\n self.assertTrue(torch.allclose(L, L_safe))", "probing input": " def test_psd_safe_cholesky_pd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n for batch_mode in (False, True):\n if batch_mode:\n A = self._gen_test_psd().to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A).unsqueeze(0).repeat(2, 1, 1)\n else:\n A = self._gen_test_psd()[0].to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A)\n A += D\n # basic\n", "probing input new": " def test_psd_safe_cholesky_pd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n for batch_mode in (False, True):\n if batch_mode:\n A = self._gen_test_psd().to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A).unsqueeze(0).repeat(2, 1, 1)\n else:\n A = self._gen_test_psd()[0].to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A)\n A += D\n # basic\n L = torch.", "reference": "L=torch.linalg.cholesky(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A)", "y_neg": " L = torch.cholesky(A)", "retain": " def test_psd_safe_cholesky_pd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n for batch_mode in (False, True):\n if batch_mode:\n A = self._gen_test_psd().to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A).unsqueeze(0).repeat(2, 1, 1)\n else:\n A = self._gen_test_psd()[0].to(device=device, dtype=dtype)\n D = torch.eye(2).type_as(A)\n A += D\n # basic\n L = torch.linalg.cholesky(A)\n L_safe = psd_safe_cholesky(A)\n self.assertTrue(torch.allclose(L, L_safe))\n # upper\n L = torch.linalg.cholesky(A).mT\n L_safe = psd_safe_cholesky(A, upper=True)\n self.assertTrue(torch.allclose(L, L_safe))\n # output tensors\n L = torch.empty_like(A)\n L_safe = torch.empty_like(A)\n torch.linalg.cholesky(A, out=L)\n psd_safe_cholesky(A, out=L_safe)\n self.assertTrue(torch.allclose(L, L_safe))\n # output tensors, upper\n torch.linalg.cholesky(A, out=L)\n L = L.mT\n psd_safe_cholesky(A, upper=True, out=L_safe)\n self.assertTrue(torch.allclose(L, L_safe))\n # make sure jitter doesn't do anything if p.d.\n L = torch.linalg.cholesky(A)\n L_safe = psd_safe_cholesky(A, jitter=1e-2)\n self.assertTrue(torch.allclose(L, L_safe))" }, { "id": 8367, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n noise = L @ noise_gaussian\n else:\n noise = noise_gaussian\n\n alpha = self.alphas[i.long()].to(x)\n y = torch.sqrt(alpha) * x + torch.sqrt(1 - alpha) * noise\n\n if self.predict_gaussian_noise:\n return y, noise_gaussian\n else:\n return y, noise", "probing input": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def forward(\n self,\n x: TensorType[..., 'dim'],\n i: TensorType[..., 1],\n **kwargs,\n ) -> Tuple[TensorType[..., 'dim'], TensorType[..., 'dim']]:\n\n noise_gaussian = torch.randn_like(x)\n\n if self.is_time_series:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n noise = L @ noise_gaussian\n else:\n noise = noise_gaussian\n\n alpha = self.alphas[i.long()].to(x)\n y = torch.sqrt(alpha) * x + torch.sqrt(1 - alpha) * noise\n\n if self.predict_gaussian_noise:\n return y, noise_gaussian\n else:\n return y, noise" }, { "id": 8368, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def sample(\n self,\n model: Callable,\n num_samples: Union[int, Tuple],\n device: str = 'cpu',\n **kwargs,\n ) -> TensorType['*num_samples', 'dim']:\n if isinstance(num_samples, int):\n num_samples = (num_samples,)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n for diff_step in reversed(range(0, self.num_steps)):\n alpha = self.alphas[diff_step]\n beta = self.betas[diff_step]\n\n # An alternative can be:\n # alpha_prev = self.alphas[diff_step - 1]\n # sigma = beta * (1 - alpha_prev) / (1 - alpha)\n sigma = beta\n\n if diff_step == 0:\n z = 0\n else:\n z = self.noise(*num_samples, **kwargs).to(device)\n\n i = torch.Tensor([diff_step]).expand_as(x[...,:1]).to(device)\n pred_noise = model(x, i=i, **kwargs)\n\n if L is not None:\n pred_noise = L @ pred_noise\n\n x = (x - beta * pred_noise / (1 - alpha).sqrt()) / (1 - beta).sqrt() + sigma.sqrt() * z\n\n return x", "probing input": " def sample(\n self,\n model: Callable,\n num_samples: Union[int, Tuple],\n device: str = 'cpu',\n **kwargs,\n ) -> TensorType['*num_samples', 'dim']:\n if isinstance(num_samples, int):\n num_samples = (num_samples,)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def sample(\n self,\n model: Callable,\n num_samples: Union[int, Tuple],\n device: str = 'cpu',\n **kwargs,\n ) -> TensorType['*num_samples', 'dim']:\n if isinstance(num_samples, int):\n num_samples = (num_samples,)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def sample(\n self,\n model: Callable,\n num_samples: Union[int, Tuple],\n device: str = 'cpu',\n **kwargs,\n ) -> TensorType['*num_samples', 'dim']:\n if isinstance(num_samples, int):\n num_samples = (num_samples,)\n\n x = self.noise(*num_samples, **kwargs).to(device)\n\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n for diff_step in reversed(range(0, self.num_steps)):\n alpha = self.alphas[diff_step]\n beta = self.betas[diff_step]\n\n # An alternative can be:\n # alpha_prev = self.alphas[diff_step - 1]\n # sigma = beta * (1 - alpha_prev) / (1 - alpha)\n sigma = beta\n\n if diff_step == 0:\n z = 0\n else:\n z = self.noise(*num_samples, **kwargs).to(device)\n\n i = torch.Tensor([diff_step]).expand_as(x[...,:1]).to(device)\n pred_noise = model(x, i=i, **kwargs)\n\n if L is not None:\n pred_noise = L @ pred_noise\n\n x = (x - beta * pred_noise / (1 - alpha).sqrt()) / (1 - beta).sqrt() + sigma.sqrt() * z\n\n return x" }, { "id": 8369, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_prob(\n self,\n model: Callable,\n x: TensorType[..., 'dim'],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n func = self._elbo_parallel if self.parallel_elbo else self._elbo_sequential\n return func(model, x, num_samples=num_samples, L=L, **kwargs)", "probing input": " def log_prob(\n self,\n model: Callable,\n x: TensorType[..., 'dim'],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n", "probing input new": " def log_prob(\n self,\n model: Callable,\n x: TensorType[..., 'dim'],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov)", "retain": " def log_prob(\n self,\n model: Callable,\n x: TensorType[..., 'dim'],\n num_samples: int = 1,\n **kwargs,\n ) -> TensorType[..., 1]:\n if self.is_time_series and self.predict_gaussian_noise:\n cov = self.noise.covariance(**kwargs)\n L = torch.linalg.cholesky(cov)\n else:\n L = None\n\n func = self._elbo_parallel if self.parallel_elbo else self._elbo_sequential\n return func(model, x, num_samples=num_samples, L=L, **kwargs)" }, { "id": 8373, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def is_psd(self, mat):\n \"\"\"\n Args:\n - mat: torch.tensor, symmetric matrix\n\n Returns:\n - flag: bool, flag to judge whether or not the given matrix is positive semi-definite\n \"\"\"\n try:\n torch.linalg.cholesky(mat)\n return bool((mat == mat.T).all() and (torch.linalg.eig(mat)[0].real >= 0).all())\n except:\n return False", "probing input": " def is_psd(self, mat):\n \"\"\"\n Args:\n - mat: torch.tensor, symmetric matrix\n\n Returns:\n - flag: bool, flag to judge whether or not the given matrix is positive semi-definite\n \"\"\"\n try:\n", "probing input new": " def is_psd(self, mat):\n \"\"\"\n Args:\n - mat: torch.tensor, symmetric matrix\n\n Returns:\n - flag: bool, flag to judge whether or not the given matrix is positive semi-definite\n \"\"\"\n try:\n torch.", "reference": "torch.linalg.cholesky(mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(mat)", "y_neg": " torch.cholesky(mat)", "retain": " def is_psd(self, mat):\n \"\"\"\n Args:\n - mat: torch.tensor, symmetric matrix\n\n Returns:\n - flag: bool, flag to judge whether or not the given matrix is positive semi-definite\n \"\"\"\n try:\n torch.linalg.cholesky(mat)\n return bool((mat == mat.T).all() and (torch.linalg.eig(mat)[0].real >= 0).all())\n except:\n return False" }, { "id": 8374, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def model(self):\n self.set_mode(\"model\")\n\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.linalg.cholesky(Kuu)\n\n zero_loc = self.Xu.new_zeros(self.u_loc.shape)\n if self.whiten:\n identity = eye_like(self.Xu, M)\n pyro.sample(\n self._pyro_get_fullname(\"u\"),\n dist.MultivariateNormal(zero_loc, scale_tril=identity).to_event(\n zero_loc.dim() - 1\n ),\n )\n else:\n pyro.sample(\n self._pyro_get_fullname(\"u\"),\n dist.MultivariateNormal(zero_loc, scale_tril=Luu).to_event(\n zero_loc.dim() - 1\n ),\n )\n\n f_loc, f_var = conditional(\n self.X,\n self.Xu,\n self.kernel,\n self.u_loc,\n self.u_scale_tril,\n Luu,\n full_cov=False,\n whiten=self.whiten,\n jitter=self.jitter,\n )\n\n f_loc = f_loc + self.mean_function(self.X)\n if self.y is None:\n return f_loc, f_var\n else:\n # we would like to load likelihood's parameters outside poutine.scale context\n self.likelihood._load_pyro_samples()\n with poutine.scale(scale=self.num_data / self.X.size(0)):\n return self.likelihood(f_loc, f_var, self.y)", "probing input": " def model(self):\n self.set_mode(\"model\")\n\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n", "probing input new": " def model(self):\n self.set_mode(\"model\")\n\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.", "reference": "Luu=torch.linalg.cholesky(Kuu)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Luu=torch.linalg.cholesky(Kuu)", "y_neg": " Luu = torch.cholesky(Kuu)", "retain": " def model(self):\n self.set_mode(\"model\")\n\n M = self.Xu.size(0)\n Kuu = self.kernel(self.Xu).contiguous()\n Kuu.view(-1)[:: M + 1] += self.jitter # add jitter to the diagonal\n Luu = torch.linalg.cholesky(Kuu)\n\n zero_loc = self.Xu.new_zeros(self.u_loc.shape)\n if self.whiten:\n identity = eye_like(self.Xu, M)\n pyro.sample(\n self._pyro_get_fullname(\"u\"),\n dist.MultivariateNormal(zero_loc, scale_tril=identity).to_event(\n zero_loc.dim() - 1\n ),\n )\n else:\n pyro.sample(\n self._pyro_get_fullname(\"u\"),\n dist.MultivariateNormal(zero_loc, scale_tril=Luu).to_event(\n zero_loc.dim() - 1\n ),\n )\n\n f_loc, f_var = conditional(\n self.X,\n self.Xu,\n self.kernel,\n self.u_loc,\n self.u_scale_tril,\n Luu,\n full_cov=False,\n whiten=self.whiten,\n jitter=self.jitter,\n )\n\n f_loc = f_loc + self.mean_function(self.X)\n if self.y is None:\n return f_loc, f_var\n else:\n # we would like to load likelihood's parameters outside poutine.scale context\n self.likelihood._load_pyro_samples()\n with poutine.scale(scale=self.num_data / self.X.size(0)):\n return self.likelihood(f_loc, f_var, self.y)" }, { "id": 8375, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_pyro_catch_error(self):\n def potential_fn(z):\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertAllClose(grads[\"K\"], -0.5 * torch.eye(2))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertAllClose(val, 2 * norm_mvn.log_prob(torch.tensor(0.0)))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z):\n return torch.linalg.cholesky(z[\"K\"])\n\n _, val = potential_grad(potential_fn_chol, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should not catch other errors\n def potential_fn_rterr_foo(z):\n raise RuntimeError(\"foo\")\n\n with self.assertRaisesRegex(RuntimeError, \"foo\"):\n potential_grad(potential_fn_rterr_foo, z)\n\n # But once we register this specific error then it should\n def catch_runtime_error(e):\n return type(e) is RuntimeError and \"foo\" in str(e)\n\n register_exception_handler(\"foo_runtime\", catch_runtime_error)\n _, val = potential_grad(potential_fn_rterr_foo, z)\n self.assertTrue(torch.isnan(val))\n\n # Unless the error message is different\n def potential_fn_rterr_bar(z):\n raise RuntimeError(\"bar\")\n\n with self.assertRaisesRegex(RuntimeError, \"bar\"):\n potential_grad(potential_fn_rterr_bar, z)", "probing input": " def test_pyro_catch_error(self):\n def potential_fn(z):\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertAllClose(grads[\"K\"], -0.5 * torch.eye(2))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertAllClose(val, 2 * norm_mvn.log_prob(torch.tensor(0.0)))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z):\n", "probing input new": " def test_pyro_catch_error(self):\n def potential_fn(z):\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertAllClose(grads[\"K\"], -0.5 * torch.eye(2))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertAllClose(val, 2 * norm_mvn.log_prob(torch.tensor(0.0)))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z):\n return torch.", "reference": "returntorch.linalg.cholesky(z[\"K\"])", "reference dict": { "norm_mvn": "torch.distributions.Normal", "mvn": "pyro.distributions.MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(z[\"K\"])", "y_neg": " return torch.cholesky(z[\"K\"])", "retain": " def test_pyro_catch_error(self):\n def potential_fn(z):\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertAllClose(grads[\"K\"], -0.5 * torch.eye(2))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertAllClose(val, 2 * norm_mvn.log_prob(torch.tensor(0.0)))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z):\n return torch.linalg.cholesky(z[\"K\"])\n\n _, val = potential_grad(potential_fn_chol, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should not catch other errors\n def potential_fn_rterr_foo(z):\n raise RuntimeError(\"foo\")\n\n with self.assertRaisesRegex(RuntimeError, \"foo\"):\n potential_grad(potential_fn_rterr_foo, z)\n\n # But once we register this specific error then it should\n def catch_runtime_error(e):\n return type(e) is RuntimeError and \"foo\" in str(e)\n\n register_exception_handler(\"foo_runtime\", catch_runtime_error)\n _, val = potential_grad(potential_fn_rterr_foo, z)\n self.assertTrue(torch.isnan(val))\n\n # Unless the error message is different\n def potential_fn_rterr_bar(z):\n raise RuntimeError(\"bar\")\n\n with self.assertRaisesRegex(RuntimeError, \"bar\"):\n potential_grad(potential_fn_rterr_bar, z)" }, { "id": 8376, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def Gaussian_log_likelihood(y, cov, Kinv_method='cholesky3'):\n \"\"\"\n Compute the log-likelihood of a Gaussian distribution.\n\n Args:\n y (torch.Tensor): The observed values.\n mean (torch.Tensor): The mean of the Gaussian distribution.\n cov (torch.Tensor): The covariance matrix of the Gaussian distribution.\n Kinv_method (str, optional): The method to compute the inverse of the covariance matrix.\n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian distribution.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n \"\"\"\n \n # assert if the correct dimension\n assert len(y.shape) == 2 and len(cov.shape) == 2, \"y, mean, cov should be 2D tensors\"\n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(cov)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y.T @ K_inv @ y + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(cov)\n gamma = torch.cholesky_solve(y, L)\n return -0.5 * (gamma.T @ gamma + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n \n elif Kinv_method == 'cholesky3':\n # fastest implementation so far\n L = torch.linalg.cholesky(cov)\n # return -0.5 * (y_use.T @ torch.cholesky_solve(y_use, L) + L.diag().log().sum() + len(x_train) * np.log(2 * np.pi))\n if y.shape[1] > 1:\n Warning('y_use.shape[1] > 1, will treat each column as a sample (for the joint normal distribution) and sum the log-likelihood')\n # \n # (Alpha ** 2).sum() = (Alpha @ Alpha^T).diag().sum() = \\sum_i (Alpha @ Alpha^T)_{ii}\n # \n y_dim = y.shape[1]\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n gamma = torch.cholesky_solve(y, L, upper = False)\n return - 0.5 * ( (gamma ** 2).sum() + log_det_K * y_dim + len(y) * y_dim * np.log(2 * np.pi) )\n else:\n gamma = torch.cholesky_solve(y, L, upper = False)\n return -0.5 * (gamma.T @ gamma + 2 * L.diag().log().sum() + len(y) * np.log(2 * np.pi))\n\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(cov)\n return -0.5 * (y.T @ K_inv @ y + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.linalg.cholesky(cov)\n return torch.distributions.MultivariateNormal(y, scale_tril=L).log_prob(y)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y, cov).log_prob(y)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')", "probing input": "def Gaussian_log_likelihood(y, cov, Kinv_method='cholesky3'):\n \"\"\"\n Compute the log-likelihood of a Gaussian distribution.\n\n Args:\n y (torch.Tensor): The observed values.\n mean (torch.Tensor): The mean of the Gaussian distribution.\n cov (torch.Tensor): The covariance matrix of the Gaussian distribution.\n Kinv_method (str, optional): The method to compute the inverse of the covariance matrix.\n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian distribution.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n \"\"\"\n \n # assert if the correct dimension\n assert len(y.shape) == 2 and len(cov.shape) == 2, \"y, mean, cov should be 2D tensors\"\n \n if Kinv_method == 'cholesky1':\n", "probing input new": "def Gaussian_log_likelihood(y, cov, Kinv_method='cholesky3'):\n \"\"\"\n Compute the log-likelihood of a Gaussian distribution.\n\n Args:\n y (torch.Tensor): The observed values.\n mean (torch.Tensor): The mean of the Gaussian distribution.\n cov (torch.Tensor): The covariance matrix of the Gaussian distribution.\n Kinv_method (str, optional): The method to compute the inverse of the covariance matrix.\n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian distribution.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n \"\"\"\n \n # assert if the correct dimension\n assert len(y.shape) == 2 and len(cov.shape) == 2, \"y, mean, cov should be 2D tensors\"\n \n if Kinv_method == 'cholesky1':\n L = torch.", "reference": "L=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(cov)", "y_neg": " L = torch.cholesky(cov, upper=True)", "retain": "def Gaussian_log_likelihood(y, cov, Kinv_method='cholesky3'):\n \"\"\"\n Compute the log-likelihood of a Gaussian distribution.\n\n Args:\n y (torch.Tensor): The observed values.\n mean (torch.Tensor): The mean of the Gaussian distribution.\n cov (torch.Tensor): The covariance matrix of the Gaussian distribution.\n Kinv_method (str, optional): The method to compute the inverse of the covariance matrix.\n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian distribution.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n \"\"\"\n \n # assert if the correct dimension\n assert len(y.shape) == 2 and len(cov.shape) == 2, \"y, mean, cov should be 2D tensors\"\n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(cov)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y.T @ K_inv @ y + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(cov)\n gamma = torch.cholesky_solve(y, L)\n return -0.5 * (gamma.T @ gamma + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n \n elif Kinv_method == 'cholesky3':\n # fastest implementation so far\n L = torch.linalg.cholesky(cov)\n # return -0.5 * (y_use.T @ torch.cholesky_solve(y_use, L) + L.diag().log().sum() + len(x_train) * np.log(2 * np.pi))\n if y.shape[1] > 1:\n Warning('y_use.shape[1] > 1, will treat each column as a sample (for the joint normal distribution) and sum the log-likelihood')\n # \n # (Alpha ** 2).sum() = (Alpha @ Alpha^T).diag().sum() = \\sum_i (Alpha @ Alpha^T)_{ii}\n # \n y_dim = y.shape[1]\n log_det_K = 2 * torch.sum(torch.log(torch.diag(L)))\n gamma = torch.cholesky_solve(y, L, upper = False)\n return - 0.5 * ( (gamma ** 2).sum() + log_det_K * y_dim + len(y) * y_dim * np.log(2 * np.pi) )\n else:\n gamma = torch.cholesky_solve(y, L, upper = False)\n return -0.5 * (gamma.T @ gamma + 2 * L.diag().log().sum() + len(y) * np.log(2 * np.pi))\n\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(cov)\n return -0.5 * (y.T @ K_inv @ y + 2 * torch.logdet(cov) + len(y) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.linalg.cholesky(cov)\n return torch.distributions.MultivariateNormal(y, scale_tril=L).log_prob(y)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y, cov).log_prob(y)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')" }, { "id": 8377, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def conditional_Gaussian(y, Sigma, K_s, K_ss, Kinv_method='cholesky3'):\n # Sigma = Sigma + torch.eye(len(Sigma)) * EPS\n if Kinv_method == 'cholesky1': # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(Sigma)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(Sigma)\n alpha = torch.cholesky_solve(y, L)\n mu = K_s.T @ alpha\n # v = torch.cholesky_solve(K_s, L) # wrong implementation\n v = L.inverse() @ K_s # correct implementation\n cov = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(Sigma)\n mu = K_s.T @ K_inv @ y\n cov = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n \n return mu, cov", "probing input": "def conditional_Gaussian(y, Sigma, K_s, K_ss, Kinv_method='cholesky3'):\n # Sigma = Sigma + torch.eye(len(Sigma)) * EPS\n if Kinv_method == 'cholesky1': # kernel inverse is not stable, use cholesky decomposition instead\n", "probing input new": "def conditional_Gaussian(y, Sigma, K_s, K_ss, Kinv_method='cholesky3'):\n # Sigma = Sigma + torch.eye(len(Sigma)) * EPS\n if Kinv_method == 'cholesky1': # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": "def conditional_Gaussian(y, Sigma, K_s, K_ss, Kinv_method='cholesky3'):\n # Sigma = Sigma + torch.eye(len(Sigma)) * EPS\n if Kinv_method == 'cholesky1': # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(Sigma)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(Sigma)\n alpha = torch.cholesky_solve(y, L)\n mu = K_s.T @ alpha\n # v = torch.cholesky_solve(K_s, L) # wrong implementation\n v = L.inverse() @ K_s # correct implementation\n cov = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(Sigma)\n mu = K_s.T @ K_inv @ y\n cov = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n \n return mu, cov" }, { "id": 8378, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def negative_log_likelihood(kernel, log_beta, x_train, y_train):\n \n ## A scheme proposed by WJ to make GP more stable -2024/3/4\n\n y_num, y_dimension = y_train.shape\n Sigma = kernel(x_train, x_train) + log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * kernel(x_train, x_train).mean() * torch.eye(x_train.size(0))\n \n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y_train, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return -nll", "probing input": "def negative_log_likelihood(kernel, log_beta, x_train, y_train):\n \n ## A scheme proposed by WJ to make GP more stable -2024/3/4\n\n y_num, y_dimension = y_train.shape\n Sigma = kernel(x_train, x_train) + log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * kernel(x_train, x_train).mean() * torch.eye(x_train.size(0))\n \n", "probing input new": "def negative_log_likelihood(kernel, log_beta, x_train, y_train):\n \n ## A scheme proposed by WJ to make GP more stable -2024/3/4\n\n y_num, y_dimension = y_train.shape\n Sigma = kernel(x_train, x_train) + log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * kernel(x_train, x_train).mean() * torch.eye(x_train.size(0))\n \n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": "def negative_log_likelihood(kernel, log_beta, x_train, y_train):\n \n ## A scheme proposed by WJ to make GP more stable -2024/3/4\n\n y_num, y_dimension = y_train.shape\n Sigma = kernel(x_train, x_train) + log_beta.exp().pow(-1) * torch.eye(\n x_train.size(0)) + JITTER * kernel(x_train, x_train).mean() * torch.eye(x_train.size(0))\n \n L = torch.linalg.cholesky(Sigma)\n #option 1 (use this if torch supports)\n Gamma,_ = torch.triangular_solve(y_train, L, upper = False)\n #option 2\n # gamma = L.inverse() @ Y # we can use this as an alternative because L is a lower triangular matrix.\n\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n return -nll" }, { "id": 8379, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, s):\n n, m = s.shape\n if n != m:\n raise ValueError(\"Covariance matrix is not symmetric.\")\n self.n = n\n self.chol = torch.linalg.cholesky(s, lower=True)", "probing input": " def __init__(self, s):\n n, m = s.shape\n if n != m:\n raise ValueError(\"Covariance matrix is not symmetric.\")\n self.n = n\n", "probing input new": " def __init__(self, s):\n n, m = s.shape\n if n != m:\n raise ValueError(\"Covariance matrix is not symmetric.\")\n self.n = n\n self.chol = torch.", "reference": "self.chol=torch.linalg.cholesky(s,lower=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.chol=torch.linalg.cholesky(s,lower=True)", "y_neg": " self.chol = torch.cholesky(s)", "retain": " def __init__(self, s):\n n, m = s.shape\n if n != m:\n raise ValueError(\"Covariance matrix is not symmetric.\")\n self.n = n\n self.chol = torch.linalg.cholesky(s, lower=True)" }, { "id": 8380, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def backward(ctx, grad_output):\n batch_size, n_dim = grad_output.shape\n sign_z, = ctx.saved_tensors\n device = grad_output.device\n grad_output = grad_output\n sign_z = sign_z\n\n S = sign_z != 0\n S[:, -1] = True\n sign_z[:, -1] = 0\n\n S = S.cuda()\n s_active = torch.zeros(batch_size, n_dim, device=device, dtype=int)\n s_num_active = torch.zeros(batch_size, device=device, dtype=int)\n check_s_active(S, s_active, s_num_active)\n L_S_padded = torch.zeros(batch_size, n_dim, n_dim,\n device=device, dtype=grad_output.dtype)\n setup_l_s(L_S_padded, s_active, s_num_active)\n LTL_all = L_S_padded.transpose(-1, -2).matmul(L_S_padded)\n pad_ltl_diag(LTL_all, s_num_active)\n grad_u = (grad_output.unsqueeze(-2)\n ).matmul(L_S_padded).squeeze().unsqueeze(-1)\n\n # Cholesky Solve.\n u_all = torch.linalg.cholesky(LTL_all)\n tmp0 = torch.cholesky_solve(grad_u, u_all)\n if ctx.x_need_grad:\n grad_x = L_S_padded.matmul(tmp0).squeeze()\n else:\n grad_x = None\n sign_all = torch.zeros(\n batch_size, n_dim, device=device, dtype=grad_output.dtype)\n setup_sign_all(sign_all, sign_z, s_active, s_num_active)\n grad_lbda = (sign_all.unsqueeze(-2)).matmul(tmp0).squeeze(-1)\n return (grad_x, grad_lbda)", "probing input": " def backward(ctx, grad_output):\n batch_size, n_dim = grad_output.shape\n sign_z, = ctx.saved_tensors\n device = grad_output.device\n grad_output = grad_output\n sign_z = sign_z\n\n S = sign_z != 0\n S[:, -1] = True\n sign_z[:, -1] = 0\n\n S = S.cuda()\n s_active = torch.zeros(batch_size, n_dim, device=device, dtype=int)\n s_num_active = torch.zeros(batch_size, device=device, dtype=int)\n check_s_active(S, s_active, s_num_active)\n L_S_padded = torch.zeros(batch_size, n_dim, n_dim,\n device=device, dtype=grad_output.dtype)\n setup_l_s(L_S_padded, s_active, s_num_active)\n LTL_all = L_S_padded.transpose(-1, -2).matmul(L_S_padded)\n pad_ltl_diag(LTL_all, s_num_active)\n grad_u = (grad_output.unsqueeze(-2)\n ).matmul(L_S_padded).squeeze().unsqueeze(-1)\n\n # Cholesky Solve.\n", "probing input new": " def backward(ctx, grad_output):\n batch_size, n_dim = grad_output.shape\n sign_z, = ctx.saved_tensors\n device = grad_output.device\n grad_output = grad_output\n sign_z = sign_z\n\n S = sign_z != 0\n S[:, -1] = True\n sign_z[:, -1] = 0\n\n S = S.cuda()\n s_active = torch.zeros(batch_size, n_dim, device=device, dtype=int)\n s_num_active = torch.zeros(batch_size, device=device, dtype=int)\n check_s_active(S, s_active, s_num_active)\n L_S_padded = torch.zeros(batch_size, n_dim, n_dim,\n device=device, dtype=grad_output.dtype)\n setup_l_s(L_S_padded, s_active, s_num_active)\n LTL_all = L_S_padded.transpose(-1, -2).matmul(L_S_padded)\n pad_ltl_diag(LTL_all, s_num_active)\n grad_u = (grad_output.unsqueeze(-2)\n ).matmul(L_S_padded).squeeze().unsqueeze(-1)\n\n # Cholesky Solve.\n u_all = torch.", "reference": "u_all=torch.linalg.cholesky(LTL_all)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "u_all=torch.linalg.cholesky(LTL_all)", "y_neg": " u_all = torch.cholesky(LTL_all)", "retain": " def backward(ctx, grad_output):\n batch_size, n_dim = grad_output.shape\n sign_z, = ctx.saved_tensors\n device = grad_output.device\n grad_output = grad_output\n sign_z = sign_z\n\n S = sign_z != 0\n S[:, -1] = True\n sign_z[:, -1] = 0\n\n S = S.cuda()\n s_active = torch.zeros(batch_size, n_dim, device=device, dtype=int)\n s_num_active = torch.zeros(batch_size, device=device, dtype=int)\n check_s_active(S, s_active, s_num_active)\n L_S_padded = torch.zeros(batch_size, n_dim, n_dim,\n device=device, dtype=grad_output.dtype)\n setup_l_s(L_S_padded, s_active, s_num_active)\n LTL_all = L_S_padded.transpose(-1, -2).matmul(L_S_padded)\n pad_ltl_diag(LTL_all, s_num_active)\n grad_u = (grad_output.unsqueeze(-2)\n ).matmul(L_S_padded).squeeze().unsqueeze(-1)\n\n # Cholesky Solve.\n u_all = torch.linalg.cholesky(LTL_all)\n tmp0 = torch.cholesky_solve(grad_u, u_all)\n if ctx.x_need_grad:\n grad_x = L_S_padded.matmul(tmp0).squeeze()\n else:\n grad_x = None\n sign_all = torch.zeros(\n batch_size, n_dim, device=device, dtype=grad_output.dtype)\n setup_sign_all(sign_all, sign_z, s_active, s_num_active)\n grad_lbda = (sign_all.unsqueeze(-2)).matmul(tmp0).squeeze(-1)\n return (grad_x, grad_lbda)" }, { "id": 8381, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n # chol = torch.cholesky(matrix)\n chol = torch.linalg.cholesky(matrix, upper=False)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)", "probing input": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n # chol = torch.cholesky(matrix)\n", "probing input new": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n # chol = torch.cholesky(matrix)\n chol = torch.", "reference": "chol=torch.linalg.cholesky(matrix,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(matrix,upper=False)", "y_neg": " chol = torch.cholesky(matrix)", "retain": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n # chol = torch.cholesky(matrix)\n chol = torch.linalg.cholesky(matrix, upper=False)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)" }, { "id": 8382, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args: \tmatrix, 4-D tensor, [N, C, M, M].\n matrix must be a symmetric positive define matrix.\n \"\"\"\n # chol_low = torch.cholesky(matrix, upper=False)\n chol_low = torch.linalg.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)", "probing input": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args: \tmatrix, 4-D tensor, [N, C, M, M].\n matrix must be a symmetric positive define matrix.\n \"\"\"\n # chol_low = torch.cholesky(matrix, upper=False)\n", "probing input new": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args: \tmatrix, 4-D tensor, [N, C, M, M].\n matrix must be a symmetric positive define matrix.\n \"\"\"\n # chol_low = torch.cholesky(matrix, upper=False)\n chol_low = torch.", "reference": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "y_neg": " chol_low = torch.cholesky(matrix)", "retain": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args: \tmatrix, 4-D tensor, [N, C, M, M].\n matrix must be a symmetric positive define matrix.\n \"\"\"\n # chol_low = torch.cholesky(matrix, upper=False)\n chol_low = torch.linalg.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)" }, { "id": 8383, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, inp):\n if self.training:\n with th.no_grad():\n # Ensure input to Cholesky is PD\n cholesky_inp = inp.T @ inp + self.small_number * th.eye(inp.size(1)).type_as(inp)\n ort = th.linalg.cholesky(cholesky_inp)\n ort = th.linalg.inv(ort)\n self.update_ort_weights(ort)\n else:\n ort = self.ort_weights\n\n out = inp @ ort.T\n return out", "probing input": " def forward(self, inp):\n if self.training:\n with th.no_grad():\n # Ensure input to Cholesky is PD\n cholesky_inp = inp.T @ inp + self.small_number * th.eye(inp.size(1)).type_as(inp)\n", "probing input new": " def forward(self, inp):\n if self.training:\n with th.no_grad():\n # Ensure input to Cholesky is PD\n cholesky_inp = inp.T @ inp + self.small_number * th.eye(inp.size(1)).type_as(inp)\n ort = th.", "reference": "ort=th.linalg.cholesky(cholesky_inp)", "reference dict": {}, "alias dict": { "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "th.linalg.cholesky", "y_pos": "ort=th.linalg.cholesky(cholesky_inp)", "y_neg": " ort = th.cholesky(cholesky_inp)", "retain": " def forward(self, inp):\n if self.training:\n with th.no_grad():\n # Ensure input to Cholesky is PD\n cholesky_inp = inp.T @ inp + self.small_number * th.eye(inp.size(1)).type_as(inp)\n ort = th.linalg.cholesky(cholesky_inp)\n ort = th.linalg.inv(ort)\n self.update_ort_weights(ort)\n else:\n ort = self.ort_weights\n\n out = inp @ ort.T\n return out" }, { "id": 8384, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def cholesky_factor(self, matrix, jitter_level):\n \"\"\"\n Compute lower Cholesky factor of given matrix, adding jitter for stability (prevent non-PD error).\n\n :param matrix: torch.Tensor, matrix subject to Cholesky decomposition\n :param jitter_level: float, jitter added for numerical stability\n :return: torch.Tensor, lower Cholesky factor of input matrix\n \"\"\"\n jitter = torch.eye(matrix.shape[0], dtype=matrix.dtype, device=matrix.device) * jitter_level\n multiplier = 1.\n while True:\n try:\n L = torch.linalg.cholesky(matrix + multiplier * jitter) # try to compute lower Cholesky factor\n break\n except RuntimeError:\n multiplier *= 2.\n if float(multiplier) == float(\"inf\"):\n raise RuntimeError(\"increase to inf jitter\")\n return L", "probing input": " def cholesky_factor(self, matrix, jitter_level):\n \"\"\"\n Compute lower Cholesky factor of given matrix, adding jitter for stability (prevent non-PD error).\n\n :param matrix: torch.Tensor, matrix subject to Cholesky decomposition\n :param jitter_level: float, jitter added for numerical stability\n :return: torch.Tensor, lower Cholesky factor of input matrix\n \"\"\"\n jitter = torch.eye(matrix.shape[0], dtype=matrix.dtype, device=matrix.device) * jitter_level\n multiplier = 1.\n while True:\n try:\n", "probing input new": " def cholesky_factor(self, matrix, jitter_level):\n \"\"\"\n Compute lower Cholesky factor of given matrix, adding jitter for stability (prevent non-PD error).\n\n :param matrix: torch.Tensor, matrix subject to Cholesky decomposition\n :param jitter_level: float, jitter added for numerical stability\n :return: torch.Tensor, lower Cholesky factor of input matrix\n \"\"\"\n jitter = torch.eye(matrix.shape[0], dtype=matrix.dtype, device=matrix.device) * jitter_level\n multiplier = 1.\n while True:\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(matrix+multiplier*jitter)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(matrix+multiplier*jitter)", "y_neg": " L = torch.cholesky(matrix + jitter)", "retain": " def cholesky_factor(self, matrix, jitter_level):\n \"\"\"\n Compute lower Cholesky factor of given matrix, adding jitter for stability (prevent non-PD error).\n\n :param matrix: torch.Tensor, matrix subject to Cholesky decomposition\n :param jitter_level: float, jitter added for numerical stability\n :return: torch.Tensor, lower Cholesky factor of input matrix\n \"\"\"\n jitter = torch.eye(matrix.shape[0], dtype=matrix.dtype, device=matrix.device) * jitter_level\n multiplier = 1.\n while True:\n try:\n L = torch.linalg.cholesky(matrix + multiplier * jitter) # try to compute lower Cholesky factor\n break\n except RuntimeError:\n multiplier *= 2.\n if float(multiplier) == float(\"inf\"):\n raise RuntimeError(\"increase to inf jitter\")\n return L" }, { "id": 8385, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss of the module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor): Target tensor.\n x_var (float, optional): Variance of the input tensor. Defaults to 0.\n y_var (float, optional): Variance of the target tensor. Defaults to 0.\n update_data (bool, optional): Whether to update the training data. Defaults to False.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n _noise = self.noise_box.get()\n\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n m_device = list(self.parameters())[0].device\n sigma = self.kernel(x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=m_device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=m_device)\n\n L = torch.linalg.cholesky(sigma)\n y_num, y_dimension = y.shape\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll", "probing input": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss of the module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor): Target tensor.\n x_var (float, optional): Variance of the input tensor. Defaults to 0.\n y_var (float, optional): Variance of the target tensor. Defaults to 0.\n update_data (bool, optional): Whether to update the training data. Defaults to False.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n _noise = self.noise_box.get()\n\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n m_device = list(self.parameters())[0].device\n sigma = self.kernel(x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=m_device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=m_device)\n\n", "probing input new": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss of the module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor): Target tensor.\n x_var (float, optional): Variance of the input tensor. Defaults to 0.\n y_var (float, optional): Variance of the target tensor. Defaults to 0.\n update_data (bool, optional): Whether to update the training data. Defaults to False.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n _noise = self.noise_box.get()\n\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n m_device = list(self.parameters())[0].device\n sigma = self.kernel(x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=m_device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=m_device)\n\n L = torch.", "reference": "L=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(sigma)", "y_neg": " L = torch.cholesky(sigma)", "retain": " def compute_loss(self, x, y, x_var=0., y_var=0., update_data=False):\n \"\"\"\n Compute the loss of the module.\n\n Args:\n x (torch.Tensor or list): Input tensor or list of tensors.\n y (torch.Tensor): Target tensor.\n x_var (float, optional): Variance of the input tensor. Defaults to 0.\n y_var (float, optional): Variance of the target tensor. Defaults to 0.\n update_data (bool, optional): Whether to update the training data. Defaults to False.\n\n Returns:\n torch.Tensor: Loss value.\n \"\"\"\n x = self.check_single_tensor(x)\n y = self.check_single_tensor(y)\n assert y.ndim == 2, \"y should be 2d tensor\"\n\n # TODO checking if inputs/outputs was changed\n if self.train_x is None:\n self.train_x = x\n self.train_y = y\n elif update_data:\n self.train_x = x\n self.train_y = y\n\n _noise = self.noise_box.get()\n\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n m_device = list(self.parameters())[0].device\n sigma = self.kernel(x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=m_device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=m_device)\n\n L = torch.linalg.cholesky(sigma)\n y_num, y_dimension = y.shape\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll" }, { "id": 8386, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.linalg.cholesky(A, upper=False)\n X = torch.cholesky_solve(B, A_decomp, upper=False) # bxmxn\n except RuntimeError: # Revert to loop if batchwise solve fails\n X = torch.zeros_like(B)\n for i in range(A.size(0)):\n try: # Cholesky solve\n A_decomp = torch.linalg.cholesky(A[i, ...], upper=False)\n X[i, ...] = torch.cholesky_solve(B[i, ...], A_decomp, upper=False) # mxn\n except RuntimeError: # Revert to LU solve\n X[i, ...] = torch.linalg.solve(A[i, ...], B[i, ...])[0] # mxn\n if B_sizes is not None:\n X = X.split(B_sizes, dim=-1)\n return X", "probing input": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n", "probing input new": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.", "reference": "A_decomp=torch.linalg.cholesky(A,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "A_decomp=torch.linalg.cholesky(A,upper=False)", "y_neg": " A_decomp = torch.cholesky(A)", "retain": " def _solve_linear_system(self, A, B):\n \"\"\"Solves linear system AX = B.\n If B is a tuple (B1, B2, ...), returns tuple (X1, X2, ...).\n Otherwise returns X.\n \"\"\"\n B_sizes = None\n # If B is a tuple, concatenate into single tensor:\n if isinstance(B, (tuple, list)):\n B_sizes = list(map(lambda x: x.size(-1), B))\n B = torch.cat(B, dim=-1)\n # Ensure B is 2D (bxmxn):\n if len(B.size()) == 2:\n B = B.unsqueeze(-1)\n try: # Batchwise Cholesky solve\n A_decomp = torch.linalg.cholesky(A, upper=False)\n X = torch.cholesky_solve(B, A_decomp, upper=False) # bxmxn\n except RuntimeError: # Revert to loop if batchwise solve fails\n X = torch.zeros_like(B)\n for i in range(A.size(0)):\n try: # Cholesky solve\n A_decomp = torch.linalg.cholesky(A[i, ...], upper=False)\n X[i, ...] = torch.cholesky_solve(B[i, ...], A_decomp, upper=False) # mxn\n except RuntimeError: # Revert to LU solve\n X[i, ...] = torch.linalg.solve(A[i, ...], B[i, ...])[0] # mxn\n if B_sizes is not None:\n X = X.split(B_sizes, dim=-1)\n return X" }, { "id": 8388, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self) -> torch.Tensor:\n \"\"\"Return a value proportional to the log likelihood.\"\"\"\n # model-implied covariance/mean\n sigma, mu = self.implied_sigma_mu()\n\n if self.fiml:\n # FIML -2 * logL (without constants)\n assert mu is not None\n loss = torch.zeros(1, dtype=mu.dtype, device=mu.device)\n mean_diffs: torch.Tensor = self.data - mu.t()\n for pairs in self.missing_patterns.values():\n # calculate sigma^-1 and logdet(sigma) in batches\n sigmas = torch.stack(\n [sigma.index_select(0, x[1]).index_select(1, x[1]) for x in pairs],\n )\n L_sigmas = torch.linalg.cholesky(sigmas)\n sigmas_logdet = L_sigmas.diagonal(dim1=1, dim2=2).log().sum(dim=1) * 2\n\n for i, (observations, available) in enumerate(pairs):\n mean_diff = mean_diffs.index_select(0, observations).index_select(\n 1, available,\n )\n loss_current = sigmas_logdet[i] * len(observations) + torch.trace(\n mean_diff.mm(torch.cholesky_solve(mean_diff.t(), L_sigmas[i])),\n )\n loss = loss + loss_current.clamp(min=0.0)\n\n else:\n # maximum likelihood\n L_sigma = torch.linalg.cholesky(sigma)\n loss = L_sigma.diagonal().log().sum() * 2 + torch.trace(\n torch.cholesky_solve(self.sample_covariance, L_sigma),\n )\n\n return loss", "probing input": " def forward(self) -> torch.Tensor:\n \"\"\"Return a value proportional to the log likelihood.\"\"\"\n # model-implied covariance/mean\n sigma, mu = self.implied_sigma_mu()\n\n if self.fiml:\n # FIML -2 * logL (without constants)\n assert mu is not None\n loss = torch.zeros(1, dtype=mu.dtype, device=mu.device)\n mean_diffs: torch.Tensor = self.data - mu.t()\n for pairs in self.missing_patterns.values():\n # calculate sigma^-1 and logdet(sigma) in batches\n sigmas = torch.stack(\n [sigma.index_select(0, x[1]).index_select(1, x[1]) for x in pairs],\n )\n L_sigmas = torch.linalg.cholesky(sigmas)\n sigmas_logdet = L_sigmas.diagonal(dim1=1, dim2=2).log().sum(dim=1) * 2\n\n for i, (observations, available) in enumerate(pairs):\n mean_diff = mean_diffs.index_select(0, observations).index_select(\n 1, available,\n )\n loss_current = sigmas_logdet[i] * len(observations) + torch.trace(\n mean_diff.mm(torch.cholesky_solve(mean_diff.t(), L_sigmas[i])),\n )\n loss = loss + loss_current.clamp(min=0.0)\n\n else:\n # maximum likelihood\n", "probing input new": " def forward(self) -> torch.Tensor:\n \"\"\"Return a value proportional to the log likelihood.\"\"\"\n # model-implied covariance/mean\n sigma, mu = self.implied_sigma_mu()\n\n if self.fiml:\n # FIML -2 * logL (without constants)\n assert mu is not None\n loss = torch.zeros(1, dtype=mu.dtype, device=mu.device)\n mean_diffs: torch.Tensor = self.data - mu.t()\n for pairs in self.missing_patterns.values():\n # calculate sigma^-1 and logdet(sigma) in batches\n sigmas = torch.stack(\n [sigma.index_select(0, x[1]).index_select(1, x[1]) for x in pairs],\n )\n L_sigmas = torch.linalg.cholesky(sigmas)\n sigmas_logdet = L_sigmas.diagonal(dim1=1, dim2=2).log().sum(dim=1) * 2\n\n for i, (observations, available) in enumerate(pairs):\n mean_diff = mean_diffs.index_select(0, observations).index_select(\n 1, available,\n )\n loss_current = sigmas_logdet[i] * len(observations) + torch.trace(\n mean_diff.mm(torch.cholesky_solve(mean_diff.t(), L_sigmas[i])),\n )\n loss = loss + loss_current.clamp(min=0.0)\n\n else:\n # maximum likelihood\n L_sigma = torch.", "reference": "L_sigma=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L_sigma=torch.linalg.cholesky(sigma)", "y_neg": " L_sigma = torch.cholesky(sigma)", "retain": " def forward(self) -> torch.Tensor:\n \"\"\"Return a value proportional to the log likelihood.\"\"\"\n # model-implied covariance/mean\n sigma, mu = self.implied_sigma_mu()\n\n if self.fiml:\n # FIML -2 * logL (without constants)\n assert mu is not None\n loss = torch.zeros(1, dtype=mu.dtype, device=mu.device)\n mean_diffs: torch.Tensor = self.data - mu.t()\n for pairs in self.missing_patterns.values():\n # calculate sigma^-1 and logdet(sigma) in batches\n sigmas = torch.stack(\n [sigma.index_select(0, x[1]).index_select(1, x[1]) for x in pairs],\n )\n L_sigmas = torch.linalg.cholesky(sigmas)\n sigmas_logdet = L_sigmas.diagonal(dim1=1, dim2=2).log().sum(dim=1) * 2\n\n for i, (observations, available) in enumerate(pairs):\n mean_diff = mean_diffs.index_select(0, observations).index_select(\n 1, available,\n )\n loss_current = sigmas_logdet[i] * len(observations) + torch.trace(\n mean_diff.mm(torch.cholesky_solve(mean_diff.t(), L_sigmas[i])),\n )\n loss = loss + loss_current.clamp(min=0.0)\n\n else:\n # maximum likelihood\n L_sigma = torch.linalg.cholesky(sigma)\n loss = L_sigma.diagonal().log().sum() * 2 + torch.trace(\n torch.cholesky_solve(self.sample_covariance, L_sigma),\n )\n\n return loss" }, { "id": 8389, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_ill_conditioned_matrix():\n \"\"\"Test with an ill-conditioned matrix.\"\"\"\n # Create an ill-conditioned matrix\n ill_cond_matrix = t.rand((10, 10))\n ill_cond_matrix = ill_cond_matrix @ ill_cond_matrix.T # Make it symmetric\n ill_cond_matrix[0, 0] = 1e-8 # Introduce ill-conditioning\n\n # Verify that the matrix really is ill-conditioned\n with pytest.raises(LinAlgError):\n L = t.linalg.cholesky(ill_cond_matrix)\n\n # Test if stable Cholesky decomposition succeeds\n L = stable_cholesky(ill_cond_matrix)\n assert isinstance(L, t.Tensor)\n assert not t.isnan(L).any()", "probing input": "def test_ill_conditioned_matrix():\n \"\"\"Test with an ill-conditioned matrix.\"\"\"\n # Create an ill-conditioned matrix\n ill_cond_matrix = t.rand((10, 10))\n ill_cond_matrix = ill_cond_matrix @ ill_cond_matrix.T # Make it symmetric\n ill_cond_matrix[0, 0] = 1e-8 # Introduce ill-conditioning\n\n # Verify that the matrix really is ill-conditioned\n with pytest.raises(LinAlgError):\n", "probing input new": "def test_ill_conditioned_matrix():\n \"\"\"Test with an ill-conditioned matrix.\"\"\"\n # Create an ill-conditioned matrix\n ill_cond_matrix = t.rand((10, 10))\n ill_cond_matrix = ill_cond_matrix @ ill_cond_matrix.T # Make it symmetric\n ill_cond_matrix[0, 0] = 1e-8 # Introduce ill-conditioning\n\n # Verify that the matrix really is ill-conditioned\n with pytest.raises(LinAlgError):\n L = t.", "reference": "L=t.linalg.cholesky(ill_cond_matrix)", "reference dict": {}, "alias dict": { "t.potri": "torch.potri", "t.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "t.potrs": "torch.potrs", "t.qr": "torch.qr", "t.lu_solve": "torch.lu_solve", "t.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "t.symeig": "torch.symeig", "t.func.functional_call": "torch.func.functional_call", "t.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "t.solve": "torch.solve", "t.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "t.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "t.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "t.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "t.lu_unpack": "torch.lu_unpack", "t.btrisolve": "torch.btrisolve", "t.linalg.lu_factor": "torch.linalg.lu_factor", "t.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "t.linalg.matrix_rank": "torch.linalg.matrix_rank", "t.norm": "torch.norm", "t.cholesky_solve": "torch.cholesky_solve", "t.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "t.testing.assert_allclose": "torch.testing.assert_allclose", "t.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "t.gels": "torch.gels", "t.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "t.chain_matmul": "torch.chain_matmul", "t.lu": "torch.lu", "t.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "t.pstrf": "torch.pstrf", "t.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "t.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "t.linalg.eigh": "torch.linalg.eigh", "t.btrifact": "torch.btrifact", "t.linalg.lu_solve": "torch.linalg.lu_solve", "t.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "t.linalg.multi_dot": "torch.linalg.multi_dot", "t.gesv": "torch.gesv", "t.btrifact_with_info": "torch.btrifact_with_info", "t.linalg.solve": "torch.linalg.solve", "t.linalg.eig": "torch.linalg.eig", "t.linalg.cholesky": "torch.linalg.cholesky", "t.trtrs": "torch.trtrs", "t.linalg.solve_triangular": "torch.linalg.solve_triangular", "t.matrix_rank": "torch.matrix_rank", "t.triangular_solve": "torch.triangular_solve", "t.linalg.qr": "torch.linalg.qr", "t.svd": "torch.svd", "t.lstsq": "torch.lstsq", "t.nn.functional.interpolate": "torch.nn.functional.interpolate", "t.potrf": "torch.potrf", "t.linalg.svd": "torch.linalg.svd", "t.btriunpack": "torch.btriunpack", "t.eig": "torch.eig", "t.cholesky_inverse": "torch.cholesky_inverse", "t.testing.assert_close": "torch.testing.assert_close", "t.cholesky": "torch.cholesky", "t.nn.functional.upsample": "torch.nn.functional.upsample", "t.linalg.norm": "torch.linalg.norm", "t.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "t.linalg.cholesky", "y_pos": "L=t.linalg.cholesky(ill_cond_matrix)", "y_neg": " L = t.cholesky(ill_cond_matrix)", "retain": "def test_ill_conditioned_matrix():\n \"\"\"Test with an ill-conditioned matrix.\"\"\"\n # Create an ill-conditioned matrix\n ill_cond_matrix = t.rand((10, 10))\n ill_cond_matrix = ill_cond_matrix @ ill_cond_matrix.T # Make it symmetric\n ill_cond_matrix[0, 0] = 1e-8 # Introduce ill-conditioning\n\n # Verify that the matrix really is ill-conditioned\n with pytest.raises(LinAlgError):\n L = t.linalg.cholesky(ill_cond_matrix)\n\n # Test if stable Cholesky decomposition succeeds\n L = stable_cholesky(ill_cond_matrix)\n assert isinstance(L, t.Tensor)\n assert not t.isnan(L).any()" }, { "id": 8390, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def test_multivariate_standardize_tfm():\n d = 5\n tril_ind = torch.tril_indices(d, d)\n Q = torch.zeros(d, d)\n Q[tril_ind[0], tril_ind[1]] = torch.randn(d * (d + 1) // 2)\n Sigma = Q @ Q.t() + torch.eye(d) * 1e-3\n L = torch.linalg.cholesky(Sigma)\n x = torch.randn(1000, d) @ L.t() + torch.arange(d)\n tfm = MultivariateStandardizeTransform(x)\n y = tfm(x)\n with torch.no_grad():\n npt.assert_array_almost_equal(y.mean(0), torch.zeros(d))\n npt.assert_array_almost_equal(sample_covariance(y), torch.eye(d))\n npt.assert_array_almost_equal(tfm.inverse(y), x)", "probing input": "def test_multivariate_standardize_tfm():\n d = 5\n tril_ind = torch.tril_indices(d, d)\n Q = torch.zeros(d, d)\n Q[tril_ind[0], tril_ind[1]] = torch.randn(d * (d + 1) // 2)\n Sigma = Q @ Q.t() + torch.eye(d) * 1e-3\n", "probing input new": "def test_multivariate_standardize_tfm():\n d = 5\n tril_ind = torch.tril_indices(d, d)\n Q = torch.zeros(d, d)\n Q[tril_ind[0], tril_ind[1]] = torch.randn(d * (d + 1) // 2)\n Sigma = Q @ Q.t() + torch.eye(d) * 1e-3\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": { "tfm": "MultivariateStandardizeTransform" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": "def test_multivariate_standardize_tfm():\n d = 5\n tril_ind = torch.tril_indices(d, d)\n Q = torch.zeros(d, d)\n Q[tril_ind[0], tril_ind[1]] = torch.randn(d * (d + 1) // 2)\n Sigma = Q @ Q.t() + torch.eye(d) * 1e-3\n L = torch.linalg.cholesky(Sigma)\n x = torch.randn(1000, d) @ L.t() + torch.arange(d)\n tfm = MultivariateStandardizeTransform(x)\n y = tfm(x)\n with torch.no_grad():\n npt.assert_array_almost_equal(y.mean(0), torch.zeros(d))\n npt.assert_array_almost_equal(sample_covariance(y), torch.eye(d))\n npt.assert_array_almost_equal(tfm.inverse(y), x)" }, { "id": 8392, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.transpose(-1, -2) / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)", "probing input": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.transpose(-1, -2) / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n", "probing input new": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.transpose(-1, -2) / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.", "reference": "returntorch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(K)", "y_neg": " return torch.cholesky(K)", "retain": "def _batch_capacitance_tril(W, D):\n r\"\"\"\n Computes Cholesky of :math:`I + W.T @ inv(D) @ W` for a batch of matrices :math:`W`\n and a batch of vectors :math:`D`.\n \"\"\"\n m = W.size(-1)\n Wt_Dinv = W.transpose(-1, -2) / D.unsqueeze(-2)\n K = torch.matmul(Wt_Dinv, W).contiguous()\n K.view(-1, m * m)[:, ::m + 1] += 1 # add identity matrix to K\n return torch.linalg.cholesky(K)" }, { "id": 8393, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.transpose(-1, -2)).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(self._batch_shape + self._event_shape + self._event_shape)", "probing input": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.transpose(-1, -2)).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n", "probing input new": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.transpose(-1, -2)).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.", "reference": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=cov_diag_sqrt_unsqueeze*torch.linalg.cholesky(K)", "y_neg": " scale_tril = cov_diag_sqrt_unsqueeze * torch.cholesky(K)", "retain": " def scale_tril(self):\n # The following identity is used to increase the numerically computation stability\n # for Cholesky decomposition (see http://www.gaussianprocess.org/gpml/, Section 3.4.3):\n # W @ W.T + D = D1/2 @ (I + D-1/2 @ W @ W.T @ D-1/2) @ D1/2\n # The matrix \"I + D-1/2 @ W @ W.T @ D-1/2\" has eigenvalues bounded from below by 1,\n # hence it is well-conditioned and safe to take Cholesky decomposition.\n n = self._event_shape[0]\n cov_diag_sqrt_unsqueeze = self._unbroadcasted_cov_diag.sqrt().unsqueeze(-1)\n Dinvsqrt_W = self._unbroadcasted_cov_factor / cov_diag_sqrt_unsqueeze\n K = torch.matmul(Dinvsqrt_W, Dinvsqrt_W.transpose(-1, -2)).contiguous()\n K.view(-1, n * n)[:, ::n + 1] += 1 # add identity matrix to K\n scale_tril = cov_diag_sqrt_unsqueeze * torch.linalg.cholesky(K)\n return scale_tril.expand(self._batch_shape + self._event_shape + self._event_shape)" }, { "id": 8394, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def full_mixture_posterior_predictive(model, test_x, trace_hyper):\n \n ''' Returns the mixture posterior predictive multivariate normal '''\n \n # Make predictions by feeding model through likelihood\n \n list_of_y_pred_dists = []\n \n for i in range(len(trace_hyper)):\n \n hyper_sample = trace_hyper[i]\n \n ## Training mode for overwriting hypers \n model.train()\n model.likelihood.train()\n \n if hyper_sample['sig_n']**2 < 1e-4:\n hyper_sample['sig_n'] = 0.01\n \n model.likelihood.noise_covar.noise = hyper_sample['sig_n']**2\n model.base_covar_module.outputscale = hyper_sample['sig_f']**2\n model.base_covar_module.base_kernel.lengthscale = hyper_sample['ls']\n model.covar_module.inducing_points = torch.nn.Parameter(torch.Tensor(hyper_sample['Z']).double())\n \n with torch.no_grad():\n \n ## Testing mode for computing the posterior predictive \n model.eval()\n model.likelihood.eval()\n pred = model.likelihood(model(test_x))\n \n try:\n chol = torch.linalg.cholesky(pred.covariance_matrix + torch.eye(len(test_x))*1e-5)\n list_of_y_pred_dists.append(pred)\n except RuntimeError:\n print('Not psd for sample ' + str(i))\n \n return list_of_y_pred_dists", "probing input": "def full_mixture_posterior_predictive(model, test_x, trace_hyper):\n \n ''' Returns the mixture posterior predictive multivariate normal '''\n \n # Make predictions by feeding model through likelihood\n \n list_of_y_pred_dists = []\n \n for i in range(len(trace_hyper)):\n \n hyper_sample = trace_hyper[i]\n \n ## Training mode for overwriting hypers \n model.train()\n model.likelihood.train()\n \n if hyper_sample['sig_n']**2 < 1e-4:\n hyper_sample['sig_n'] = 0.01\n \n model.likelihood.noise_covar.noise = hyper_sample['sig_n']**2\n model.base_covar_module.outputscale = hyper_sample['sig_f']**2\n model.base_covar_module.base_kernel.lengthscale = hyper_sample['ls']\n model.covar_module.inducing_points = torch.nn.Parameter(torch.Tensor(hyper_sample['Z']).double())\n \n with torch.no_grad():\n \n ## Testing mode for computing the posterior predictive \n model.eval()\n model.likelihood.eval()\n pred = model.likelihood(model(test_x))\n \n try:\n", "probing input new": "def full_mixture_posterior_predictive(model, test_x, trace_hyper):\n \n ''' Returns the mixture posterior predictive multivariate normal '''\n \n # Make predictions by feeding model through likelihood\n \n list_of_y_pred_dists = []\n \n for i in range(len(trace_hyper)):\n \n hyper_sample = trace_hyper[i]\n \n ## Training mode for overwriting hypers \n model.train()\n model.likelihood.train()\n \n if hyper_sample['sig_n']**2 < 1e-4:\n hyper_sample['sig_n'] = 0.01\n \n model.likelihood.noise_covar.noise = hyper_sample['sig_n']**2\n model.base_covar_module.outputscale = hyper_sample['sig_f']**2\n model.base_covar_module.base_kernel.lengthscale = hyper_sample['ls']\n model.covar_module.inducing_points = torch.nn.Parameter(torch.Tensor(hyper_sample['Z']).double())\n \n with torch.no_grad():\n \n ## Testing mode for computing the posterior predictive \n model.eval()\n model.likelihood.eval()\n pred = model.likelihood(model(test_x))\n \n try:\n chol = torch.", "reference": "chol=torch.linalg.cholesky(pred.covariance_matrix+torch.eye(len(test_x))*1e-5)", "reference dict": { "model.covar_module.inducing_points": "torch.nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(pred.covariance_matrix+torch.eye(len(test_x))*1e-5)", "y_neg": " chol = torch.cholesky(model.covar_module.base_kernel.lengthscale_matrix)", "retain": "def full_mixture_posterior_predictive(model, test_x, trace_hyper):\n \n ''' Returns the mixture posterior predictive multivariate normal '''\n \n # Make predictions by feeding model through likelihood\n \n list_of_y_pred_dists = []\n \n for i in range(len(trace_hyper)):\n \n hyper_sample = trace_hyper[i]\n \n ## Training mode for overwriting hypers \n model.train()\n model.likelihood.train()\n \n if hyper_sample['sig_n']**2 < 1e-4:\n hyper_sample['sig_n'] = 0.01\n \n model.likelihood.noise_covar.noise = hyper_sample['sig_n']**2\n model.base_covar_module.outputscale = hyper_sample['sig_f']**2\n model.base_covar_module.base_kernel.lengthscale = hyper_sample['ls']\n model.covar_module.inducing_points = torch.nn.Parameter(torch.Tensor(hyper_sample['Z']).double())\n \n with torch.no_grad():\n \n ## Testing mode for computing the posterior predictive \n model.eval()\n model.likelihood.eval()\n pred = model.likelihood(model(test_x))\n \n try:\n chol = torch.linalg.cholesky(pred.covariance_matrix + torch.eye(len(test_x))*1e-5)\n list_of_y_pred_dists.append(pred)\n except RuntimeError:\n print('Not psd for sample ' + str(i))\n \n return list_of_y_pred_dists" }, { "id": 8395, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n L = torch.linalg.cholesky(A, upper=upper, out=out)\n return L\n except RuntimeError as e:\n isnan = torch.isnan(A)\n if isnan.any():\n raise NanError(\n f\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n )\n\n if jitter is None:\n jitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n Aprime = A.clone()\n jitter_prev = 0\n for i in range(10):\n jitter_new = jitter * (10 ** i)\n Aprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n jitter_prev = jitter_new\n try:\n L = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return L\n except RuntimeError:\n continue\n # return torch.randn_like(A).tril()\n raise e", "probing input": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n", "probing input new": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A,upper=upper,out=out)", "y_neg": " L = torch.cholesky(A, upper=upper, out=out)", "retain": "def psd_safe_cholesky(A, upper=False, out=None, jitter=None):\n \"\"\"Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.\n Args:\n :attr:`A` (Tensor):\n The tensor to compute the Cholesky decomposition of\n :attr:`upper` (bool, optional):\n See torch.cholesky\n :attr:`out` (Tensor, optional):\n See torch.cholesky\n :attr:`jitter` (float, optional):\n The jitter to add to the diagonal of A in case A is only p.s.d. If omitted, chosen\n as 1e-6 (float) or 1e-8 (double)\n \"\"\"\n try:\n L = torch.linalg.cholesky(A, upper=upper, out=out)\n return L\n except RuntimeError as e:\n isnan = torch.isnan(A)\n if isnan.any():\n raise NanError(\n f\"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN.\"\n )\n\n if jitter is None:\n jitter = 1e-6 if A.dtype == torch.float32 else 1e-8\n Aprime = A.clone()\n jitter_prev = 0\n for i in range(10):\n jitter_new = jitter * (10 ** i)\n Aprime.diagonal(dim1=-2, dim2=-1).add_(jitter_new - jitter_prev)\n jitter_prev = jitter_new\n try:\n L = torch.linalg.cholesky(Aprime, upper=upper, out=out)\n warnings.warn(\n f\"A not p.d., added jitter of {jitter_new} to the diagonal\",\n RuntimeWarning,\n )\n return L\n except RuntimeError:\n continue\n # return torch.randn_like(A).tril()\n raise e" }, { "id": 8396, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n zero_loc = self.X.new_zeros(self.X.size(0))\n f_loc = zero_loc + self.mean_function(self.X)\n if self.y is None:\n f_var = Lff.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.MultivariateNormal(f_loc, scale_tril=Lff)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )", "probing input": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n", "probing input new": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X)\n Kff.view(-1)[:: N + 1] += self.jitter + self.noise # add noise to diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n zero_loc = self.X.new_zeros(self.X.size(0))\n f_loc = zero_loc + self.mean_function(self.X)\n if self.y is None:\n f_var = Lff.pow(2).sum(dim=-1)\n return f_loc, f_var\n else:\n return pyro.sample(\n self._pyro_get_fullname(\"y\"),\n dist.MultivariateNormal(f_loc, scale_tril=Lff)\n .expand_by(self.y.shape[:-1])\n .to_event(self.y.dim() - 1),\n obs=self.y,\n )" }, { "id": 8399, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky(mat):\n return torch.linalg.cholesky(mat)", "probing input": "def cholesky(mat):\n", "probing input new": "def cholesky(mat):\n return torch.", "reference": "returntorch.linalg.cholesky(mat)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(mat)", "y_neg": " return torch.cholesky(mat)", "retain": "def cholesky(mat):\n return torch.linalg.cholesky(mat)" }, { "id": 8401, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def random_mvn(batch_shape, dim, requires_grad=False):\n rank = dim + dim\n loc = torch.randn(batch_shape + (dim,), requires_grad=requires_grad)\n cov = torch.randn(batch_shape + (dim, rank))\n cov = cov.matmul(cov.transpose(-1, -2))\n scale_tril = torch.linalg.cholesky(cov)\n scale_tril.requires_grad_(requires_grad)\n return dist.MultivariateNormal(loc, scale_tril=scale_tril)", "probing input": "def random_mvn(batch_shape, dim, requires_grad=False):\n rank = dim + dim\n loc = torch.randn(batch_shape + (dim,), requires_grad=requires_grad)\n cov = torch.randn(batch_shape + (dim, rank))\n cov = cov.matmul(cov.transpose(-1, -2))\n", "probing input new": "def random_mvn(batch_shape, dim, requires_grad=False):\n rank = dim + dim\n loc = torch.randn(batch_shape + (dim,), requires_grad=requires_grad)\n cov = torch.randn(batch_shape + (dim, rank))\n cov = cov.matmul(cov.transpose(-1, -2))\n scale_tril = torch.", "reference": "scale_tril=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "scale_tril=torch.linalg.cholesky(cov)", "y_neg": " scale_tril = torch.cholesky(cov)", "retain": "def random_mvn(batch_shape, dim, requires_grad=False):\n rank = dim + dim\n loc = torch.randn(batch_shape + (dim,), requires_grad=requires_grad)\n cov = torch.randn(batch_shape + (dim, rank))\n cov = cov.matmul(cov.transpose(-1, -2))\n scale_tril = torch.linalg.cholesky(cov)\n scale_tril.requires_grad_(requires_grad)\n return dist.MultivariateNormal(loc, scale_tril=scale_tril)" }, { "id": 8405, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_covariance_matrix(self):\n for d in self.distributions:\n cov = d.covariance_matrix\n self.assertTrue(isinstance(cov, Tensor))\n\n # testing for symmetry\n self.assertAllClose(cov, cov.mT)\n\n # testing for positive-definiteness\n ispd = False\n try:\n torch.linalg.cholesky(cov)\n ispd = True\n except RuntimeError:\n pass\n self.assertTrue(ispd)\n\n # checking that linear operator to tensor conversion\n # leads to same covariance matrix\n xcov_linop = DenseLinearOperator(d.cross_covariance_matrix)\n usn_linop = UnifiedSkewNormal(\n trunc=d.trunc, gauss=d.gauss, cross_covariance_matrix=xcov_linop\n )\n cov_linop = usn_linop.covariance_matrix\n self.assertTrue(isinstance(cov_linop, Tensor))\n self.assertAllClose(cov, cov_linop)", "probing input": " def test_covariance_matrix(self):\n for d in self.distributions:\n cov = d.covariance_matrix\n self.assertTrue(isinstance(cov, Tensor))\n\n # testing for symmetry\n self.assertAllClose(cov, cov.mT)\n\n # testing for positive-definiteness\n ispd = False\n try:\n", "probing input new": " def test_covariance_matrix(self):\n for d in self.distributions:\n cov = d.covariance_matrix\n self.assertTrue(isinstance(cov, Tensor))\n\n # testing for symmetry\n self.assertAllClose(cov, cov.mT)\n\n # testing for positive-definiteness\n ispd = False\n try:\n torch.", "reference": "torch.linalg.cholesky(cov)", "reference dict": { "xcov_linop": "DenseLinearOperator", "usn_linop": "UnifiedSkewNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "torch.linalg.cholesky(cov)", "y_neg": " torch.cholesky(cov)", "retain": " def test_covariance_matrix(self):\n for d in self.distributions:\n cov = d.covariance_matrix\n self.assertTrue(isinstance(cov, Tensor))\n\n # testing for symmetry\n self.assertAllClose(cov, cov.mT)\n\n # testing for positive-definiteness\n ispd = False\n try:\n torch.linalg.cholesky(cov)\n ispd = True\n except RuntimeError:\n pass\n self.assertTrue(ispd)\n\n # checking that linear operator to tensor conversion\n # leads to same covariance matrix\n xcov_linop = DenseLinearOperator(d.cross_covariance_matrix)\n usn_linop = UnifiedSkewNormal(\n trunc=d.trunc, gauss=d.gauss, cross_covariance_matrix=xcov_linop\n )\n cov_linop = usn_linop.covariance_matrix\n self.assertTrue(isinstance(cov_linop, Tensor))\n self.assertAllClose(cov, cov_linop)" }, { "id": 8406, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky_eigh(A, B, reg_B=1e-6, n_eig=None):\n \"\"\"\n -- Generalized eigenvalue problem: A * v_i = lambda_i * B * v_i --\n\n First apply cholesky decomposition to B and then solve the generalized eigvalue problem.\n\n Notes\n -----\n The eigenvecs object which is returned is a matrix whose column eigvecs[:,i] is the eigenvector associated to eigvals[i]\n \"\"\"\n\n # check that both matrices are symmetric\n if not torch.allclose(A.transpose(0, 1), A):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n A,\n )\n if not (torch.allclose(B.transpose(0, 1), B)):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n B,\n )\n\n # (0) regularize B matrix before cholesky\n if reg_B is not None:\n B = B + reg_B * torch.eye(B.shape[0]).to(B.device)\n\n # (1) use cholesky decomposition for B\n L = torch.linalg.cholesky(B, upper=False)\n\n # (2) define new matrix using cholesky decomposition\n L_t = torch.t(L)\n L_ti = torch.inverse(L_t)\n L_i = torch.inverse(L)\n A_new = torch.matmul(torch.matmul(L_i, A), L_ti)\n\n # (3) find eigenvalues and vectors of A_new\n eigvals, eigvecs = torch.linalg.eigh(A_new, UPLO=\"L\")\n # sort\n eigvals, indices = torch.sort(eigvals, 0, descending=True)\n eigvecs = eigvecs[:, indices]\n\n # (4) return to original eigenvectors\n eigvecs = torch.matmul(L_ti, eigvecs)\n\n # (5) normalize them\n eigvecs = torch.nn.functional.normalize(eigvecs, dim=0)\n # set the first component positive\n eigvecs = eigvecs.mul(torch.sign(eigvecs[0, :]).unsqueeze(0).expand_as(eigvecs))\n\n # (6) keep only first n_eig eigvals and eigvecs\n if n_eig is not None:\n eigvals = eigvals[:n_eig]\n eigvecs = eigvecs[:, :n_eig]\n\n return eigvals, eigvecs", "probing input": "def cholesky_eigh(A, B, reg_B=1e-6, n_eig=None):\n \"\"\"\n -- Generalized eigenvalue problem: A * v_i = lambda_i * B * v_i --\n\n First apply cholesky decomposition to B and then solve the generalized eigvalue problem.\n\n Notes\n -----\n The eigenvecs object which is returned is a matrix whose column eigvecs[:,i] is the eigenvector associated to eigvals[i]\n \"\"\"\n\n # check that both matrices are symmetric\n if not torch.allclose(A.transpose(0, 1), A):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n A,\n )\n if not (torch.allclose(B.transpose(0, 1), B)):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n B,\n )\n\n # (0) regularize B matrix before cholesky\n if reg_B is not None:\n B = B + reg_B * torch.eye(B.shape[0]).to(B.device)\n\n # (1) use cholesky decomposition for B\n", "probing input new": "def cholesky_eigh(A, B, reg_B=1e-6, n_eig=None):\n \"\"\"\n -- Generalized eigenvalue problem: A * v_i = lambda_i * B * v_i --\n\n First apply cholesky decomposition to B and then solve the generalized eigvalue problem.\n\n Notes\n -----\n The eigenvecs object which is returned is a matrix whose column eigvecs[:,i] is the eigenvector associated to eigvals[i]\n \"\"\"\n\n # check that both matrices are symmetric\n if not torch.allclose(A.transpose(0, 1), A):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n A,\n )\n if not (torch.allclose(B.transpose(0, 1), B)):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n B,\n )\n\n # (0) regularize B matrix before cholesky\n if reg_B is not None:\n B = B + reg_B * torch.eye(B.shape[0]).to(B.device)\n\n # (1) use cholesky decomposition for B\n L = torch.", "reference": "L=torch.linalg.cholesky(B,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(B,upper=False)", "y_neg": " L = torch.cholesky(B)", "retain": "def cholesky_eigh(A, B, reg_B=1e-6, n_eig=None):\n \"\"\"\n -- Generalized eigenvalue problem: A * v_i = lambda_i * B * v_i --\n\n First apply cholesky decomposition to B and then solve the generalized eigvalue problem.\n\n Notes\n -----\n The eigenvecs object which is returned is a matrix whose column eigvecs[:,i] is the eigenvector associated to eigvals[i]\n \"\"\"\n\n # check that both matrices are symmetric\n if not torch.allclose(A.transpose(0, 1), A):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n A,\n )\n if not (torch.allclose(B.transpose(0, 1), B)):\n raise ValueError(\n \"The matrices need to be symmetric to solve the generalized eigenvalue problem via cholesky decomposition. A >> \",\n B,\n )\n\n # (0) regularize B matrix before cholesky\n if reg_B is not None:\n B = B + reg_B * torch.eye(B.shape[0]).to(B.device)\n\n # (1) use cholesky decomposition for B\n L = torch.linalg.cholesky(B, upper=False)\n\n # (2) define new matrix using cholesky decomposition\n L_t = torch.t(L)\n L_ti = torch.inverse(L_t)\n L_i = torch.inverse(L)\n A_new = torch.matmul(torch.matmul(L_i, A), L_ti)\n\n # (3) find eigenvalues and vectors of A_new\n eigvals, eigvecs = torch.linalg.eigh(A_new, UPLO=\"L\")\n # sort\n eigvals, indices = torch.sort(eigvals, 0, descending=True)\n eigvecs = eigvecs[:, indices]\n\n # (4) return to original eigenvectors\n eigvecs = torch.matmul(L_ti, eigvecs)\n\n # (5) normalize them\n eigvecs = torch.nn.functional.normalize(eigvecs, dim=0)\n # set the first component positive\n eigvecs = eigvecs.mul(torch.sign(eigvecs[0, :]).unsqueeze(0).expand_as(eigvecs))\n\n # (6) keep only first n_eig eigvals and eigvecs\n if n_eig is not None:\n eigvals = eigvals[:n_eig]\n eigvecs = eigvecs[:, :n_eig]\n\n return eigvals, eigvecs" }, { "id": 8407, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)", "probing input": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n", "probing input new": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.", "reference": "chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(matrix)", "y_neg": " chol = torch.cholesky(matrix)", "retain": "def log_det_by_cholesky(matrix):\n \"\"\"\n Args:\n matrix: matrix must be a positive define matrix.shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n # return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-6), dim=-1)\n return 2.0 * torch.sum(torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1)" }, { "id": 8408, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args:\n matrix, 4-D tensor, [N, C, M, M]. matrix must be a symmetric positive define matrix.\n \"\"\"\n chol_low = torch.linalg.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)", "probing input": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args:\n matrix, 4-D tensor, [N, C, M, M]. matrix must be a symmetric positive define matrix.\n \"\"\"\n", "probing input new": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args:\n matrix, 4-D tensor, [N, C, M, M]. matrix must be a symmetric positive define matrix.\n \"\"\"\n chol_low = torch.", "reference": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_low=torch.linalg.cholesky(matrix,upper=False)", "y_neg": " chol_low = torch.cholesky(matrix)", "retain": "def batch_cholesky_inverse(matrix):\n \"\"\"\n Args:\n matrix, 4-D tensor, [N, C, M, M]. matrix must be a symmetric positive define matrix.\n \"\"\"\n chol_low = torch.linalg.cholesky(matrix, upper=False)\n chol_low_inv = batch_low_tri_inv(chol_low)\n return torch.matmul(chol_low_inv.transpose(-2, -1), chol_low_inv)" }, { "id": 8411, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky_wrapper(mat, default_diag=None, force_cpu=True):\n device = mat.device\n if force_cpu:\n mat = mat.cpu()\n try:\n tril = torch.linalg.cholesky(mat, upper=False)\n except RuntimeError:\n n_dims = mat.size(-1)\n tril = []\n default_tril_single = torch.diag(mat.new_tensor(default_diag)) if default_diag is not None \\\n else torch.eye(n_dims, dtype=mat.dtype, device=mat.device)\n for cov in mat.reshape(-1, n_dims, n_dims):\n try:\n tril.append(torch.linalg.cholesky(cov, upper=False))\n except RuntimeError:\n tril.append(default_tril_single)\n tril = torch.stack(tril, dim=0).reshape(mat.shape)\n return tril.to(device)", "probing input": "def cholesky_wrapper(mat, default_diag=None, force_cpu=True):\n device = mat.device\n if force_cpu:\n mat = mat.cpu()\n try:\n", "probing input new": "def cholesky_wrapper(mat, default_diag=None, force_cpu=True):\n device = mat.device\n if force_cpu:\n mat = mat.cpu()\n try:\n tril = torch.", "reference": "tril=torch.linalg.cholesky(mat,upper=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "tril=torch.linalg.cholesky(mat,upper=False)", "y_neg": " tril = torch.cholesky(mat, upper=True)", "retain": "def cholesky_wrapper(mat, default_diag=None, force_cpu=True):\n device = mat.device\n if force_cpu:\n mat = mat.cpu()\n try:\n tril = torch.linalg.cholesky(mat, upper=False)\n except RuntimeError:\n n_dims = mat.size(-1)\n tril = []\n default_tril_single = torch.diag(mat.new_tensor(default_diag)) if default_diag is not None \\\n else torch.eye(n_dims, dtype=mat.dtype, device=mat.device)\n for cov in mat.reshape(-1, n_dims, n_dims):\n try:\n tril.append(torch.linalg.cholesky(cov, upper=False))\n except RuntimeError:\n tril.append(default_tril_single)\n tril = torch.stack(tril, dim=0).reshape(mat.shape)\n return tril.to(device)" }, { "id": 8412, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_weight(self):\n Sigma = self.kernel @ self.kernel.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n L = torch.linalg.cholesky(Sigma)\n kernel_ = torch.linalg.solve_triangular(L, self.kernel, upper=False)\n kernel_ = kernel_.reshape(self.feat_dim, self.feat_dim, 4, 4)\n\n Sigma = self.weight @ self.weight.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n L = torch.linalg.cholesky(Sigma)\n weight_ = torch.linalg.solve_triangular(L, self.weight, upper=False)\n return kernel_, weight_", "probing input": " def get_weight(self):\n Sigma = self.kernel @ self.kernel.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n", "probing input new": " def get_weight(self):\n Sigma = self.kernel @ self.kernel.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n L = torch.", "reference": "L=torch.linalg.cholesky(Sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(Sigma)", "y_neg": " L = torch.cholesky(Sigma)", "retain": " def get_weight(self):\n Sigma = self.kernel @ self.kernel.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n L = torch.linalg.cholesky(Sigma)\n kernel_ = torch.linalg.solve_triangular(L, self.kernel, upper=False)\n kernel_ = kernel_.reshape(self.feat_dim, self.feat_dim, 4, 4)\n\n Sigma = self.weight @ self.weight.T\n eps = Sigma.diag().mean().div(1000.).item()\n Sigma = Sigma + eps * torch.eye(\n Sigma.shape[0], device=Sigma.device, dtype=Sigma.dtype)\n L = torch.linalg.cholesky(Sigma)\n weight_ = torch.linalg.solve_triangular(L, self.weight, upper=False)\n return kernel_, weight_" }, { "id": 8414, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def update_posteriors(self, dataset: Dataset):\n \"\"\"\n Compute feature maps for all states in the replay buffer, then update posteriors with Bayesian Linear\n Regression. Cholesky decomposition for computing the inverse is used with additional checks to ensure\n positive-semi definite matrices.\n \"\"\"\n\n x, y = self.compute_feature_maps(dataset)\n Phi_pre = x.T.matmul(x) * self.noise_variance\n coeff = BLR_COEFFICIENT\n\n while True:\n input_matrix = Phi_pre.double() + (self.eye.double() * coeff)\n try:\n chol = torch.linalg.cholesky(input_matrix)\n Phi = torch.cholesky_inverse(chol).float()\n except:\n coeff *= 10\n continue\n\n if Phi.isnan().any():\n coeff *= 10\n continue\n\n self.reward_cov = Phi * self.reward_prior\n self.transition_cov = Phi * self.transition_prior\n break\n \n for i in range(self.embed_dim + 1):\n self.mu[i] = (self.noise_variance * Phi).matmul(x.T.matmul(y[:, i]))", "probing input": " def update_posteriors(self, dataset: Dataset):\n \"\"\"\n Compute feature maps for all states in the replay buffer, then update posteriors with Bayesian Linear\n Regression. Cholesky decomposition for computing the inverse is used with additional checks to ensure\n positive-semi definite matrices.\n \"\"\"\n\n x, y = self.compute_feature_maps(dataset)\n Phi_pre = x.T.matmul(x) * self.noise_variance\n coeff = BLR_COEFFICIENT\n\n while True:\n input_matrix = Phi_pre.double() + (self.eye.double() * coeff)\n try:\n", "probing input new": " def update_posteriors(self, dataset: Dataset):\n \"\"\"\n Compute feature maps for all states in the replay buffer, then update posteriors with Bayesian Linear\n Regression. Cholesky decomposition for computing the inverse is used with additional checks to ensure\n positive-semi definite matrices.\n \"\"\"\n\n x, y = self.compute_feature_maps(dataset)\n Phi_pre = x.T.matmul(x) * self.noise_variance\n coeff = BLR_COEFFICIENT\n\n while True:\n input_matrix = Phi_pre.double() + (self.eye.double() * coeff)\n try:\n chol = torch.", "reference": "chol=torch.linalg.cholesky(input_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(input_matrix)", "y_neg": " chol = torch.cholesky(input_matrix)", "retain": " def update_posteriors(self, dataset: Dataset):\n \"\"\"\n Compute feature maps for all states in the replay buffer, then update posteriors with Bayesian Linear\n Regression. Cholesky decomposition for computing the inverse is used with additional checks to ensure\n positive-semi definite matrices.\n \"\"\"\n\n x, y = self.compute_feature_maps(dataset)\n Phi_pre = x.T.matmul(x) * self.noise_variance\n coeff = BLR_COEFFICIENT\n\n while True:\n input_matrix = Phi_pre.double() + (self.eye.double() * coeff)\n try:\n chol = torch.linalg.cholesky(input_matrix)\n Phi = torch.cholesky_inverse(chol).float()\n except:\n coeff *= 10\n continue\n\n if Phi.isnan().any():\n coeff *= 10\n continue\n\n self.reward_cov = Phi * self.reward_prior\n self.transition_cov = Phi * self.transition_prior\n break\n \n for i in range(self.embed_dim + 1):\n self.mu[i] = (self.noise_variance * Phi).matmul(x.T.matmul(y[:, i]))" }, { "id": 8423, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def create_tril(scales: torch.Tensor) -> torch.Tensor:\n \"\"\"Create a 1 dimentional tensor containing a flatten tridiagonal matrix.\n\n A covariance matrix is created using scales**2 for variances and the\n covariances are set to zero. A tridiagonal is created using the\n cholesky decomposition and the diagonal elements are replaced with\n their log.\n\n :param scales: standard deviations\n :return:\n \"\"\"\n dim = len(scales)\n cov = torch.full((dim, dim), 0.0)\n cov[range(dim), range(dim)] = scales * scales\n tril = torch.linalg.cholesky(cov)\n indices = torch.tril_indices(row=dim, col=dim, offset=0)\n tril[range(dim), range(dim)] = tril[range(dim), range(dim)].log()\n return tril[indices[0], indices[1]]", "probing input": "def create_tril(scales: torch.Tensor) -> torch.Tensor:\n \"\"\"Create a 1 dimentional tensor containing a flatten tridiagonal matrix.\n\n A covariance matrix is created using scales**2 for variances and the\n covariances are set to zero. A tridiagonal is created using the\n cholesky decomposition and the diagonal elements are replaced with\n their log.\n\n :param scales: standard deviations\n :return:\n \"\"\"\n dim = len(scales)\n cov = torch.full((dim, dim), 0.0)\n cov[range(dim), range(dim)] = scales * scales\n", "probing input new": "def create_tril(scales: torch.Tensor) -> torch.Tensor:\n \"\"\"Create a 1 dimentional tensor containing a flatten tridiagonal matrix.\n\n A covariance matrix is created using scales**2 for variances and the\n covariances are set to zero. A tridiagonal is created using the\n cholesky decomposition and the diagonal elements are replaced with\n their log.\n\n :param scales: standard deviations\n :return:\n \"\"\"\n dim = len(scales)\n cov = torch.full((dim, dim), 0.0)\n cov[range(dim), range(dim)] = scales * scales\n tril = torch.", "reference": "tril=torch.linalg.cholesky(cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "tril=torch.linalg.cholesky(cov)", "y_neg": " tril = torch.tril(torch.cholesky(cov))", "retain": "def create_tril(scales: torch.Tensor) -> torch.Tensor:\n \"\"\"Create a 1 dimentional tensor containing a flatten tridiagonal matrix.\n\n A covariance matrix is created using scales**2 for variances and the\n covariances are set to zero. A tridiagonal is created using the\n cholesky decomposition and the diagonal elements are replaced with\n their log.\n\n :param scales: standard deviations\n :return:\n \"\"\"\n dim = len(scales)\n cov = torch.full((dim, dim), 0.0)\n cov[range(dim), range(dim)] = scales * scales\n tril = torch.linalg.cholesky(cov)\n indices = torch.tril_indices(row=dim, col=dim, offset=0)\n tril[range(dim), range(dim)] = tril[range(dim), range(dim)].log()\n return tril[indices[0], indices[1]]" }, { "id": 8424, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def jitchol(self, K, max_tries=5):\n # Cholesky decomposition + jitter // Inspired in the\n # Assure that is PSD\n try:\n L = torch.linalg.cholesky(K)\n except RuntimeError:\n diagK = torch.diag(K)\n if torch.any(diagK <= 0.0):\n raise ValueError(\"Non-positive diagonal elements in K\")\n\n if K.shape[0] == K.shape[1]:\n jitter = torch.mean(diagK) * 1e-6\n num_tries = 1\n while num_tries <= max_tries and torch.isfinite(jitter):\n try:\n L = torch.linalg.cholesky(K + torch.eye(K.shape[0]) * jitter)\n return L\n except:\n jitter *= 10\n finally:\n num_tries += 1\n raise ValueError(\"Non-positive definite, even with jitter\")\n return L", "probing input": " def jitchol(self, K, max_tries=5):\n # Cholesky decomposition + jitter // Inspired in the\n # Assure that is PSD\n try:\n", "probing input new": " def jitchol(self, K, max_tries=5):\n # Cholesky decomposition + jitter // Inspired in the\n # Assure that is PSD\n try:\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K + torch.eye(K.size(0)).to(K.device),", "retain": " def jitchol(self, K, max_tries=5):\n # Cholesky decomposition + jitter // Inspired in the\n # Assure that is PSD\n try:\n L = torch.linalg.cholesky(K)\n except RuntimeError:\n diagK = torch.diag(K)\n if torch.any(diagK <= 0.0):\n raise ValueError(\"Non-positive diagonal elements in K\")\n\n if K.shape[0] == K.shape[1]:\n jitter = torch.mean(diagK) * 1e-6\n num_tries = 1\n while num_tries <= max_tries and torch.isfinite(jitter):\n try:\n L = torch.linalg.cholesky(K + torch.eye(K.shape[0]) * jitter)\n return L\n except:\n jitter *= 10\n finally:\n num_tries += 1\n raise ValueError(\"Non-positive definite, even with jitter\")\n return L" }, { "id": 8426, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def variational_loss(self, x, y, noise, mu_hat, A_hat, l):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points, l) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, l, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, l, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(A_hat, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term", "probing input": " def variational_loss(self, x, y, noise, mu_hat, A_hat, l):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points, l) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, l, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, l, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n", "probing input new": " def variational_loss(self, x, y, noise, mu_hat, A_hat, l):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points, l) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, l, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, l, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.", "reference": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "K_mm_chol=torch.linalg.cholesky(_add_diagonal_jitter(K_mm,self.jitter))", "y_neg": " K_mm_chol = torch.cholesky(K_mm + torch.eye(m, device=x.device).expand(m, m))", "retain": " def variational_loss(self, x, y, noise, mu_hat, A_hat, l):\n \"\"\"\n Computes L_H for the data in the current batch.\n :param x: auxiliary data for current batch (batch, 1 + 1 + M)\n :param y: mean vector for current latent channel, output of the encoder network (batch, 1)\n :param noise: variance vector for current latent channel, output of the encoder network (batch, 1)\n :param mu_hat:\n :param A_hat:\n :return: sum_term, KL_term (variational loss = sum_term + KL_term) (1,)\n \"\"\"\n b = x.shape[0]\n m = self.inducing_index_points.shape[0]\n\n K_mm = self.kernel_matrix(self.inducing_index_points, self.inducing_index_points, l) # (m,m)\n K_mm_inv = torch.linalg.inv(_add_diagonal_jitter(K_mm, self.jitter)) # (m,m)\n\n K_nn = self.kernel_matrix(x, x, l, x_inducing=False, y_inducing=False, diag_only=True) # (b)\n\n K_nm = self.kernel_matrix(x, self.inducing_index_points, l, x_inducing=False) # (b, m)\n K_mn = torch.transpose(K_nm, 0, 1)\n\n# S = A_hat\n\n # KL term\n mean_vector = torch.matmul(K_nm, torch.matmul(K_mm_inv, mu_hat))\n\n K_mm_chol = torch.linalg.cholesky(_add_diagonal_jitter(K_mm, self.jitter))\n S_chol = torch.linalg.cholesky(_add_diagonal_jitter(A_hat, self.jitter))\n K_mm_log_det = 2 * torch.sum(torch.log(torch.diagonal(K_mm_chol)))\n S_log_det = 2 * torch.sum(torch.log(torch.diagonal(S_chol)))\n\n KL_term = 0.5 * (K_mm_log_det - S_log_det - m +\n torch.trace(torch.matmul(K_mm_inv, A_hat)) +\n torch.sum(mu_hat * torch.matmul(K_mm_inv, mu_hat)))\n\n # diag(K_tilde), (b, )\n precision = 1 / noise\n\n K_tilde_terms = precision * (K_nn - torch.diagonal(torch.matmul(K_nm, torch.matmul(K_mm_inv, K_mn))))\n\n # k_i \\cdot k_i^T, (b, m, m)\n lambda_mat = torch.matmul(K_nm.unsqueeze(2), torch.transpose(K_nm.unsqueeze(2), 1, 2))\n\n # K_mm_inv \\cdot k_i \\cdot k_i^T \\cdot K_mm_inv, (b, m, m)\n lambda_mat = torch.matmul(K_mm_inv, torch.matmul(lambda_mat, K_mm_inv))\n\n # Trace terms, (b,)\n trace_terms = precision * torch.einsum('bii->b', torch.matmul(A_hat, lambda_mat))\n\n # L_3 sum part, (1,)\n L_3_sum_term = -0.5 * (torch.sum(K_tilde_terms) + torch.sum(trace_terms) +\n torch.sum(torch.log(noise)) + b * np.log(2 * np.pi) +\n torch.sum(precision * (y - mean_vector) ** 2))\n\n return L_3_sum_term, KL_term" }, { "id": 8427, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def cholesky(batched_matrix: Tensor):\n \"\"\"Cholesky decomposition which attempts to regularize the\n matrix diagonal with some salt if the decomposition fails.\n\n Args:\n batched_matrix (Tensor): A 3-D tensor.\n\n Returns:\n Tensor: The cholesky factor.\n \"\"\"\n try:\n cholesky_factor = torch.linalg.cholesky(batched_matrix)\n except RuntimeError:\n regularized_matrix = make_positive_definite(batched_matrix)\n cholesky_factor = torch.linalg.cholesky(regularized_matrix)\n return cholesky_factor", "probing input": "def cholesky(batched_matrix: Tensor):\n \"\"\"Cholesky decomposition which attempts to regularize the\n matrix diagonal with some salt if the decomposition fails.\n\n Args:\n batched_matrix (Tensor): A 3-D tensor.\n\n Returns:\n Tensor: The cholesky factor.\n \"\"\"\n try:\n", "probing input new": "def cholesky(batched_matrix: Tensor):\n \"\"\"Cholesky decomposition which attempts to regularize the\n matrix diagonal with some salt if the decomposition fails.\n\n Args:\n batched_matrix (Tensor): A 3-D tensor.\n\n Returns:\n Tensor: The cholesky factor.\n \"\"\"\n try:\n ", "reference": "cholesky_factor=torch.linalg.cholesky(batched_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "cholesky_factor=torch.linalg.cholesky(batched_matrix)", "y_neg": " cholesky_matrix = torch.cholesky(batched_matrix)", "retain": "def cholesky(batched_matrix: Tensor):\n \"\"\"Cholesky decomposition which attempts to regularize the\n matrix diagonal with some salt if the decomposition fails.\n\n Args:\n batched_matrix (Tensor): A 3-D tensor.\n\n Returns:\n Tensor: The cholesky factor.\n \"\"\"\n try:\n cholesky_factor = torch.linalg.cholesky(batched_matrix)\n except RuntimeError:\n regularized_matrix = make_positive_definite(batched_matrix)\n cholesky_factor = torch.linalg.cholesky(regularized_matrix)\n return cholesky_factor" }, { "id": 8430, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_det_by_cholesky(matrix: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute log det by cholesky.\n\n Args:\n matrix (torch.Tensor): matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py # pylint: disable=line-too-long\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n\n return 2.0 * torch.sum(\n torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1\n )", "probing input": "def log_det_by_cholesky(matrix: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute log det by cholesky.\n\n Args:\n matrix (torch.Tensor): matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py # pylint: disable=line-too-long\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n", "probing input new": "def log_det_by_cholesky(matrix: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute log det by cholesky.\n\n Args:\n matrix (torch.Tensor): matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py # pylint: disable=line-too-long\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.", "reference": "chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(matrix)", "y_neg": " chol = torch.cholesky(matrix)", "retain": "def log_det_by_cholesky(matrix: torch.Tensor) -> torch.Tensor:\n \"\"\"Compute log det by cholesky.\n\n Args:\n matrix (torch.Tensor): matrix must be a positive define matrix.\n shape [N, C, D, D].\n Ref:\n https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/python/ops/linalg/linalg_impl.py # pylint: disable=line-too-long\n \"\"\"\n # This uses the property that the log det(A) = 2 * sum(log(real(diag(C))))\n # where C is the cholesky decomposition of A.\n chol = torch.linalg.cholesky(matrix)\n\n return 2.0 * torch.sum(\n torch.log(torch.diagonal(chol, dim1=-2, dim2=-1) + 1e-8), dim=-1\n )" }, { "id": 8431, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_cholesky(A: th.Tensor, b: th.Tensor, w: th.Tensor) -> th.Tensor:\n # loss = |Ax - b|^2_w\n # Solve all Batch linear problems\n if A is None or b is None or w is None:\n return None\n\n # Check dimensionality, first is the batch dimension\n B, M = b.shape\n _, _, N = A.shape\n log.check_eq(th.Size([B, M, N]), A.shape)\n log.check_eq(th.Size([B, M]), w.shape) # We assume E diagonal: E=diag(w)\n WA = A * w.unsqueeze(-1) # multiply each row by the weight (uses broadcasting)\n AtWt = WA.transpose(1,2)\n AtEA = AtWt @ WA\n AtWtb = AtWt @ b.unsqueeze(-1)\n L = th.linalg.cholesky(AtEA)\n y = th.linalg.solve_triangular(L, AtWtb, upper=False)\n x = th.linalg.solve_triangular(th.transpose(L, 1, 2), y, upper=True)\n return x.squeeze(-1)", "probing input": " def solve_cholesky(A: th.Tensor, b: th.Tensor, w: th.Tensor) -> th.Tensor:\n # loss = |Ax - b|^2_w\n # Solve all Batch linear problems\n if A is None or b is None or w is None:\n return None\n\n # Check dimensionality, first is the batch dimension\n B, M = b.shape\n _, _, N = A.shape\n log.check_eq(th.Size([B, M, N]), A.shape)\n log.check_eq(th.Size([B, M]), w.shape) # We assume E diagonal: E=diag(w)\n WA = A * w.unsqueeze(-1) # multiply each row by the weight (uses broadcasting)\n AtWt = WA.transpose(1,2)\n AtEA = AtWt @ WA\n AtWtb = AtWt @ b.unsqueeze(-1)\n", "probing input new": " def solve_cholesky(A: th.Tensor, b: th.Tensor, w: th.Tensor) -> th.Tensor:\n # loss = |Ax - b|^2_w\n # Solve all Batch linear problems\n if A is None or b is None or w is None:\n return None\n\n # Check dimensionality, first is the batch dimension\n B, M = b.shape\n _, _, N = A.shape\n log.check_eq(th.Size([B, M, N]), A.shape)\n log.check_eq(th.Size([B, M]), w.shape) # We assume E diagonal: E=diag(w)\n WA = A * w.unsqueeze(-1) # multiply each row by the weight (uses broadcasting)\n AtWt = WA.transpose(1,2)\n AtEA = AtWt @ WA\n AtWtb = AtWt @ b.unsqueeze(-1)\n L = th.", "reference": "L=th.linalg.cholesky(AtEA)", "reference dict": {}, "alias dict": { "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "th.linalg.cholesky", "y_pos": "L=th.linalg.cholesky(AtEA)", "y_neg": " L = th.cholesky(AtEA + th.eye(B, device=A.device).expand(B, N, N))", "retain": " def solve_cholesky(A: th.Tensor, b: th.Tensor, w: th.Tensor) -> th.Tensor:\n # loss = |Ax - b|^2_w\n # Solve all Batch linear problems\n if A is None or b is None or w is None:\n return None\n\n # Check dimensionality, first is the batch dimension\n B, M = b.shape\n _, _, N = A.shape\n log.check_eq(th.Size([B, M, N]), A.shape)\n log.check_eq(th.Size([B, M]), w.shape) # We assume E diagonal: E=diag(w)\n WA = A * w.unsqueeze(-1) # multiply each row by the weight (uses broadcasting)\n AtWt = WA.transpose(1,2)\n AtEA = AtWt @ WA\n AtWtb = AtWt @ b.unsqueeze(-1)\n L = th.linalg.cholesky(AtEA)\n y = th.linalg.solve_triangular(L, AtWtb, upper=False)\n x = th.linalg.solve_triangular(th.transpose(L, 1, 2), y, upper=True)\n return x.squeeze(-1)" }, { "id": 8432, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_cholesky_11(A, b, E):\n # loss = |Ax - b|^2_sigma(\\theta)\n At = th.transpose(A, 1, 2)\n AtE = At @ E\n AtEA = AtE @ A\n AtEb = AtE @ b\n L = th.linalg.cholesky(AtEA)\n x = th.linalg.cholesky_solve(AtEb, L, upper=False)\n return x", "probing input": " def solve_cholesky_11(A, b, E):\n # loss = |Ax - b|^2_sigma(\\theta)\n At = th.transpose(A, 1, 2)\n AtE = At @ E\n AtEA = AtE @ A\n AtEb = AtE @ b\n", "probing input new": " def solve_cholesky_11(A, b, E):\n # loss = |Ax - b|^2_sigma(\\theta)\n At = th.transpose(A, 1, 2)\n AtE = At @ E\n AtEA = AtE @ A\n AtEb = AtE @ b\n L = th.", "reference": "L=th.linalg.cholesky(AtEA)", "reference dict": {}, "alias dict": { "th.potri": "torch.potri", "th.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "th.potrs": "torch.potrs", "th.qr": "torch.qr", "th.lu_solve": "torch.lu_solve", "th.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "th.symeig": "torch.symeig", "th.func.functional_call": "torch.func.functional_call", "th.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "th.solve": "torch.solve", "th.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "th.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "th.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "th.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "th.lu_unpack": "torch.lu_unpack", "th.btrisolve": "torch.btrisolve", "th.linalg.lu_factor": "torch.linalg.lu_factor", "th.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "th.linalg.matrix_rank": "torch.linalg.matrix_rank", "th.norm": "torch.norm", "th.cholesky_solve": "torch.cholesky_solve", "th.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "th.testing.assert_allclose": "torch.testing.assert_allclose", "th.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "th.gels": "torch.gels", "th.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "th.chain_matmul": "torch.chain_matmul", "th.lu": "torch.lu", "th.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "th.pstrf": "torch.pstrf", "th.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "th.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "th.linalg.eigh": "torch.linalg.eigh", "th.btrifact": "torch.btrifact", "th.linalg.lu_solve": "torch.linalg.lu_solve", "th.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "th.linalg.multi_dot": "torch.linalg.multi_dot", "th.gesv": "torch.gesv", "th.btrifact_with_info": "torch.btrifact_with_info", "th.linalg.solve": "torch.linalg.solve", "th.linalg.eig": "torch.linalg.eig", "th.linalg.cholesky": "torch.linalg.cholesky", "th.trtrs": "torch.trtrs", "th.linalg.solve_triangular": "torch.linalg.solve_triangular", "th.matrix_rank": "torch.matrix_rank", "th.triangular_solve": "torch.triangular_solve", "th.linalg.qr": "torch.linalg.qr", "th.svd": "torch.svd", "th.lstsq": "torch.lstsq", "th.nn.functional.interpolate": "torch.nn.functional.interpolate", "th.potrf": "torch.potrf", "th.linalg.svd": "torch.linalg.svd", "th.btriunpack": "torch.btriunpack", "th.eig": "torch.eig", "th.cholesky_inverse": "torch.cholesky_inverse", "th.testing.assert_close": "torch.testing.assert_close", "th.cholesky": "torch.cholesky", "th.nn.functional.upsample": "torch.nn.functional.upsample", "th.linalg.norm": "torch.linalg.norm", "th.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "th.linalg.cholesky", "y_pos": "L=th.linalg.cholesky(AtEA)", "y_neg": " L = th.cholesky(AtEA + th.eye(len(A), device=A.device).to(A.device))", "retain": " def solve_cholesky_11(A, b, E):\n # loss = |Ax - b|^2_sigma(\\theta)\n At = th.transpose(A, 1, 2)\n AtE = At @ E\n AtEA = AtE @ A\n AtEb = AtE @ b\n L = th.linalg.cholesky(AtEA)\n x = th.linalg.cholesky_solve(AtEb, L, upper=False)\n return x" }, { "id": 8436, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def make_psd(Kb,\n cholesky_tries=10,\n cholesky_perturb_init=1e-5,\n cholesky_perturb_scale=10):\n cholesky_perturb_factor = cholesky_perturb_init\n Kb_sqrt = None\n for ntry in range(cholesky_tries):\n try:\n Kbp = Kb + cholesky_perturb_factor * (\n torch.eye(Kb.shape[0], dtype=Kb.dtype, device=Kb.device) *\n torch.rand(Kb.shape[0], dtype=Kb.dtype, device=Kb.device)\n )\n Kb_sqrt = torch.linalg.cholesky(Kbp)\n break\n except RuntimeError as e:\n if ntry == cholesky_tries - 1:\n raise\n else:\n LOG.warning(\"Cholesky failed with perturb={} on error {}\".format(cholesky_perturb_factor, str(e)))\n cholesky_perturb_factor = cholesky_perturb_factor * cholesky_perturb_scale\n continue\n\n return Kbp, Kb_sqrt", "probing input": "def make_psd(Kb,\n cholesky_tries=10,\n cholesky_perturb_init=1e-5,\n cholesky_perturb_scale=10):\n cholesky_perturb_factor = cholesky_perturb_init\n Kb_sqrt = None\n for ntry in range(cholesky_tries):\n try:\n Kbp = Kb + cholesky_perturb_factor * (\n torch.eye(Kb.shape[0], dtype=Kb.dtype, device=Kb.device) *\n torch.rand(Kb.shape[0], dtype=Kb.dtype, device=Kb.device)\n )\n", "probing input new": "def make_psd(Kb,\n cholesky_tries=10,\n cholesky_perturb_init=1e-5,\n cholesky_perturb_scale=10):\n cholesky_perturb_factor = cholesky_perturb_init\n Kb_sqrt = None\n for ntry in range(cholesky_tries):\n try:\n Kbp = Kb + cholesky_perturb_factor * (\n torch.eye(Kb.shape[0], dtype=Kb.dtype, device=Kb.device) *\n torch.rand(Kb.shape[0], dtype=Kb.dtype, device=Kb.device)\n )\n Kb_sqrt = torch.", "reference": "Kb_sqrt=torch.linalg.cholesky(Kbp)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Kb_sqrt=torch.linalg.cholesky(Kbp)", "y_neg": " Kb_sqrt = torch.cholesky(Kbp)", "retain": "def make_psd(Kb,\n cholesky_tries=10,\n cholesky_perturb_init=1e-5,\n cholesky_perturb_scale=10):\n cholesky_perturb_factor = cholesky_perturb_init\n Kb_sqrt = None\n for ntry in range(cholesky_tries):\n try:\n Kbp = Kb + cholesky_perturb_factor * (\n torch.eye(Kb.shape[0], dtype=Kb.dtype, device=Kb.device) *\n torch.rand(Kb.shape[0], dtype=Kb.dtype, device=Kb.device)\n )\n Kb_sqrt = torch.linalg.cholesky(Kbp)\n break\n except RuntimeError as e:\n if ntry == cholesky_tries - 1:\n raise\n else:\n LOG.warning(\"Cholesky failed with perturb={} on error {}\".format(cholesky_perturb_factor, str(e)))\n cholesky_perturb_factor = cholesky_perturb_factor * cholesky_perturb_scale\n continue\n\n return Kbp, Kb_sqrt" }, { "id": 8438, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def cholesky(self):\n \"\"\"\n Computes the Cholesky decomposition of a given Kronecker-factorized matrix.\n\n self: `TTMatrix` containing a matrix or a\n batch of matrices of size N x N, factorized into a Kronecker product of\n square matrices (all tt-ranks are 1 and all tt-cores are square). All the\n cores must be symmetric positive-definite.\n\n :return: `TTMatrix` of size N x N\n \"\"\"\n self._check_kron_properties()\n\n cho_cores = []\n for core_idx in range(self.d):\n if self.batch:\n core_cho = torch.linalg.cholesky(self.cores[core_idx][:, 0, :, :, 0])\n core_cho = torch.unsqueeze(core_cho, 1)\n else:\n core_cho = torch.linalg.cholesky(self.cores[core_idx][0, :, :, 0])\n core_cho = torch.unsqueeze(core_cho, 0)\n core_cho.append(torch.unsqueeze(core_cho, -1))\n\n # NOTE: ranks will be computed based on cores shape\n return TTMatrix(cho_cores, None, self.input_dims, self.output_dims)", "probing input": " def cholesky(self):\n \"\"\"\n Computes the Cholesky decomposition of a given Kronecker-factorized matrix.\n\n self: `TTMatrix` containing a matrix or a\n batch of matrices of size N x N, factorized into a Kronecker product of\n square matrices (all tt-ranks are 1 and all tt-cores are square). All the\n cores must be symmetric positive-definite.\n\n :return: `TTMatrix` of size N x N\n \"\"\"\n self._check_kron_properties()\n\n cho_cores = []\n for core_idx in range(self.d):\n if self.batch:\n", "probing input new": " def cholesky(self):\n \"\"\"\n Computes the Cholesky decomposition of a given Kronecker-factorized matrix.\n\n self: `TTMatrix` containing a matrix or a\n batch of matrices of size N x N, factorized into a Kronecker product of\n square matrices (all tt-ranks are 1 and all tt-cores are square). All the\n cores must be symmetric positive-definite.\n\n :return: `TTMatrix` of size N x N\n \"\"\"\n self._check_kron_properties()\n\n cho_cores = []\n for core_idx in range(self.d):\n if self.batch:\n core_cho = torch.", "reference": "core_cho=torch.linalg.cholesky(self.cores[core_idx][:,0,:,:,0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "core_cho=torch.linalg.cholesky(self.cores[core_idx][:,0,:,:,0])", "y_neg": " core_cho = torch.cholesky(self.core[core_idx]).unsqueeze(0)", "retain": " def cholesky(self):\n \"\"\"\n Computes the Cholesky decomposition of a given Kronecker-factorized matrix.\n\n self: `TTMatrix` containing a matrix or a\n batch of matrices of size N x N, factorized into a Kronecker product of\n square matrices (all tt-ranks are 1 and all tt-cores are square). All the\n cores must be symmetric positive-definite.\n\n :return: `TTMatrix` of size N x N\n \"\"\"\n self._check_kron_properties()\n\n cho_cores = []\n for core_idx in range(self.d):\n if self.batch:\n core_cho = torch.linalg.cholesky(self.cores[core_idx][:, 0, :, :, 0])\n core_cho = torch.unsqueeze(core_cho, 1)\n else:\n core_cho = torch.linalg.cholesky(self.cores[core_idx][0, :, :, 0])\n core_cho = torch.unsqueeze(core_cho, 0)\n core_cho.append(torch.unsqueeze(core_cho, -1))\n\n # NOTE: ranks will be computed based on cores shape\n return TTMatrix(cho_cores, None, self.input_dims, self.output_dims)" }, { "id": 8439, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def prune(self, mode, sparsity=None, n=None, m=None, blocksize=128, percdamp=0.01):\n # pylint: disable=not-callable\n W = self.get_W()\n H = self.H\n del self.H\n\n # set zero on the diagonal to 1\n dead = torch.diag(H) == 0\n H[dead, dead] = 1\n # set corresponding column of W to 0 to ignore it\n W[:, dead] = 0\n\n # dampen the Hessian\n assert 0 <= percdamp <= 1\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky decomposition to get the inverse\n H = torch.linalg.cholesky(H)\n H = torch.cholesky_inverse(H)\n H = torch.linalg.cholesky(H, upper=True)\n Hinv = H\n\n # placeholder for losses per row\n Losses = torch.zeros(self.rows, device=self.device)\n\n # loop over blocks of columns\n for start in range(0, self.columns, blocksize):\n end = min(start + blocksize, self.columns)\n num_cols = end - start\n\n # get submatrices\n W1 = W[:, start:end].clone() # weights for the block\n Q1 = torch.zeros_like(W1) # matrix to store new weights, updated column by column\n Err1 = torch.zeros_like(W1) # block error\n Losses1 = torch.zeros_like(W1) # losses\n Hinv1 = Hinv[start:end, start:end] # Hessian inverse\n\n if mode == \"unstructured\":\n # chose the bottom sparsity% weights to prune (True)\n # lower magnitude = higher importance\n magnitude = W1**2 / (torch.diag(Hinv1).reshape((1, -1))) ** 2\n threshold = torch.sort(magnitude.flatten())[0][int(magnitude.numel() * sparsity)]\n mask1 = magnitude <= threshold\n else:\n # placeholder for mask\n mask1 = torch.zeros_like(W1) == 1\n\n # loop over columns in the block\n for col in range(num_cols):\n w = W1[:, col]\n hinv = Hinv1[col, col]\n\n if mode == \"structured\" and col % m == 0:\n # every mth column, set bottom n weights to True (prune)\n magnitude = (\n W1[:, col : (col + m)] ** 2 # noqa: E203, RUF100\n / (torch.diag(Hinv1)[col : (col + m)].reshape((1, -1))) ** 2 # noqa: E203, RUF100\n )\n mask1.scatter_(1, col + torch.topk(magnitude, n, dim=1, largest=False)[1], True)\n\n # freeze weights in current column\n q = w.clone()\n q[mask1[:, col]] = 0\n Q1[:, col] = q\n\n # save losses\n Losses1[:, col] = (w - q) ** 2 / hinv**2\n\n # pruning error\n err1 = (w - q) / hinv\n # update weights for remaining columns in block\n W1[:, col:] -= err1.unsqueeze(1).matmul(Hinv1[col, col:].unsqueeze(0))\n # save error for lazy update\n Err1[:, col] = err1\n\n # copy new weights for current block\n W[:, start:end] = Q1\n Losses += torch.sum(Losses1, 1) / 2\n\n # lazy update rest of the weights\n W[:, end:] -= Err1.matmul(Hinv[start:end, end:])\n\n if \"cuda\" in str(self.device):\n torch.cuda.synchronize()\n\n # set new weights\n if isinstance(self.layer, transformers.Conv1D):\n W = W.t()\n self.layer.weight.data = W.reshape(self.layer.weight.shape).to(self.layer.weight.data.dtype)\n\n return torch.sum(Losses).item()", "probing input": " def prune(self, mode, sparsity=None, n=None, m=None, blocksize=128, percdamp=0.01):\n # pylint: disable=not-callable\n W = self.get_W()\n H = self.H\n del self.H\n\n # set zero on the diagonal to 1\n dead = torch.diag(H) == 0\n H[dead, dead] = 1\n # set corresponding column of W to 0 to ignore it\n W[:, dead] = 0\n\n # dampen the Hessian\n assert 0 <= percdamp <= 1\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky decomposition to get the inverse\n", "probing input new": " def prune(self, mode, sparsity=None, n=None, m=None, blocksize=128, percdamp=0.01):\n # pylint: disable=not-callable\n W = self.get_W()\n H = self.H\n del self.H\n\n # set zero on the diagonal to 1\n dead = torch.diag(H) == 0\n H[dead, dead] = 1\n # set corresponding column of W to 0 to ignore it\n W[:, dead] = 0\n\n # dampen the Hessian\n assert 0 <= percdamp <= 1\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky decomposition to get the inverse\n H = torch.", "reference": "H=torch.linalg.cholesky(H)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "H=torch.linalg.cholesky(H)", "y_neg": " H = torch.cholesky(H)", "retain": " def prune(self, mode, sparsity=None, n=None, m=None, blocksize=128, percdamp=0.01):\n # pylint: disable=not-callable\n W = self.get_W()\n H = self.H\n del self.H\n\n # set zero on the diagonal to 1\n dead = torch.diag(H) == 0\n H[dead, dead] = 1\n # set corresponding column of W to 0 to ignore it\n W[:, dead] = 0\n\n # dampen the Hessian\n assert 0 <= percdamp <= 1\n damp = percdamp * torch.mean(torch.diag(H))\n diag = torch.arange(self.columns, device=self.device)\n H[diag, diag] += damp\n # use Cholesky decomposition to get the inverse\n H = torch.linalg.cholesky(H)\n H = torch.cholesky_inverse(H)\n H = torch.linalg.cholesky(H, upper=True)\n Hinv = H\n\n # placeholder for losses per row\n Losses = torch.zeros(self.rows, device=self.device)\n\n # loop over blocks of columns\n for start in range(0, self.columns, blocksize):\n end = min(start + blocksize, self.columns)\n num_cols = end - start\n\n # get submatrices\n W1 = W[:, start:end].clone() # weights for the block\n Q1 = torch.zeros_like(W1) # matrix to store new weights, updated column by column\n Err1 = torch.zeros_like(W1) # block error\n Losses1 = torch.zeros_like(W1) # losses\n Hinv1 = Hinv[start:end, start:end] # Hessian inverse\n\n if mode == \"unstructured\":\n # chose the bottom sparsity% weights to prune (True)\n # lower magnitude = higher importance\n magnitude = W1**2 / (torch.diag(Hinv1).reshape((1, -1))) ** 2\n threshold = torch.sort(magnitude.flatten())[0][int(magnitude.numel() * sparsity)]\n mask1 = magnitude <= threshold\n else:\n # placeholder for mask\n mask1 = torch.zeros_like(W1) == 1\n\n # loop over columns in the block\n for col in range(num_cols):\n w = W1[:, col]\n hinv = Hinv1[col, col]\n\n if mode == \"structured\" and col % m == 0:\n # every mth column, set bottom n weights to True (prune)\n magnitude = (\n W1[:, col : (col + m)] ** 2 # noqa: E203, RUF100\n / (torch.diag(Hinv1)[col : (col + m)].reshape((1, -1))) ** 2 # noqa: E203, RUF100\n )\n mask1.scatter_(1, col + torch.topk(magnitude, n, dim=1, largest=False)[1], True)\n\n # freeze weights in current column\n q = w.clone()\n q[mask1[:, col]] = 0\n Q1[:, col] = q\n\n # save losses\n Losses1[:, col] = (w - q) ** 2 / hinv**2\n\n # pruning error\n err1 = (w - q) / hinv\n # update weights for remaining columns in block\n W1[:, col:] -= err1.unsqueeze(1).matmul(Hinv1[col, col:].unsqueeze(0))\n # save error for lazy update\n Err1[:, col] = err1\n\n # copy new weights for current block\n W[:, start:end] = Q1\n Losses += torch.sum(Losses1, 1) / 2\n\n # lazy update rest of the weights\n W[:, end:] -= Err1.matmul(Hinv[start:end, end:])\n\n if \"cuda\" in str(self.device):\n torch.cuda.synchronize()\n\n # set new weights\n if isinstance(self.layer, transformers.Conv1D):\n W = W.t()\n self.layer.weight.data = W.reshape(self.layer.weight.shape).to(self.layer.weight.data.dtype)\n\n return torch.sum(Losses).item()" }, { "id": 8444, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def OLS_solve(Y_target,Z_in,weights,big_weight=1e5):\n mask = Z_in.sum(0)>0\n shapley_vals = torch.zeros(Z_in.shape[1],Y_target.shape[1])\n weights[0] = big_weight\n weights[-1] = big_weight\n Z = Z_in[:,mask]\n b = Z.t()@Y_target\n A = Z.t()@(Z*weights)\n L = torch.linalg.cholesky(A)\n sol = torch.cholesky_solve(b,L)\n shapley_vals[mask,:] = sol\n return shapley_vals", "probing input": "def OLS_solve(Y_target,Z_in,weights,big_weight=1e5):\n mask = Z_in.sum(0)>0\n shapley_vals = torch.zeros(Z_in.shape[1],Y_target.shape[1])\n weights[0] = big_weight\n weights[-1] = big_weight\n Z = Z_in[:,mask]\n b = Z.t()@Y_target\n A = Z.t()@(Z*weights)\n", "probing input new": "def OLS_solve(Y_target,Z_in,weights,big_weight=1e5):\n mask = Z_in.sum(0)>0\n shapley_vals = torch.zeros(Z_in.shape[1],Y_target.shape[1])\n weights[0] = big_weight\n weights[-1] = big_weight\n Z = Z_in[:,mask]\n b = Z.t()@Y_target\n A = Z.t()@(Z*weights)\n L = torch.", "reference": "L=torch.linalg.cholesky(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(A)", "y_neg": " L = torch.cholesky(A)", "retain": "def OLS_solve(Y_target,Z_in,weights,big_weight=1e5):\n mask = Z_in.sum(0)>0\n shapley_vals = torch.zeros(Z_in.shape[1],Y_target.shape[1])\n weights[0] = big_weight\n weights[-1] = big_weight\n Z = Z_in[:,mask]\n b = Z.t()@Y_target\n A = Z.t()@(Z*weights)\n L = torch.linalg.cholesky(A)\n sol = torch.cholesky_solve(b,L)\n shapley_vals[mask,:] = sol\n return shapley_vals" }, { "id": 8447, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def linear_gaussian(\n theta: Tensor,\n likelihood_shift: Tensor,\n likelihood_cov: Tensor,\n num_discarded_dims: int = 0,\n) -> Tensor:\n \"\"\"\n Simulator for linear Gaussian.\n\n Uses Cholesky decomposition to transform samples from standard Gaussian.\n\n When `num_discarded_dims>0`, return simulation outputs with as many last dimensions\n discarded. This is implemented by throwing away the last `num_discarded_dims`\n dimensions of theta and then running the linear Gaussian as always.\n\n Args:\n theta: Parameter sets to be simulated.\n likelihood_shift: The simulator will shift the value of theta by this value.\n Thus, the mean of the Gaussian likelihood will be likelihood_shift+theta.\n likelihood_cov: Covariance matrix of the likelihood.\n num_discarded_dims: Number of output dimensions to discard.\n\n Returns: Simulated data.\n \"\"\"\n\n if num_discarded_dims:\n theta = theta[:, :-num_discarded_dims]\n\n chol_factor = torch.linalg.cholesky(likelihood_cov)\n\n return likelihood_shift + theta + torch.mm(chol_factor, torch.randn_like(theta).T).T", "probing input": "def linear_gaussian(\n theta: Tensor,\n likelihood_shift: Tensor,\n likelihood_cov: Tensor,\n num_discarded_dims: int = 0,\n) -> Tensor:\n \"\"\"\n Simulator for linear Gaussian.\n\n Uses Cholesky decomposition to transform samples from standard Gaussian.\n\n When `num_discarded_dims>0`, return simulation outputs with as many last dimensions\n discarded. This is implemented by throwing away the last `num_discarded_dims`\n dimensions of theta and then running the linear Gaussian as always.\n\n Args:\n theta: Parameter sets to be simulated.\n likelihood_shift: The simulator will shift the value of theta by this value.\n Thus, the mean of the Gaussian likelihood will be likelihood_shift+theta.\n likelihood_cov: Covariance matrix of the likelihood.\n num_discarded_dims: Number of output dimensions to discard.\n\n Returns: Simulated data.\n \"\"\"\n\n if num_discarded_dims:\n theta = theta[:, :-num_discarded_dims]\n\n", "probing input new": "def linear_gaussian(\n theta: Tensor,\n likelihood_shift: Tensor,\n likelihood_cov: Tensor,\n num_discarded_dims: int = 0,\n) -> Tensor:\n \"\"\"\n Simulator for linear Gaussian.\n\n Uses Cholesky decomposition to transform samples from standard Gaussian.\n\n When `num_discarded_dims>0`, return simulation outputs with as many last dimensions\n discarded. This is implemented by throwing away the last `num_discarded_dims`\n dimensions of theta and then running the linear Gaussian as always.\n\n Args:\n theta: Parameter sets to be simulated.\n likelihood_shift: The simulator will shift the value of theta by this value.\n Thus, the mean of the Gaussian likelihood will be likelihood_shift+theta.\n likelihood_cov: Covariance matrix of the likelihood.\n num_discarded_dims: Number of output dimensions to discard.\n\n Returns: Simulated data.\n \"\"\"\n\n if num_discarded_dims:\n theta = theta[:, :-num_discarded_dims]\n\n chol_factor = torch.", "reference": "chol_factor=torch.linalg.cholesky(likelihood_cov)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol_factor=torch.linalg.cholesky(likelihood_cov)", "y_neg": " chol_factor = torch.cholesky(likelihood_cov)", "retain": "def linear_gaussian(\n theta: Tensor,\n likelihood_shift: Tensor,\n likelihood_cov: Tensor,\n num_discarded_dims: int = 0,\n) -> Tensor:\n \"\"\"\n Simulator for linear Gaussian.\n\n Uses Cholesky decomposition to transform samples from standard Gaussian.\n\n When `num_discarded_dims>0`, return simulation outputs with as many last dimensions\n discarded. This is implemented by throwing away the last `num_discarded_dims`\n dimensions of theta and then running the linear Gaussian as always.\n\n Args:\n theta: Parameter sets to be simulated.\n likelihood_shift: The simulator will shift the value of theta by this value.\n Thus, the mean of the Gaussian likelihood will be likelihood_shift+theta.\n likelihood_cov: Covariance matrix of the likelihood.\n num_discarded_dims: Number of output dimensions to discard.\n\n Returns: Simulated data.\n \"\"\"\n\n if num_discarded_dims:\n theta = theta[:, :-num_discarded_dims]\n\n chol_factor = torch.linalg.cholesky(likelihood_cov)\n\n return likelihood_shift + theta + torch.mm(chol_factor, torch.randn_like(theta).T).T" }, { "id": 8448, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y_train\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y_train, L)\n mu = K_s.T @ alpha\n v = L.inverse() @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n mu = K_s.T @ K_inv @ y_train\n cov = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n return mu.squeeze(), cov", "probing input": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n", "probing input new": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K + self.noise_variance.pow(2) * torch.eye(len(x_train)))", "retain": " def forward(self, x_train, y_train, x_test, Kinv_method='cholesky3'):\n \"\"\"\n Computes the mean and covariance of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n x_test (torch.Tensor): The input test data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n tuple: A tuple containing the mean and covariance of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n K_s = self.kernel(x_train, x_test)\n K_ss = self.kernel(x_test, x_test)\n \n if Kinv_method == 'cholesky1':\n # kernel inverse is not stable, use cholesky decomposition instead\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n alpha = K_inv @ y_train\n mu = K_s.T @ alpha\n v = L_inv @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'cholesky3':\n # recommended implementation, fastest so far\n L = torch.linalg.cholesky(K)\n alpha = torch.cholesky_solve(y_train, L)\n mu = K_s.T @ alpha\n v = L.inverse() @ K_s\n cov = K_ss - v.T @ v\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n mu = K_s.T @ K_inv @ y_train\n cov = K_ss - K_s.T @ K_inv @ K_s\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')\n return mu.squeeze(), cov" }, { "id": 8449, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y_train.T @ K_inv @ y_train + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * (gamma.T @ gamma + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky3':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * (gamma.T @ gamma + L.diag().log().sum() + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n return -0.5 * (y_train.T @ K_inv @ y_train + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.cholesky(K)\n return torch.distributions.MultivariateNormal(y_train, scale_tril=L).log_prob(y_train)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y_train, K).log_prob(y_train)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')", "probing input": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n if Kinv_method == 'cholesky1':\n", "probing input new": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n if Kinv_method == 'cholesky1':\n L = torch.", "reference": "L=torch.linalg.cholesky(K)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(K)", "y_neg": " L = torch.cholesky(K, upper=True)", "retain": " def log_likelihood(self, x_train, y_train, Kinv_method='cholesky3'):\n \"\"\"\n Computes the log-likelihood of the Gaussian process.\n\n Args:\n x_train (torch.Tensor): The input training data.\n y_train (torch.Tensor): The target training data.\n Kinv_method (str, optional): The method used for computing the inverse of the covariance matrix. \n Defaults to 'cholesky3'.\n\n Returns:\n torch.Tensor: The log-likelihood of the Gaussian process.\n\n Raises:\n ValueError: If Kinv_method is not 'direct' or 'cholesky'.\n\n \"\"\"\n K = self.kernel(x_train, x_train) + self.noise_variance.pow(2) * torch.eye(len(x_train))\n \n if Kinv_method == 'cholesky1':\n L = torch.linalg.cholesky(K)\n L_inv = torch.inverse(L)\n K_inv = L_inv.T @ L_inv\n return -0.5 * (y_train.T @ K_inv @ y_train + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky2':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * (gamma.T @ gamma + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'cholesky3':\n L = torch.linalg.cholesky(K)\n gamma = torch.cholesky_solve(y_train, L)\n return -0.5 * (gamma.T @ gamma + L.diag().log().sum() + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'direct':\n K_inv = torch.inverse(K)\n return -0.5 * (y_train.T @ K_inv @ y_train + torch.logdet(K) + len(x_train) * np.log(2 * np.pi))\n elif Kinv_method == 'torch_distribution_MN1':\n L = torch.cholesky(K)\n return torch.distributions.MultivariateNormal(y_train, scale_tril=L).log_prob(y_train)\n elif Kinv_method == 'torch_distribution_MN2':\n return torch.distributions.MultivariateNormal(y_train, K).log_prob(y_train)\n else:\n raise ValueError('Kinv_method should be either direct or cholesky')" }, { "id": 8450, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))", "probing input": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n", "probing input new": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.", "reference": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "reference dict": { "m": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "y_neg": " self.assertEqual(m.scale_tril, torch.cholesky(m.precision_matrix))", "retain": " def test_multivariate_normal_properties(self):\n loc = torch.randn(5)\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5))\n m = MultivariateNormal(loc=loc, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))" }, { "id": 8454, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_wishart_properties(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n ndim = 5\n df = torch.rand([]) + ndim - 1\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(ndim, ndim))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))", "probing input": " def test_wishart_properties(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n ndim = 5\n df = torch.rand([]) + ndim - 1\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(ndim, ndim))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n", "probing input new": " def test_wishart_properties(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n ndim = 5\n df = torch.rand([]) + ndim - 1\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(ndim, ndim))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.", "reference": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "reference dict": { "m": "Wishart" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.assertEqual(m.scale_tril,torch.linalg.cholesky(m.covariance_matrix))", "y_neg": " self.assertEqual(m.scale_tril, torch.cholesky(m.precision_matrix))", "retain": " def test_wishart_properties(self):\n set_rng_seed(0) # see Note [Randomized statistical tests]\n ndim = 5\n df = torch.rand([]) + ndim - 1\n scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(ndim, ndim))\n m = Wishart(df=df, scale_tril=scale_tril)\n self.assertEqual(m.covariance_matrix, m.scale_tril.mm(m.scale_tril.t()))\n self.assertEqual(\n m.covariance_matrix.mm(m.precision_matrix), torch.eye(m.event_shape[0])\n )\n self.assertEqual(m.scale_tril, torch.linalg.cholesky(m.covariance_matrix))" }, { "id": 8456, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _fit_params(self) -> None:\n self.mus = {}\n self.invs = {}\n self.precision_chols = {}\n device = next(self.model.parameters()).device\n for layer_name, layer_features in self.train_features.items():\n self.mus[layer_name], cov, self.invs[layer_name] = self.mu_cov_inv_est_fn(\n layer_features, self.train_targets, self.cov_mat_method, device=device\n )\n cov_chol = torch.linalg.cholesky(cov.to(device) + self.cov_reg * torch.eye(cov.shape[1], device=device))\n self.precision_chols[layer_name] = torch.linalg.solve_triangular(\n cov_chol, torch.eye(cov_chol.shape[1], device=device), upper=False\n ).T", "probing input": " def _fit_params(self) -> None:\n self.mus = {}\n self.invs = {}\n self.precision_chols = {}\n device = next(self.model.parameters()).device\n for layer_name, layer_features in self.train_features.items():\n self.mus[layer_name], cov, self.invs[layer_name] = self.mu_cov_inv_est_fn(\n layer_features, self.train_targets, self.cov_mat_method, device=device\n )\n", "probing input new": " def _fit_params(self) -> None:\n self.mus = {}\n self.invs = {}\n self.precision_chols = {}\n device = next(self.model.parameters()).device\n for layer_name, layer_features in self.train_features.items():\n self.mus[layer_name], cov, self.invs[layer_name] = self.mu_cov_inv_est_fn(\n layer_features, self.train_targets, self.cov_mat_method, device=device\n )\n cov_chol = torch.", "reference": "cov_chol=torch.linalg.cholesky(cov.to(device)+self.cov_reg*torch.eye(cov.shape[1],device=device))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "cov_chol=torch.linalg.cholesky(cov.to(device)+self.cov_reg*torch.eye(cov.shape[1],device=device))", "y_neg": " cov_chol = torch.cholesky(cov)", "retain": " def _fit_params(self) -> None:\n self.mus = {}\n self.invs = {}\n self.precision_chols = {}\n device = next(self.model.parameters()).device\n for layer_name, layer_features in self.train_features.items():\n self.mus[layer_name], cov, self.invs[layer_name] = self.mu_cov_inv_est_fn(\n layer_features, self.train_targets, self.cov_mat_method, device=device\n )\n cov_chol = torch.linalg.cholesky(cov.to(device) + self.cov_reg * torch.eye(cov.shape[1], device=device))\n self.precision_chols[layer_name] = torch.linalg.solve_triangular(\n cov_chol, torch.eye(cov_chol.shape[1], device=device), upper=False\n ).T" }, { "id": 8457, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertAlmostEqual(prior.log_prob(S), dist.log_prob(S_chol), places=4)\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n with self.assertRaises(ValueError):\n prior.log_prob(torch.eye(3, device=device))", "probing input": " def test_lkj_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n", "probing input new": " def test_lkj_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "prior": "LKJPrior", "dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertAlmostEqual(prior.log_prob(S), dist.log_prob(S_chol), places=4)\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n with self.assertRaises(ValueError):\n prior.log_prob(torch.eye(3, device=device))" }, { "id": 8458, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n with self.assertRaises(ValueError):\n prior.log_prob(torch.eye(3, device=device))", "probing input": " def test_lkj_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n", "probing input new": " def test_lkj_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "prior": "LKJPrior", "dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S), dist.log_prob(S_chol)))\n with self.assertRaises(ValueError):\n prior.log_prob(torch.eye(3, device=device))" }, { "id": 8459, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_cholesky_factor_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertAlmostEqual(prior.log_prob(S_chol), dist.log_prob(S_chol), places=4)\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S_chol.device)])\n S_chol = torch.stack([torch.linalg.cholesky(Si) for Si in S])\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))", "probing input": " def test_lkj_cholesky_factor_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n S = torch.eye(2, device=device)\n", "probing input new": " def test_lkj_cholesky_factor_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n S = torch.eye(2, device=device)\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "prior": "LKJCholeskyFactorPrior", "dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_cholesky_factor_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor(0.5, device=device))\n dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertAlmostEqual(prior.log_prob(S_chol), dist.log_prob(S_chol), places=4)\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S_chol.device)])\n S_chol = torch.stack([torch.linalg.cholesky(Si) for Si in S])\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))" }, { "id": 8460, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_cholesky_factor_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.stack([torch.linalg.cholesky(Si) for Si in S])\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))", "probing input": " def test_lkj_cholesky_factor_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n", "probing input new": " def test_lkj_cholesky_factor_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "prior": "LKJCholeskyFactorPrior", "dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_cholesky_factor_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n prior = LKJCholeskyFactorPrior(2, torch.tensor([0.5, 1.5], device=device))\n dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n S_chol = torch.linalg.cholesky(S)\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.stack([torch.linalg.cholesky(Si) for Si in S])\n self.assertTrue(approx_equal(prior.log_prob(S_chol), dist.log_prob(S_chol)))" }, { "id": 8461, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_covariance_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n sd_prior = SmoothedBoxPrior(exp(-1), exp(1))\n if cuda:\n sd_prior = sd_prior.cuda()\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n S = torch.eye(2, device=device)\n\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertTrue(approx_equal(prior.log_prob(S), dist_log_prob))", "probing input": " def test_lkj_covariance_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n sd_prior = SmoothedBoxPrior(exp(-1), exp(1))\n if cuda:\n sd_prior = sd_prior.cuda()\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n S = torch.eye(2, device=device)\n\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n", "probing input new": " def test_lkj_covariance_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n sd_prior = SmoothedBoxPrior(exp(-1), exp(1))\n if cuda:\n sd_prior = sd_prior.cuda()\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n S = torch.eye(2, device=device)\n\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "sd_prior": "SmoothedBoxPrior", "prior": "LKJCovariancePrior", "corr_dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_covariance_prior_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n sd_prior = SmoothedBoxPrior(exp(-1), exp(1))\n if cuda:\n sd_prior = sd_prior.cuda()\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n S = torch.eye(2, device=device)\n\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertTrue(approx_equal(prior.log_prob(S), dist_log_prob))" }, { "id": 8462, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_covariance_prior_log_prob_hetsd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n a = torch.tensor([exp(-1), exp(-2)], device=device)\n b = torch.tensor([exp(1), exp(2)], device=device)\n sd_prior = SmoothedBoxPrior(a, b)\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertTrue(approx_equal(prior.log_prob(S), dist_log_prob))", "probing input": " def test_lkj_covariance_prior_log_prob_hetsd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n a = torch.tensor([exp(-1), exp(-2)], device=device)\n b = torch.tensor([exp(1), exp(2)], device=device)\n sd_prior = SmoothedBoxPrior(a, b)\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n", "probing input new": " def test_lkj_covariance_prior_log_prob_hetsd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n a = torch.tensor([exp(-1), exp(-2)], device=device)\n b = torch.tensor([exp(1), exp(2)], device=device)\n sd_prior = SmoothedBoxPrior(a, b)\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "sd_prior": "SmoothedBoxPrior", "prior": "LKJCovariancePrior", "corr_dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_covariance_prior_log_prob_hetsd(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n a = torch.tensor([exp(-1), exp(-2)], device=device)\n b = torch.tensor([exp(1), exp(2)], device=device)\n sd_prior = SmoothedBoxPrior(a, b)\n prior = LKJCovariancePrior(2, torch.tensor(0.5, device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor(0.5, device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2)).sum()\n self.assertAlmostEqual(prior.log_prob(S), dist_log_prob, places=4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertTrue(approx_equal(prior.log_prob(S), dist_log_prob))" }, { "id": 8463, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lkj_covariance_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n v = torch.ones(2, 1, device=device)\n sd_prior = SmoothedBoxPrior(exp(-1) * v, exp(1) * v)\n prior = LKJCovariancePrior(2, torch.tensor([0.5, 1.5], device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)", "probing input": " def test_lkj_covariance_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n v = torch.ones(2, 1, device=device)\n sd_prior = SmoothedBoxPrior(exp(-1) * v, exp(1) * v)\n prior = LKJCovariancePrior(2, torch.tensor([0.5, 1.5], device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n", "probing input new": " def test_lkj_covariance_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n v = torch.ones(2, 1, device=device)\n sd_prior = SmoothedBoxPrior(exp(-1) * v, exp(1) * v)\n prior = LKJCovariancePrior(2, torch.tensor([0.5, 1.5], device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.", "reference": "S_chol=torch.linalg.cholesky(S)", "reference dict": { "sd_prior": "SmoothedBoxPrior", "prior": "LKJCovariancePrior", "corr_dist": "LKJCholesky" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "S_chol=torch.linalg.cholesky(S)", "y_neg": " S_chol = torch.cholesky(S)", "retain": " def test_lkj_covariance_prior_batch_log_prob(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n v = torch.ones(2, 1, device=device)\n sd_prior = SmoothedBoxPrior(exp(-1) * v, exp(1) * v)\n prior = LKJCovariancePrior(2, torch.tensor([0.5, 1.5], device=device), sd_prior)\n corr_dist = LKJCholesky(2, torch.tensor([0.5, 1.5], device=device))\n\n S = torch.eye(2, device=device)\n dist_log_prob = corr_dist.log_prob(S) + sd_prior.log_prob(S.diagonal(dim1=-1, dim2=-2))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)\n\n S = torch.stack([S, torch.tensor([[1.0, 0.5], [0.5, 1]], device=S.device)])\n S_chol = torch.linalg.cholesky(S)\n dist_log_prob = corr_dist.log_prob(S_chol) + sd_prior.log_prob(torch.diagonal(S, dim1=-2, dim2=-1))\n self.assertLessEqual((prior.log_prob(S) - dist_log_prob).abs().sum(), 1e-4)" }, { "id": 8464, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def optnet_pre_factor_kkt(Q, G, A):\n # S = [ A Q^{-1} A^T A Q^{-1} G^T ]\n # [ G Q^{-1} A^T G Q^{-1} G^T + D^{-1} ]\n # S = rbind(cbind(A_invQ_AT,A_invQ_GT),cbind(G_invQ_AT,G%*%invQ_GT +diag(n_ineq)))\n # chol(S)[1,] == U_S[1,]\n\n # --- prep:\n n_batch = Q.shape[0]\n dtype = Q.dtype\n n_eq = get_ncon(A, dim=1)\n any_eq = n_eq > 0\n n_ineq = get_ncon(G, dim=1)\n n_con = n_eq + n_ineq\n GT = torch.transpose(G, 1, 2)\n AT = torch.transpose(A, 1, 2)\n\n U_Q = torch.linalg.cholesky(Q, upper=True)\n U_S = torch.zeros((n_batch, n_con, n_con), dtype=dtype)\n\n # --- ineq:\n invQ_GT = torch.cholesky_solve(GT, U_Q, upper=True)\n R = torch.matmul(G, invQ_GT)\n\n if any_eq:\n # --- eq\n invQ_AT = torch.cholesky_solve(AT, U_Q, upper=True)\n A_invQ_AT = torch.matmul(A, invQ_AT)\n U11 = torch.linalg.cholesky(A_invQ_AT, upper=True)\n\n # --- cross product terms\n G_invQ_AT = torch.matmul(G, invQ_AT)\n U12 = torch.linalg.solve(U11, torch.transpose(G_invQ_AT, 1, 2))\n\n U1 = torch.cat((U11, U12), dim=2)\n zeros = torch.zeros((n_batch, n_ineq, n_con), dtype=dtype)\n U_S = torch.cat((U1, zeros), dim=1)\n\n R = R - torch.matmul(torch.transpose(U12, 1, 2), U12)\n\n return U_Q, U_S, R", "probing input": "def optnet_pre_factor_kkt(Q, G, A):\n # S = [ A Q^{-1} A^T A Q^{-1} G^T ]\n # [ G Q^{-1} A^T G Q^{-1} G^T + D^{-1} ]\n # S = rbind(cbind(A_invQ_AT,A_invQ_GT),cbind(G_invQ_AT,G%*%invQ_GT +diag(n_ineq)))\n # chol(S)[1,] == U_S[1,]\n\n # --- prep:\n n_batch = Q.shape[0]\n dtype = Q.dtype\n n_eq = get_ncon(A, dim=1)\n any_eq = n_eq > 0\n n_ineq = get_ncon(G, dim=1)\n n_con = n_eq + n_ineq\n GT = torch.transpose(G, 1, 2)\n AT = torch.transpose(A, 1, 2)\n\n", "probing input new": "def optnet_pre_factor_kkt(Q, G, A):\n # S = [ A Q^{-1} A^T A Q^{-1} G^T ]\n # [ G Q^{-1} A^T G Q^{-1} G^T + D^{-1} ]\n # S = rbind(cbind(A_invQ_AT,A_invQ_GT),cbind(G_invQ_AT,G%*%invQ_GT +diag(n_ineq)))\n # chol(S)[1,] == U_S[1,]\n\n # --- prep:\n n_batch = Q.shape[0]\n dtype = Q.dtype\n n_eq = get_ncon(A, dim=1)\n any_eq = n_eq > 0\n n_ineq = get_ncon(G, dim=1)\n n_con = n_eq + n_ineq\n GT = torch.transpose(G, 1, 2)\n AT = torch.transpose(A, 1, 2)\n\n U_Q = torch.", "reference": "U_Q=torch.linalg.cholesky(Q,upper=True)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "U_Q=torch.linalg.cholesky(Q,upper=True)", "y_neg": " U_Q = torch.cholesky(Q)", "retain": "def optnet_pre_factor_kkt(Q, G, A):\n # S = [ A Q^{-1} A^T A Q^{-1} G^T ]\n # [ G Q^{-1} A^T G Q^{-1} G^T + D^{-1} ]\n # S = rbind(cbind(A_invQ_AT,A_invQ_GT),cbind(G_invQ_AT,G%*%invQ_GT +diag(n_ineq)))\n # chol(S)[1,] == U_S[1,]\n\n # --- prep:\n n_batch = Q.shape[0]\n dtype = Q.dtype\n n_eq = get_ncon(A, dim=1)\n any_eq = n_eq > 0\n n_ineq = get_ncon(G, dim=1)\n n_con = n_eq + n_ineq\n GT = torch.transpose(G, 1, 2)\n AT = torch.transpose(A, 1, 2)\n\n U_Q = torch.linalg.cholesky(Q, upper=True)\n U_S = torch.zeros((n_batch, n_con, n_con), dtype=dtype)\n\n # --- ineq:\n invQ_GT = torch.cholesky_solve(GT, U_Q, upper=True)\n R = torch.matmul(G, invQ_GT)\n\n if any_eq:\n # --- eq\n invQ_AT = torch.cholesky_solve(AT, U_Q, upper=True)\n A_invQ_AT = torch.matmul(A, invQ_AT)\n U11 = torch.linalg.cholesky(A_invQ_AT, upper=True)\n\n # --- cross product terms\n G_invQ_AT = torch.matmul(G, invQ_AT)\n U12 = torch.linalg.solve(U11, torch.transpose(G_invQ_AT, 1, 2))\n\n U1 = torch.cat((U11, U12), dim=2)\n zeros = torch.zeros((n_batch, n_ineq, n_con), dtype=dtype)\n U_S = torch.cat((U1, zeros), dim=1)\n\n R = R - torch.matmul(torch.transpose(U12, 1, 2), U12)\n\n return U_Q, U_S, R" }, { "id": 8466, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, t, cov1, cov2, cov_target):\n # Compute necessities\n if t == 0.5:\n self.chol_forward = torch.linalg.cholesky(cov_target)\n elif t < 0.5:\n self.chol_a = torch.linalg.cholesky(cov1)\n self.chol_b = torch.linalg.cholesky(cov_target)\n self.chol_forward = (1.0 - 2.0 * t) * self.chol_a + 2.0 * t * self.chol_b\n else:\n self.chol_a = torch.linalg.cholesky(cov2)\n self.chol_b = torch.linalg.cholesky(cov_target)\n self.chol_forward = (2.0 * t - 1.0) * self.chol_a + 2.0 * (1.0 - t) * self.chol_b\n self.log_jac = torch.linalg.slogdet(self.chol_forward).logabsdet\n self.chol_inverse = torch.linalg.inv(self.chol_forward)", "probing input": " def __init__(self, t, cov1, cov2, cov_target):\n # Compute necessities\n if t == 0.5:\n", "probing input new": " def __init__(self, t, cov1, cov2, cov_target):\n # Compute necessities\n if t == 0.5:\n self.chol_forward = torch.", "reference": "self.chol_forward=torch.linalg.cholesky(cov_target)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "self.chol_forward=torch.linalg.cholesky(cov_target)", "y_neg": " self.chol_forward = torch.cholesky(cov1 + torch.eye(len(cov1)) * 1e-6)", "retain": " def __init__(self, t, cov1, cov2, cov_target):\n # Compute necessities\n if t == 0.5:\n self.chol_forward = torch.linalg.cholesky(cov_target)\n elif t < 0.5:\n self.chol_a = torch.linalg.cholesky(cov1)\n self.chol_b = torch.linalg.cholesky(cov_target)\n self.chol_forward = (1.0 - 2.0 * t) * self.chol_a + 2.0 * t * self.chol_b\n else:\n self.chol_a = torch.linalg.cholesky(cov2)\n self.chol_b = torch.linalg.cholesky(cov_target)\n self.chol_forward = (2.0 * t - 1.0) * self.chol_a + 2.0 * (1.0 - t) * self.chol_b\n self.log_jac = torch.linalg.slogdet(self.chol_forward).logabsdet\n self.chol_inverse = torch.linalg.inv(self.chol_forward)" }, { "id": 8468, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype))\n covmat_chol = torch.linalg.cholesky(covmat)\n mvn = MultivariateNormal(mean=mean, covariance_matrix=DenseLinearOperator(covmat))\n self.assertTrue(torch.is_tensor(mvn.covariance_matrix))\n self.assertIsInstance(mvn.lazy_covariance_matrix, LinearOperator)\n self.assertAllClose(mvn.variance, torch.diag(covmat))\n self.assertAllClose(mvn.covariance_matrix, covmat)\n self.assertAllClose(mvn._unbroadcasted_scale_tril, covmat_chol)\n mvn_plus1 = mvn + 1\n self.assertAllClose(mvn_plus1.mean, mvn.mean + 1)\n self.assertAllClose(mvn_plus1.covariance_matrix, mvn.covariance_matrix)\n self.assertAllClose(mvn_plus1._unbroadcasted_scale_tril, covmat_chol)\n mvn_times2 = mvn * 2\n self.assertAllClose(mvn_times2.mean, mvn.mean * 2)\n self.assertAllClose(mvn_times2.covariance_matrix, mvn.covariance_matrix * 4)\n self.assertAllClose(mvn_times2._unbroadcasted_scale_tril, covmat_chol * 2)\n mvn_divby2 = mvn / 2\n self.assertAllClose(mvn_divby2.mean, mvn.mean / 2)\n self.assertAllClose(mvn_divby2.covariance_matrix, mvn.covariance_matrix / 4)\n self.assertAllClose(mvn_divby2._unbroadcasted_scale_tril, covmat_chol / 2)\n # TODO: Add tests for entropy, log_prob, etc. - this an issue b/c it\n # uses using root_decomposition which is not very reliable\n # self.assertAlmostEqual(mvn.entropy().item(), 4.3157, places=4)\n # self.assertAlmostEqual(mvn.log_prob(torch.zeros(3)).item(), -4.8157, places=4)\n # self.assertTrue(\n # torch.allclose(\n # mvn.log_prob(torch.zeros(2, 3)), -4.8157 * torch.ones(2))\n # )\n # )\n conf_lower, conf_upper = mvn.confidence_region()\n self.assertAllClose(conf_lower, mvn.mean - 2 * mvn.stddev)\n self.assertAllClose(conf_upper, mvn.mean + 2 * mvn.stddev)\n self.assertTrue(mvn.sample().shape == torch.Size([3]))\n self.assertTrue(mvn.sample(torch.Size([2])).shape == torch.Size([2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2, 4])).shape == torch.Size([2, 4, 3]))", "probing input": " def test_multivariate_normal_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype))\n", "probing input new": " def test_multivariate_normal_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype))\n covmat_chol = torch.", "reference": "covmat_chol=torch.linalg.cholesky(covmat)", "reference dict": { "mvn": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "covmat_chol=torch.linalg.cholesky(covmat)", "y_neg": " covmat_chol = torch.cholesky(covmat)", "retain": " def test_multivariate_normal_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype))\n covmat_chol = torch.linalg.cholesky(covmat)\n mvn = MultivariateNormal(mean=mean, covariance_matrix=DenseLinearOperator(covmat))\n self.assertTrue(torch.is_tensor(mvn.covariance_matrix))\n self.assertIsInstance(mvn.lazy_covariance_matrix, LinearOperator)\n self.assertAllClose(mvn.variance, torch.diag(covmat))\n self.assertAllClose(mvn.covariance_matrix, covmat)\n self.assertAllClose(mvn._unbroadcasted_scale_tril, covmat_chol)\n mvn_plus1 = mvn + 1\n self.assertAllClose(mvn_plus1.mean, mvn.mean + 1)\n self.assertAllClose(mvn_plus1.covariance_matrix, mvn.covariance_matrix)\n self.assertAllClose(mvn_plus1._unbroadcasted_scale_tril, covmat_chol)\n mvn_times2 = mvn * 2\n self.assertAllClose(mvn_times2.mean, mvn.mean * 2)\n self.assertAllClose(mvn_times2.covariance_matrix, mvn.covariance_matrix * 4)\n self.assertAllClose(mvn_times2._unbroadcasted_scale_tril, covmat_chol * 2)\n mvn_divby2 = mvn / 2\n self.assertAllClose(mvn_divby2.mean, mvn.mean / 2)\n self.assertAllClose(mvn_divby2.covariance_matrix, mvn.covariance_matrix / 4)\n self.assertAllClose(mvn_divby2._unbroadcasted_scale_tril, covmat_chol / 2)\n # TODO: Add tests for entropy, log_prob, etc. - this an issue b/c it\n # uses using root_decomposition which is not very reliable\n # self.assertAlmostEqual(mvn.entropy().item(), 4.3157, places=4)\n # self.assertAlmostEqual(mvn.log_prob(torch.zeros(3)).item(), -4.8157, places=4)\n # self.assertTrue(\n # torch.allclose(\n # mvn.log_prob(torch.zeros(2, 3)), -4.8157 * torch.ones(2))\n # )\n # )\n conf_lower, conf_upper = mvn.confidence_region()\n self.assertAllClose(conf_lower, mvn.mean - 2 * mvn.stddev)\n self.assertAllClose(conf_upper, mvn.mean + 2 * mvn.stddev)\n self.assertTrue(mvn.sample().shape == torch.Size([3]))\n self.assertTrue(mvn.sample(torch.Size([2])).shape == torch.Size([2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2, 4])).shape == torch.Size([2, 4, 3]))" }, { "id": 8469, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_multivariate_normal_batch_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype).repeat(2, 1)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype)).repeat(2, 1, 1)\n covmat_chol = torch.linalg.cholesky(covmat)\n mvn = MultivariateNormal(mean=mean, covariance_matrix=DenseLinearOperator(covmat))\n self.assertTrue(torch.is_tensor(mvn.covariance_matrix))\n self.assertIsInstance(mvn.lazy_covariance_matrix, LinearOperator)\n self.assertAllClose(mvn.variance, torch.diagonal(covmat, dim1=-2, dim2=-1))\n self.assertAllClose(mvn._unbroadcasted_scale_tril, covmat_chol)\n mvn_plus1 = mvn + 1\n self.assertAllClose(mvn_plus1.mean, mvn.mean + 1)\n self.assertAllClose(mvn_plus1.covariance_matrix, mvn.covariance_matrix)\n self.assertAllClose(mvn_plus1._unbroadcasted_scale_tril, covmat_chol)\n mvn_times2 = mvn * 2\n self.assertAllClose(mvn_times2.mean, mvn.mean * 2)\n self.assertAllClose(mvn_times2.covariance_matrix, mvn.covariance_matrix * 4)\n self.assertAllClose(mvn_times2._unbroadcasted_scale_tril, covmat_chol * 2)\n mvn_divby2 = mvn / 2\n self.assertAllClose(mvn_divby2.mean, mvn.mean / 2)\n self.assertAllClose(mvn_divby2.covariance_matrix, mvn.covariance_matrix / 4)\n self.assertAllClose(mvn_divby2._unbroadcasted_scale_tril, covmat_chol / 2)\n # TODO: Add tests for entropy, log_prob, etc. - this an issue b/c it\n # uses using root_decomposition which is not very reliable\n # self.assertTrue(torch.allclose(mvn.entropy(), 4.3157 * torch.ones(2)))\n # self.assertTrue(\n # torch.allclose(mvn.log_prob(torch.zeros(2, 3)), -4.8157 * torch.ones(2))\n # )\n # self.assertTrue(\n # torch.allclose(mvn.log_prob(torch.zeros(2, 2, 3)), -4.8157 * torch.ones(2, 2))\n # )\n conf_lower, conf_upper = mvn.confidence_region()\n self.assertAllClose(conf_lower, mvn.mean - 2 * mvn.stddev)\n self.assertAllClose(conf_upper, mvn.mean + 2 * mvn.stddev)\n self.assertTrue(mvn.sample().shape == torch.Size([2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2])).shape == torch.Size([2, 2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2, 4])).shape == torch.Size([2, 4, 2, 3]))", "probing input": " def test_multivariate_normal_batch_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype).repeat(2, 1)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype)).repeat(2, 1, 1)\n", "probing input new": " def test_multivariate_normal_batch_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype).repeat(2, 1)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype)).repeat(2, 1, 1)\n covmat_chol = torch.", "reference": "covmat_chol=torch.linalg.cholesky(covmat)", "reference dict": { "mvn": "MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "covmat_chol=torch.linalg.cholesky(covmat)", "y_neg": " covmat_chol = torch.cholesky(covmat)", "retain": " def test_multivariate_normal_batch_lazy(self, cuda=False):\n device = torch.device(\"cuda\") if cuda else torch.device(\"cpu\")\n for dtype in (torch.float, torch.double):\n mean = torch.tensor([0, 1, 2], device=device, dtype=dtype).repeat(2, 1)\n covmat = torch.diag(torch.tensor([1, 0.75, 1.5], device=device, dtype=dtype)).repeat(2, 1, 1)\n covmat_chol = torch.linalg.cholesky(covmat)\n mvn = MultivariateNormal(mean=mean, covariance_matrix=DenseLinearOperator(covmat))\n self.assertTrue(torch.is_tensor(mvn.covariance_matrix))\n self.assertIsInstance(mvn.lazy_covariance_matrix, LinearOperator)\n self.assertAllClose(mvn.variance, torch.diagonal(covmat, dim1=-2, dim2=-1))\n self.assertAllClose(mvn._unbroadcasted_scale_tril, covmat_chol)\n mvn_plus1 = mvn + 1\n self.assertAllClose(mvn_plus1.mean, mvn.mean + 1)\n self.assertAllClose(mvn_plus1.covariance_matrix, mvn.covariance_matrix)\n self.assertAllClose(mvn_plus1._unbroadcasted_scale_tril, covmat_chol)\n mvn_times2 = mvn * 2\n self.assertAllClose(mvn_times2.mean, mvn.mean * 2)\n self.assertAllClose(mvn_times2.covariance_matrix, mvn.covariance_matrix * 4)\n self.assertAllClose(mvn_times2._unbroadcasted_scale_tril, covmat_chol * 2)\n mvn_divby2 = mvn / 2\n self.assertAllClose(mvn_divby2.mean, mvn.mean / 2)\n self.assertAllClose(mvn_divby2.covariance_matrix, mvn.covariance_matrix / 4)\n self.assertAllClose(mvn_divby2._unbroadcasted_scale_tril, covmat_chol / 2)\n # TODO: Add tests for entropy, log_prob, etc. - this an issue b/c it\n # uses using root_decomposition which is not very reliable\n # self.assertTrue(torch.allclose(mvn.entropy(), 4.3157 * torch.ones(2)))\n # self.assertTrue(\n # torch.allclose(mvn.log_prob(torch.zeros(2, 3)), -4.8157 * torch.ones(2))\n # )\n # self.assertTrue(\n # torch.allclose(mvn.log_prob(torch.zeros(2, 2, 3)), -4.8157 * torch.ones(2, 2))\n # )\n conf_lower, conf_upper = mvn.confidence_region()\n self.assertAllClose(conf_lower, mvn.mean - 2 * mvn.stddev)\n self.assertAllClose(conf_upper, mvn.mean + 2 * mvn.stddev)\n self.assertTrue(mvn.sample().shape == torch.Size([2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2])).shape == torch.Size([2, 2, 3]))\n self.assertTrue(mvn.sample(torch.Size([2, 4])).shape == torch.Size([2, 4, 2, 3]))" }, { "id": 8470, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_pyro_catch_error(self) -> None:\n def potential_fn(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n # pyre-fixme[16]: Module `distributions` has no attribute\n # `MultivariateNormal`.\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.allclose(grads[\"K\"], -0.5 * torch.eye(2)))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertTrue(torch.allclose(val, 2 * norm_mvn.log_prob(torch.zeros(1))))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n return torch.linalg.cholesky(z[\"K\"])\n\n _, val = potential_grad(potential_fn_chol, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should not catch other errors\n def potential_fn_rterr_foo(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n raise RuntimeError(\"foo\")\n\n with self.assertRaisesRegex(RuntimeError, \"foo\"):\n potential_grad(potential_fn_rterr_foo, z)", "probing input": " def test_pyro_catch_error(self) -> None:\n def potential_fn(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n # pyre-fixme[16]: Module `distributions` has no attribute\n # `MultivariateNormal`.\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.allclose(grads[\"K\"], -0.5 * torch.eye(2)))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertTrue(torch.allclose(val, 2 * norm_mvn.log_prob(torch.zeros(1))))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n", "probing input new": " def test_pyro_catch_error(self) -> None:\n def potential_fn(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n # pyre-fixme[16]: Module `distributions` has no attribute\n # `MultivariateNormal`.\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.allclose(grads[\"K\"], -0.5 * torch.eye(2)))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertTrue(torch.allclose(val, 2 * norm_mvn.log_prob(torch.zeros(1))))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n return torch.", "reference": "returntorch.linalg.cholesky(z[\"K\"])", "reference dict": { "norm_mvn": "torch.distributions.Normal", "mvn": "pyro.distributions.MultivariateNormal" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "returntorch.linalg.cholesky(z[\"K\"])", "y_neg": " return torch.cholesky(z[\"K\"]).solve(torch.zeros(2))", "retain": " def test_pyro_catch_error(self) -> None:\n def potential_fn(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n # pyre-fixme[16]: Module `distributions` has no attribute\n # `MultivariateNormal`.\n mvn = pyro.distributions.MultivariateNormal(\n loc=torch.zeros(2),\n covariance_matrix=z[\"K\"],\n )\n return mvn.log_prob(torch.zeros(2))\n\n # Test base case where everything is fine\n z = {\"K\": torch.eye(2)}\n grads, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.allclose(grads[\"K\"], -0.5 * torch.eye(2)))\n norm_mvn = torch.distributions.Normal(0, 1)\n self.assertTrue(torch.allclose(val, 2 * norm_mvn.log_prob(torch.zeros(1))))\n\n # Default behavior should catch the ValueError when trying to instantiate\n # the MVN and return NaN instead\n z = {\"K\": torch.ones(2, 2)}\n _, val = potential_grad(potential_fn, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should catch the LinAlgError when peforming a\n # Cholesky decomposition and return NaN instead\n def potential_fn_chol(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n return torch.linalg.cholesky(z[\"K\"])\n\n _, val = potential_grad(potential_fn_chol, z)\n self.assertTrue(torch.isnan(val))\n\n # Default behavior should not catch other errors\n def potential_fn_rterr_foo(z: Dict[str, torch.Tensor]) -> torch.Tensor:\n raise RuntimeError(\"foo\")\n\n with self.assertRaisesRegex(RuntimeError, \"foo\"):\n potential_grad(potential_fn_rterr_foo, z)" }, { "id": 8472, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, H, b):\n \"\"\"\n :param ctx:\n :param H: [b, f, 6, 6]\n :param b: [b, f, 6]\n :return:\n \"\"\"\n chol = torch.linalg.cholesky(H)\n xx = torch.cholesky_solve(b, chol)\n ctx.save_for_backward(chol, xx)\n return xx", "probing input": " def forward(ctx, H, b):\n \"\"\"\n :param ctx:\n :param H: [b, f, 6, 6]\n :param b: [b, f, 6]\n :return:\n \"\"\"\n", "probing input new": " def forward(ctx, H, b):\n \"\"\"\n :param ctx:\n :param H: [b, f, 6, 6]\n :param b: [b, f, 6]\n :return:\n \"\"\"\n chol = torch.", "reference": "chol=torch.linalg.cholesky(H)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(H)", "y_neg": " chol = torch.cholesky(H)", "retain": " def forward(ctx, H, b):\n \"\"\"\n :param ctx:\n :param H: [b, f, 6, 6]\n :param b: [b, f, 6]\n :return:\n \"\"\"\n chol = torch.linalg.cholesky(H)\n xx = torch.cholesky_solve(b, chol)\n ctx.save_for_backward(chol, xx)\n return xx" }, { "id": 8478, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=5,\n max_tridiag_iter=10,\n max_iter=size,\n tolerance=0,\n eps=1e-15,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n eigs = torch.linalg.eigvalsh(matrix)\n for i in range(5):\n approx_eigs = torch.linalg.eigvalsh(t_mats[i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))", "probing input": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=5,\n max_tridiag_iter=10,\n max_iter=size,\n tolerance=0,\n eps=1e-15,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n", "probing input new": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=5,\n max_tridiag_iter=10,\n max_iter=size,\n tolerance=0,\n eps=1e-15,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix, upper=True)", "retain": " def test_cg_with_tridiag(self):\n size = 10\n matrix = torch.randn(size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(size, 50, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=5,\n max_tridiag_iter=10,\n max_iter=size,\n tolerance=0,\n eps=1e-15,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n eigs = torch.linalg.eigvalsh(matrix)\n for i in range(5):\n approx_eigs = torch.linalg.eigvalsh(t_mats[i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))" }, { "id": 8479, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=8,\n max_iter=size,\n max_tridiag_iter=10,\n tolerance=0,\n eps=1e-30,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n for i in range(5):\n eigs = torch.linalg.eigvalsh(matrix[i])\n for j in range(8):\n approx_eigs = torch.linalg.eigvalsh(t_mats[j, i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))", "probing input": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=8,\n max_iter=size,\n max_tridiag_iter=10,\n tolerance=0,\n eps=1e-30,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n", "probing input new": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=8,\n max_iter=size,\n max_tridiag_iter=10,\n tolerance=0,\n eps=1e-30,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.", "reference": "matrix_chol=torch.linalg.cholesky(matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "matrix_chol=torch.linalg.cholesky(matrix)", "y_neg": " matrix_chol = torch.cholesky(matrix, upper=True)", "retain": " def test_batch_cg_with_tridiag(self):\n batch = 5\n size = 10\n matrix = torch.randn(batch, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(matrix.size(-1), dtype=torch.float64).mul_(1e-1))\n\n rhs = torch.randn(batch, size, 10, dtype=torch.float64)\n with warnings.catch_warnings(record=True) as ws:\n solves, t_mats = linear_cg(\n matrix.matmul,\n rhs=rhs,\n n_tridiag=8,\n max_iter=size,\n max_tridiag_iter=10,\n tolerance=0,\n eps=1e-30,\n )\n self.assertTrue(any(issubclass(w.category, NumericalWarning) for w in ws))\n\n # Check cg\n matrix_chol = torch.linalg.cholesky(matrix)\n actual = torch.cholesky_solve(rhs, matrix_chol)\n self.assertTrue(torch.allclose(solves, actual, atol=1e-3, rtol=1e-4))\n\n # Check tridiag\n for i in range(5):\n eigs = torch.linalg.eigvalsh(matrix[i])\n for j in range(8):\n approx_eigs = torch.linalg.eigvalsh(t_mats[j, i])\n self.assertTrue(torch.allclose(eigs, approx_eigs, atol=1e-3, rtol=1e-4))" }, { "id": 8481, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def marginal_log_likelihood(\n X: torch.Tensor, # [len(trials), len(params)]\n Y: torch.Tensor, # [len(trials)]\n is_categorical: torch.Tensor, # [len(params)]\n kernel_params: KernelParamsTensor,\n) -> torch.Tensor: # Scalar\n # -0.5 * log((2pi)^n |C|) - 0.5 * Y^T C^-1 Y, where C^-1 = cov_Y_Y_inv\n # We apply the cholesky decomposition to efficiently compute log(|C|) and C^-1.\n\n cov_fX_fX = kernel(is_categorical, kernel_params, X, X)\n\n cov_Y_Y_chol = torch.linalg.cholesky(\n cov_fX_fX + kernel_params.noise_var * torch.eye(X.shape[0], dtype=torch.float64)\n )\n # log |L| = 0.5 * log|L^T L| = 0.5 * log|C|\n logdet = 2 * torch.log(torch.diag(cov_Y_Y_chol)).sum()\n # cov_Y_Y_chol @ cov_Y_Y_chol_inv_Y = Y --> cov_Y_Y_chol_inv_Y = inv(cov_Y_Y_chol) @ Y\n cov_Y_Y_chol_inv_Y = torch.linalg.solve_triangular(cov_Y_Y_chol, Y[:, None], upper=False)[:, 0]\n return -0.5 * (\n logdet\n + X.shape[0] * math.log(2 * math.pi)\n # Y^T C^-1 Y = Y^T inv(L^T L) Y --> cov_Y_Y_chol_inv_Y @ cov_Y_Y_chol_inv_Y\n + (cov_Y_Y_chol_inv_Y @ cov_Y_Y_chol_inv_Y)\n )", "probing input": "def marginal_log_likelihood(\n X: torch.Tensor, # [len(trials), len(params)]\n Y: torch.Tensor, # [len(trials)]\n is_categorical: torch.Tensor, # [len(params)]\n kernel_params: KernelParamsTensor,\n) -> torch.Tensor: # Scalar\n # -0.5 * log((2pi)^n |C|) - 0.5 * Y^T C^-1 Y, where C^-1 = cov_Y_Y_inv\n # We apply the cholesky decomposition to efficiently compute log(|C|) and C^-1.\n\n cov_fX_fX = kernel(is_categorical, kernel_params, X, X)\n\n", "probing input new": "def marginal_log_likelihood(\n X: torch.Tensor, # [len(trials), len(params)]\n Y: torch.Tensor, # [len(trials)]\n is_categorical: torch.Tensor, # [len(params)]\n kernel_params: KernelParamsTensor,\n) -> torch.Tensor: # Scalar\n # -0.5 * log((2pi)^n |C|) - 0.5 * Y^T C^-1 Y, where C^-1 = cov_Y_Y_inv\n # We apply the cholesky decomposition to efficiently compute log(|C|) and C^-1.\n\n cov_fX_fX = kernel(is_categorical, kernel_params, X, X)\n\n cov_Y_Y_chol = torch.", "reference": "cov_Y_Y_chol=torch.linalg.cholesky(cov_fX_fX+kernel_params.noise_var*torch.eye(X.shape[0],dtype=torch.float64))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "cov_Y_Y_chol=torch.linalg.cholesky(cov_fX_fX+kernel_params.noise_var*torch.eye(X.shape[0],dtype=torch.float64))", "y_neg": " cov_Y_Y_chol = torch.cholesky(cov_fX_fX)", "retain": "def marginal_log_likelihood(\n X: torch.Tensor, # [len(trials), len(params)]\n Y: torch.Tensor, # [len(trials)]\n is_categorical: torch.Tensor, # [len(params)]\n kernel_params: KernelParamsTensor,\n) -> torch.Tensor: # Scalar\n # -0.5 * log((2pi)^n |C|) - 0.5 * Y^T C^-1 Y, where C^-1 = cov_Y_Y_inv\n # We apply the cholesky decomposition to efficiently compute log(|C|) and C^-1.\n\n cov_fX_fX = kernel(is_categorical, kernel_params, X, X)\n\n cov_Y_Y_chol = torch.linalg.cholesky(\n cov_fX_fX + kernel_params.noise_var * torch.eye(X.shape[0], dtype=torch.float64)\n )\n # log |L| = 0.5 * log|L^T L| = 0.5 * log|C|\n logdet = 2 * torch.log(torch.diag(cov_Y_Y_chol)).sum()\n # cov_Y_Y_chol @ cov_Y_Y_chol_inv_Y = Y --> cov_Y_Y_chol_inv_Y = inv(cov_Y_Y_chol) @ Y\n cov_Y_Y_chol_inv_Y = torch.linalg.solve_triangular(cov_Y_Y_chol, Y[:, None], upper=False)[:, 0]\n return -0.5 * (\n logdet\n + X.shape[0] * math.log(2 * math.pi)\n # Y^T C^-1 Y = Y^T inv(L^T L) Y --> cov_Y_Y_chol_inv_Y @ cov_Y_Y_chol_inv_Y\n + (cov_Y_Y_chol_inv_Y @ cov_Y_Y_chol_inv_Y)\n )" }, { "id": 8482, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_loss(self, inputs, outputs):\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n _noise = self._get_noise_according_exp_format()\n x = inputs[0]\n y = outputs[0]\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n sigma = self.kernel_list[0](x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(sigma)\n y_num, y_dimension = y.shape\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll", "probing input": " def compute_loss(self, inputs, outputs):\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n _noise = self._get_noise_according_exp_format()\n x = inputs[0]\n y = outputs[0]\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n sigma = self.kernel_list[0](x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n\n", "probing input new": " def compute_loss(self, inputs, outputs):\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n _noise = self._get_noise_according_exp_format()\n x = inputs[0]\n y = outputs[0]\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n sigma = self.kernel_list[0](x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.", "reference": "L=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "L=torch.linalg.cholesky(sigma)", "y_neg": " L = torch.cholesky(sigma)", "retain": " def compute_loss(self, inputs, outputs):\n self.inputs_tr = inputs\n self.outputs_tr = outputs\n self.already_set_train_data = True\n\n _noise = self._get_noise_according_exp_format()\n x = inputs[0]\n y = outputs[0]\n l1, h1, l2, h2 = self.l1, self.h1, self.l2, self.h2\n\n sigma = self.kernel_list[0](x, x, l1, h1, l2, h2) + _noise.pow(-1) * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n sigma = sigma + JITTER * torch.eye(x.size(0), device=list(self.parameters())[0].device)\n\n L = torch.linalg.cholesky(sigma)\n y_num, y_dimension = y.shape\n Gamma,_ = torch.triangular_solve(y, L, upper = False)\n nll = 0.5 * (Gamma ** 2).sum() + L.diag().log().sum() * y_dimension \\\n + 0.5 * y_num * torch.log(2 * torch.tensor(PI)) * y_dimension\n\n return nll" }, { "id": 8485, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter # add jitter to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n zero_loc = self.X.new_zeros(self.f_loc.shape)\n if self.whiten:\n identity = eye_like(self.X, N)\n pyro.sample(\n self._pyro_get_fullname(\"f\"),\n dist.MultivariateNormal(zero_loc, scale_tril=identity).to_event(\n zero_loc.dim() - 1\n ),\n )\n f_scale_tril = Lff.matmul(self.f_scale_tril)\n f_loc = Lff.matmul(self.f_loc.unsqueeze(-1)).squeeze(-1)\n else:\n pyro.sample(\n self._pyro_get_fullname(\"f\"),\n dist.MultivariateNormal(zero_loc, scale_tril=Lff).to_event(\n zero_loc.dim() - 1\n ),\n )\n f_scale_tril = self.f_scale_tril\n f_loc = self.f_loc\n\n f_loc = f_loc + self.mean_function(self.X)\n f_var = f_scale_tril.pow(2).sum(dim=-1)\n if self.y is None:\n return f_loc, f_var\n else:\n return self.likelihood(f_loc, f_var, self.y)", "probing input": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter # add jitter to the diagonal\n", "probing input new": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter # add jitter to the diagonal\n Lff = torch.", "reference": "Lff=torch.linalg.cholesky(Kff)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "Lff=torch.linalg.cholesky(Kff)", "y_neg": " Lff = torch.cholesky(Kff)", "retain": " def model(self):\n self.set_mode(\"model\")\n\n N = self.X.size(0)\n Kff = self.kernel(self.X).contiguous()\n Kff.view(-1)[:: N + 1] += self.jitter # add jitter to the diagonal\n Lff = torch.linalg.cholesky(Kff)\n\n zero_loc = self.X.new_zeros(self.f_loc.shape)\n if self.whiten:\n identity = eye_like(self.X, N)\n pyro.sample(\n self._pyro_get_fullname(\"f\"),\n dist.MultivariateNormal(zero_loc, scale_tril=identity).to_event(\n zero_loc.dim() - 1\n ),\n )\n f_scale_tril = Lff.matmul(self.f_scale_tril)\n f_loc = Lff.matmul(self.f_loc.unsqueeze(-1)).squeeze(-1)\n else:\n pyro.sample(\n self._pyro_get_fullname(\"f\"),\n dist.MultivariateNormal(zero_loc, scale_tril=Lff).to_event(\n zero_loc.dim() - 1\n ),\n )\n f_scale_tril = self.f_scale_tril\n f_loc = self.f_loc\n\n f_loc = f_loc + self.mean_function(self.X)\n f_var = f_scale_tril.pow(2).sum(dim=-1)\n if self.y is None:\n return f_loc, f_var\n else:\n return self.likelihood(f_loc, f_var, self.y)" }, { "id": 8487, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def log_likelihood(x, mu, sigma, pi):\n\n chol = torch.linalg.cholesky(sigma) # [nk, nc, nc]\n log_det = chol.diagonal(0, -1, -2).log().sum(-1).mul(2) # [nk]\n chol = chol.inverse()\n\n z = (x - mu[:, :, None]) # [nk, nc, nv]\n z = z.movedim(-1, 0).unsqueeze(-1) # [nv, nk, nc, 1]\n z = torch.matmul(chol, z) # [nv, nk, nc, 1]\n z = z.squeeze(-1).square_().sum(-1) # [nv, nk]\n z += log_det\n z *= -0.5\n z += pi.log()\n z = z.T # [nk, nv]\n\n return z", "probing input": "def log_likelihood(x, mu, sigma, pi):\n\n", "probing input new": "def log_likelihood(x, mu, sigma, pi):\n\n chol = torch.", "reference": "chol=torch.linalg.cholesky(sigma)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.cholesky" ], "replacement api": "torch.linalg.cholesky", "expected call": "torch.linalg.cholesky", "y_pos": "chol=torch.linalg.cholesky(sigma)", "y_neg": " chol = torch.cholesky(sigma)", "retain": "def log_likelihood(x, mu, sigma, pi):\n\n chol = torch.linalg.cholesky(sigma) # [nk, nc, nc]\n log_det = chol.diagonal(0, -1, -2).log().sum(-1).mul(2) # [nk]\n chol = chol.inverse()\n\n z = (x - mu[:, :, None]) # [nk, nc, nv]\n z = z.movedim(-1, 0).unsqueeze(-1) # [nv, nk, nc, 1]\n z = torch.matmul(chol, z) # [nv, nk, nc, 1]\n z = z.squeeze(-1).square_().sum(-1) # [nv, nk]\n z += log_det\n z *= -0.5\n z += pi.log()\n z = z.T # [nk, nv]\n\n return z" }, { "id": 8492, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n if is_torch_1_8_plus:\n return torch.linalg.solve(a, b)\n else:\n return torch.solve(b, a)[0]", "probing input": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n", "probing input new": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.", "reference": "returntorch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(a,b)", "y_neg": " return torch.solve(b, a)", "retain": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n if is_torch_1_8_plus:\n return torch.linalg.solve(a, b)\n else:\n return torch.solve(b, a)[0]" }, { "id": 8499, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _linear_solve(self, jac, residual):\n return torch.linalg.solve(jac, residual)", "probing input": " def _linear_solve(self, jac, residual):\n", "probing input new": " def _linear_solve(self, jac, residual):\n return torch.", "reference": "returntorch.linalg.solve(jac,residual)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "multi_dot": "torch.linalg.multi_dot" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(jac,residual)", "y_neg": " return torch.solve(jac, residual)[0]", "retain": " def _linear_solve(self, jac, residual):\n return torch.linalg.solve(jac, residual)" }, { "id": 8525, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_solve_batched_non_contiguous(self, device, dtype):\n from torch.testing._internal.common_utils import random_fullrank_matrix_distinct_singular_value\n A = random_fullrank_matrix_distinct_singular_value(2, 2, dtype=dtype).to(device).permute(1, 0, 2)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(A.is_contiguous())\n self.assertFalse(b.is_contiguous())\n actual = torch.linalg.solve(A, b)\n expected = np.linalg.solve(A.cpu().numpy(), b.cpu().numpy())\n self.assertEqual(actual, expected)", "probing input": " def test_solve_batched_non_contiguous(self, device, dtype):\n from torch.testing._internal.common_utils import random_fullrank_matrix_distinct_singular_value\n A = random_fullrank_matrix_distinct_singular_value(2, 2, dtype=dtype).to(device).permute(1, 0, 2)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(A.is_contiguous())\n self.assertFalse(b.is_contiguous())\n", "probing input new": " def test_solve_batched_non_contiguous(self, device, dtype):\n from torch.testing._internal.common_utils import random_fullrank_matrix_distinct_singular_value\n A = random_fullrank_matrix_distinct_singular_value(2, 2, dtype=dtype).to(device).permute(1, 0, 2)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(A.is_contiguous())\n self.assertFalse(b.is_contiguous())\n actual = torch.", "reference": "actual=torch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "actual=torch.linalg.solve(A,b)", "y_neg": " actual = torch.solve(A, b)", "retain": " def test_solve_batched_non_contiguous(self, device, dtype):\n from torch.testing._internal.common_utils import random_fullrank_matrix_distinct_singular_value\n A = random_fullrank_matrix_distinct_singular_value(2, 2, dtype=dtype).to(device).permute(1, 0, 2)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(A.is_contiguous())\n self.assertFalse(b.is_contiguous())\n actual = torch.linalg.solve(A, b)\n expected = np.linalg.solve(A.cpu().numpy(), b.cpu().numpy())\n self.assertEqual(actual, expected)" }, { "id": 8526, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_solve_errors(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # solve expects compatible shapes for A x = b\n with self.assertRaisesRegex(RuntimeError, \"Incompatible matrix sizes\"):\n a = torch.randn(2, 3, 3, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 2, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # if input is not solvable, RuntimeError is raised mentioning the first non-solvable batch\n def run_test_singular_input(batch_dim, n):\n a = torch.eye(3, 3, dtype=dtype, device=device).reshape((1, 3, 3)).repeat(batch_dim, 1, 1)\n a[n, -1, -1] = 0\n b = torch.randn(batch_dim, 3, 1, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, rf'For batch {n}: U\\(3,3\\) is zero'):\n torch.linalg.solve(a, b)\n\n for params in [(1, 0), (2, 0), (2, 1), (4, 0), (4, 2), (10, 2)]:\n run_test_singular_input(*params)\n\n # if out is non-empty then it should have correct sizes\n with self.assertRaisesRegex(RuntimeError, r'does not match broadcasted other shape'):\n out = torch.empty(1, dtype=dtype, device=device)\n A = torch.eye(3, dtype=dtype, device=device)\n b = torch.randn(3, 1, dtype=dtype, device=device)\n torch.linalg.solve(A, b, out=out)\n\n # if out is non-empty then it should also be Fortran contiguous\n with self.assertRaisesRegex(RuntimeError, r'tensor must be in batched column major'):\n out = torch.zeros(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(out.is_contiguous())\n A = torch.eye(2, dtype=dtype, device=device).reshape((1, 2, 2)).repeat(2, 1, 1)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device)\n torch.linalg.solve(A, b, out=out)", "probing input": " def test_solve_errors(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n", "probing input new": " def test_solve_errors(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.", "reference": "torch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "torch.linalg.solve(a,b)", "y_neg": " torch.solve(a, b)", "retain": " def test_solve_errors(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # solve expects compatible shapes for A x = b\n with self.assertRaisesRegex(RuntimeError, \"Incompatible matrix sizes\"):\n a = torch.randn(2, 3, 3, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 2, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # if input is not solvable, RuntimeError is raised mentioning the first non-solvable batch\n def run_test_singular_input(batch_dim, n):\n a = torch.eye(3, 3, dtype=dtype, device=device).reshape((1, 3, 3)).repeat(batch_dim, 1, 1)\n a[n, -1, -1] = 0\n b = torch.randn(batch_dim, 3, 1, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, rf'For batch {n}: U\\(3,3\\) is zero'):\n torch.linalg.solve(a, b)\n\n for params in [(1, 0), (2, 0), (2, 1), (4, 0), (4, 2), (10, 2)]:\n run_test_singular_input(*params)\n\n # if out is non-empty then it should have correct sizes\n with self.assertRaisesRegex(RuntimeError, r'does not match broadcasted other shape'):\n out = torch.empty(1, dtype=dtype, device=device)\n A = torch.eye(3, dtype=dtype, device=device)\n b = torch.randn(3, 1, dtype=dtype, device=device)\n torch.linalg.solve(A, b, out=out)\n\n # if out is non-empty then it should also be Fortran contiguous\n with self.assertRaisesRegex(RuntimeError, r'tensor must be in batched column major'):\n out = torch.zeros(2, 2, 2, dtype=dtype, device=device).permute(2, 1, 0)\n self.assertFalse(out.is_contiguous())\n A = torch.eye(2, dtype=dtype, device=device).reshape((1, 2, 2)).repeat(2, 1, 1)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device)\n torch.linalg.solve(A, b, out=out)" }, { "id": 8529, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def LM_opt(self, R_init):\n #Set current rotation based on initialisation conditions\n R_opt = R_init\n\n #Calculate intial total loss (sum of square errors, f(R)^t @ f(R)) and cost function values \n loss, fR = self.cost_func(R_opt)\n\n #Calculate jacobian of d(f(R)) / d(delta(phi))\n J = self.jacobian_func(R_opt)\n \n #Get hessian matrix, J^t @ J \n hess = J.t() @ J\n #Get gradient vector, J^t @ cost\n grad = J.t() @ fR\n\n #Set initial damping scaling\n u = self.tau * torch.max(hess.diag())\n\n #Optimisation loop\n for iter in range(self.max_iters-1):\n #Set damping based on current Hessian max value\n D = torch.eye(J.shape[1], device=J.device)\n D *= torch.max(torch.max(hess.diagonal(), D.diagonal()))\n\n #Scale damping\n damping = u*D\n \n #Solve Ax=b, (J^t@J + damping*I) = J^t@f(R)\n delta = -torch.linalg.solve((hess + damping), grad)\n \n #Calculate SO(3) delta rotation to apply to current estimate\n R_delta = self.so3exp(delta)\n R_step = R_delta @ R_opt\n\n #Get new cost values and loss for the new rotation \n loss_step, f_step = self.cost_func(R_step)\n \n #Setting previous to current for the next iteration\n fR_prev = fR.clone()\n \n #Work out LM rho value to determine if we accept or reject this new rotation\n rho_denom = delta.t() @ (u*delta-grad)\n rho_nom = loss - loss_step\n rho = rho_nom / rho_denom if rho_denom > 0 else torch.inf if rho_nom > 0 else -torch.inf\n\n #If happy then set the current values to the new setpoint\n if rho > 0:\n R_opt = R_step\n J = self.jacobian_func(R_opt)\n grad = J.T @ f_step\n hess = J.T @ J\n loss = loss_step\n fR = f_step\n\n #Change damping scaling based on the rho value above\n u = u*self.beta if rho < self.rho1 else u/self.gamma if rho > self.rho2 else u\n torch.clamp(u, 1e-8, 1e8)\n\n # stop conditions\n gcon = max(abs(grad)) < self.gtol #Very small gradients (stationary point)\n pcon = (delta**2).sum()**0.5 < self.ptol #Very small changes to rotation (rotation is negligible)\n fcon = ((fR_prev-fR)**2).sum() < ((self.ftol*fR)**2).sum() if rho > 0 else False #+ve rho but small change in cost (cost stationary point)\n\n if gcon or pcon or fcon:\n break\n\n #recover covariance from optimal hessian\n cov = torch.linalg.inv(hess)\n \n return R_opt, cov", "probing input": " def LM_opt(self, R_init):\n #Set current rotation based on initialisation conditions\n R_opt = R_init\n\n #Calculate intial total loss (sum of square errors, f(R)^t @ f(R)) and cost function values \n loss, fR = self.cost_func(R_opt)\n\n #Calculate jacobian of d(f(R)) / d(delta(phi))\n J = self.jacobian_func(R_opt)\n \n #Get hessian matrix, J^t @ J \n hess = J.t() @ J\n #Get gradient vector, J^t @ cost\n grad = J.t() @ fR\n\n #Set initial damping scaling\n u = self.tau * torch.max(hess.diag())\n\n #Optimisation loop\n for iter in range(self.max_iters-1):\n #Set damping based on current Hessian max value\n D = torch.eye(J.shape[1], device=J.device)\n D *= torch.max(torch.max(hess.diagonal(), D.diagonal()))\n\n #Scale damping\n damping = u*D\n \n #Solve Ax=b, (J^t@J + damping*I) = J^t@f(R)\n", "probing input new": " def LM_opt(self, R_init):\n #Set current rotation based on initialisation conditions\n R_opt = R_init\n\n #Calculate intial total loss (sum of square errors, f(R)^t @ f(R)) and cost function values \n loss, fR = self.cost_func(R_opt)\n\n #Calculate jacobian of d(f(R)) / d(delta(phi))\n J = self.jacobian_func(R_opt)\n \n #Get hessian matrix, J^t @ J \n hess = J.t() @ J\n #Get gradient vector, J^t @ cost\n grad = J.t() @ fR\n\n #Set initial damping scaling\n u = self.tau * torch.max(hess.diag())\n\n #Optimisation loop\n for iter in range(self.max_iters-1):\n #Set damping based on current Hessian max value\n D = torch.eye(J.shape[1], device=J.device)\n D *= torch.max(torch.max(hess.diagonal(), D.diagonal()))\n\n #Scale damping\n damping = u*D\n \n #Solve Ax=b, (J^t@J + damping*I) = J^t@f(R)\n delta = -torch.", "reference": "delta=-torch.linalg.solve((hess+damping),grad)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "delta=-torch.linalg.solve((hess+damping),grad)", "y_neg": " delta = -torch.solve(J.t() @ J + damping.diag() * torch.eye(J.shape[1], device=J.device), J.t() @ fR)[0]", "retain": " def LM_opt(self, R_init):\n #Set current rotation based on initialisation conditions\n R_opt = R_init\n\n #Calculate intial total loss (sum of square errors, f(R)^t @ f(R)) and cost function values \n loss, fR = self.cost_func(R_opt)\n\n #Calculate jacobian of d(f(R)) / d(delta(phi))\n J = self.jacobian_func(R_opt)\n \n #Get hessian matrix, J^t @ J \n hess = J.t() @ J\n #Get gradient vector, J^t @ cost\n grad = J.t() @ fR\n\n #Set initial damping scaling\n u = self.tau * torch.max(hess.diag())\n\n #Optimisation loop\n for iter in range(self.max_iters-1):\n #Set damping based on current Hessian max value\n D = torch.eye(J.shape[1], device=J.device)\n D *= torch.max(torch.max(hess.diagonal(), D.diagonal()))\n\n #Scale damping\n damping = u*D\n \n #Solve Ax=b, (J^t@J + damping*I) = J^t@f(R)\n delta = -torch.linalg.solve((hess + damping), grad)\n \n #Calculate SO(3) delta rotation to apply to current estimate\n R_delta = self.so3exp(delta)\n R_step = R_delta @ R_opt\n\n #Get new cost values and loss for the new rotation \n loss_step, f_step = self.cost_func(R_step)\n \n #Setting previous to current for the next iteration\n fR_prev = fR.clone()\n \n #Work out LM rho value to determine if we accept or reject this new rotation\n rho_denom = delta.t() @ (u*delta-grad)\n rho_nom = loss - loss_step\n rho = rho_nom / rho_denom if rho_denom > 0 else torch.inf if rho_nom > 0 else -torch.inf\n\n #If happy then set the current values to the new setpoint\n if rho > 0:\n R_opt = R_step\n J = self.jacobian_func(R_opt)\n grad = J.T @ f_step\n hess = J.T @ J\n loss = loss_step\n fR = f_step\n\n #Change damping scaling based on the rho value above\n u = u*self.beta if rho < self.rho1 else u/self.gamma if rho > self.rho2 else u\n torch.clamp(u, 1e-8, 1e8)\n\n # stop conditions\n gcon = max(abs(grad)) < self.gtol #Very small gradients (stationary point)\n pcon = (delta**2).sum()**0.5 < self.ptol #Very small changes to rotation (rotation is negligible)\n fcon = ((fR_prev-fR)**2).sum() < ((self.ftol*fR)**2).sum() if rho > 0 else False #+ve rho but small change in cost (cost stationary point)\n\n if gcon or pcon or fcon:\n break\n\n #recover covariance from optimal hessian\n cov = torch.linalg.inv(hess)\n \n return R_opt, cov" }, { "id": 8531, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _solve(self, A, b):\n if np.ndim(b) == 1: b = np.expand_dims(b, axis=1)\n if self.compute_device == \"cpu\":\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"gpu\" or A.ndim < 3:\n try:\n import torch\n A = torch.from_numpy(A).cuda()\n b = torch.from_numpy(b).cuda()\n x = torch.linalg.solve(A, b)\n return x.cpu().numpy()\n except Exception as e:\n warnings.warn(\n \"I encountered a problem using the GPU via pytorch. Falling back to Numpy and the CPU.\")\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"multi-gpu\":\n try:\n import torch\n n = min(len(A), torch.cuda.device_count())\n split_A = np.array_split(A, n)\n split_b = np.array_split(b, n)\n results = []\n for i, (tmp_A, tmp_b) in enumerate(zip(split_A, split_b)):\n cur_device = torch.device(\"cuda:\" + str(i))\n tmp_A = torch.from_numpy(tmp_A).cuda(cur_device)\n tmp_b = torch.from_numpy(tmp_b).cuda(cur_device)\n results.append(torch.linalg.solve(tmp_A, tmp_b)[0])\n total = results[0].cpu().numpy()\n for i in range(1, len(results)):\n total = np.append(total, results[i].cpu().numpy(), 0)\n return total\n except Exception as e:\n warnings.warn(\n \"I encountered a problem using the GPU via pytorch. Falling back to Numpy and the CPU.\")\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n else:\n raise Exception(\"No valid solve method specified\")", "probing input": " def _solve(self, A, b):\n if np.ndim(b) == 1: b = np.expand_dims(b, axis=1)\n if self.compute_device == \"cpu\":\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"gpu\" or A.ndim < 3:\n try:\n import torch\n A = torch.from_numpy(A).cuda()\n b = torch.from_numpy(b).cuda()\n", "probing input new": " def _solve(self, A, b):\n if np.ndim(b) == 1: b = np.expand_dims(b, axis=1)\n if self.compute_device == \"cpu\":\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"gpu\" or A.ndim < 3:\n try:\n import torch\n A = torch.from_numpy(A).cuda()\n b = torch.from_numpy(b).cuda()\n x = torch.", "reference": "x=torch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x=torch.linalg.solve(A,b)", "y_neg": " x = torch.solve(A, b)", "retain": " def _solve(self, A, b):\n if np.ndim(b) == 1: b = np.expand_dims(b, axis=1)\n if self.compute_device == \"cpu\":\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"gpu\" or A.ndim < 3:\n try:\n import torch\n A = torch.from_numpy(A).cuda()\n b = torch.from_numpy(b).cuda()\n x = torch.linalg.solve(A, b)\n return x.cpu().numpy()\n except Exception as e:\n warnings.warn(\n \"I encountered a problem using the GPU via pytorch. Falling back to Numpy and the CPU.\")\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n elif self.compute_device == \"multi-gpu\":\n try:\n import torch\n n = min(len(A), torch.cuda.device_count())\n split_A = np.array_split(A, n)\n split_b = np.array_split(b, n)\n results = []\n for i, (tmp_A, tmp_b) in enumerate(zip(split_A, split_b)):\n cur_device = torch.device(\"cuda:\" + str(i))\n tmp_A = torch.from_numpy(tmp_A).cuda(cur_device)\n tmp_b = torch.from_numpy(tmp_b).cuda(cur_device)\n results.append(torch.linalg.solve(tmp_A, tmp_b)[0])\n total = results[0].cpu().numpy()\n for i in range(1, len(results)):\n total = np.append(total, results[i].cpu().numpy(), 0)\n return total\n except Exception as e:\n warnings.warn(\n \"I encountered a problem using the GPU via pytorch. Falling back to Numpy and the CPU.\")\n try:\n x = np.linalg.solve(A, b)\n except:\n x, res, rank, s = np.linalg.lstsq(A, b, rcond=None)\n return x\n else:\n raise Exception(\"No valid solve method specified\")" }, { "id": 8543, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit_plane(points, weights=None):\n \"\"\"Expects points to be of shape (..., 3).\n Returns [a, b, c] such that the plane is defined as\n ax + by + c = z\n \"\"\"\n D = torch.cat([points[..., :2], torch.ones_like(points[..., 2:3])], dim=-1)\n z = points[..., 2]\n if weights is not None:\n Dtrans = D.transpose(-1, -2)\n else:\n DW = D * weights\n Dtrans = DW.transpose(-1, -2)\n w = torch.linalg.solve(\n torch.matmul(Dtrans, D), torch.matmul(Dtrans, z.unsqueeze(-1))\n ).squeeze(-1)\n return w", "probing input": " def fit_plane(points, weights=None):\n \"\"\"Expects points to be of shape (..., 3).\n Returns [a, b, c] such that the plane is defined as\n ax + by + c = z\n \"\"\"\n D = torch.cat([points[..., :2], torch.ones_like(points[..., 2:3])], dim=-1)\n z = points[..., 2]\n if weights is not None:\n Dtrans = D.transpose(-1, -2)\n else:\n DW = D * weights\n Dtrans = DW.transpose(-1, -2)\n", "probing input new": " def fit_plane(points, weights=None):\n \"\"\"Expects points to be of shape (..., 3).\n Returns [a, b, c] such that the plane is defined as\n ax + by + c = z\n \"\"\"\n D = torch.cat([points[..., :2], torch.ones_like(points[..., 2:3])], dim=-1)\n z = points[..., 2]\n if weights is not None:\n Dtrans = D.transpose(-1, -2)\n else:\n DW = D * weights\n Dtrans = DW.transpose(-1, -2)\n w = torch.", "reference": "w=torch.linalg.solve(torch.matmul(Dtrans,D),torch.matmul(Dtrans,z.unsqueeze(-1))).squeeze(-1)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "w=torch.linalg.solve(torch.matmul(Dtrans,D),torch.matmul(Dtrans,z.unsqueeze(-1))).squeeze(-1)", "y_neg": " w = torch.solve(Dtrans, z)[0]", "retain": " def fit_plane(points, weights=None):\n \"\"\"Expects points to be of shape (..., 3).\n Returns [a, b, c] such that the plane is defined as\n ax + by + c = z\n \"\"\"\n D = torch.cat([points[..., :2], torch.ones_like(points[..., 2:3])], dim=-1)\n z = points[..., 2]\n if weights is not None:\n Dtrans = D.transpose(-1, -2)\n else:\n DW = D * weights\n Dtrans = DW.transpose(-1, -2)\n w = torch.linalg.solve(\n torch.matmul(Dtrans, D), torch.matmul(Dtrans, z.unsqueeze(-1))\n ).squeeze(-1)\n return w" }, { "id": 8551, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_solve_errors_and_warnings(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # solve expects compatible shapes for A x = b\n with self.assertRaisesRegex(RuntimeError, \"Incompatible matrix sizes\"):\n a = torch.randn(2, 3, 3, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 2, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # if input is not solvable, RuntimeError is raised mentioning the first non-solvable batch\n def run_test_singular_input(batch_dim, n):\n a = torch.eye(3, 3, dtype=dtype, device=device).reshape((1, 3, 3)).repeat(batch_dim, 1, 1)\n a[n, -1, -1] = 0\n b = torch.randn(batch_dim, 3, 1, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, rf'For batch {n}: U\\(3,3\\) is zero'):\n torch.linalg.solve(a, b)\n\n for params in [(1, 0), (2, 0), (2, 1), (4, 0), (4, 2), (10, 2)]:\n run_test_singular_input(*params)\n\n # if out tensor with wrong shape is passed a warning is given\n # matrix 'b' case\n with warnings.catch_warnings(record=True) as w:\n A = torch.eye(2, dtype=dtype, device=device).reshape((1, 2, 2)).repeat(2, 1, 1)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device)\n out = torch.zeros(1, dtype=dtype, device=device)\n # Trigger warning\n torch.linalg.solve(A, b, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # if out tensor with wrong shape is passed a warning is given\n # vector 'b' case\n with warnings.catch_warnings(record=True) as w:\n A = torch.eye(2, dtype=dtype, device=device)\n b = torch.randn(2, dtype=dtype, device=device)\n out = torch.zeros(1, dtype=dtype, device=device)\n # Trigger warning\n torch.linalg.solve(A, b, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # dtypes should be safely castable\n a = torch.eye(2, dtype=dtype, device=device)\n b = torch.randn(2, 1, dtype=dtype, device=device)\n out = torch.empty(0, dtype=torch.int, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got result with dtype Int\"):\n torch.linalg.solve(a, b, out=out)\n\n # device should match\n if torch.cuda.is_available():\n wrong_device = 'cpu' if self.device_type != 'cpu' else 'cuda'\n out = torch.empty(0, dtype=dtype, device=wrong_device)\n clone_a = torch.empty_like(a)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.solve(a, b, out=out)", "probing input": " def test_solve_errors_and_warnings(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n", "probing input new": " def test_solve_errors_and_warnings(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.", "reference": "torch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "torch.linalg.solve(a,b)", "y_neg": " torch.solve(a, b)", "retain": " def test_solve_errors_and_warnings(self, device, dtype):\n # solve expects batches of square matrices as input\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n a = torch.randn(2, 3, 4, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 4, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # solve expects compatible shapes for A x = b\n with self.assertRaisesRegex(RuntimeError, \"Incompatible matrix sizes\"):\n a = torch.randn(2, 3, 3, 3, dtype=dtype, device=device)\n b = torch.randn(2, 3, 2, 1, dtype=dtype, device=device)\n torch.linalg.solve(a, b)\n\n # if input is not solvable, RuntimeError is raised mentioning the first non-solvable batch\n def run_test_singular_input(batch_dim, n):\n a = torch.eye(3, 3, dtype=dtype, device=device).reshape((1, 3, 3)).repeat(batch_dim, 1, 1)\n a[n, -1, -1] = 0\n b = torch.randn(batch_dim, 3, 1, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, rf'For batch {n}: U\\(3,3\\) is zero'):\n torch.linalg.solve(a, b)\n\n for params in [(1, 0), (2, 0), (2, 1), (4, 0), (4, 2), (10, 2)]:\n run_test_singular_input(*params)\n\n # if out tensor with wrong shape is passed a warning is given\n # matrix 'b' case\n with warnings.catch_warnings(record=True) as w:\n A = torch.eye(2, dtype=dtype, device=device).reshape((1, 2, 2)).repeat(2, 1, 1)\n b = torch.randn(2, 2, 2, dtype=dtype, device=device)\n out = torch.zeros(1, dtype=dtype, device=device)\n # Trigger warning\n torch.linalg.solve(A, b, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # if out tensor with wrong shape is passed a warning is given\n # vector 'b' case\n with warnings.catch_warnings(record=True) as w:\n A = torch.eye(2, dtype=dtype, device=device)\n b = torch.randn(2, dtype=dtype, device=device)\n out = torch.zeros(1, dtype=dtype, device=device)\n # Trigger warning\n torch.linalg.solve(A, b, out=out)\n # Check warning occurs\n self.assertEqual(len(w), 1)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n\n # dtypes should be safely castable\n a = torch.eye(2, dtype=dtype, device=device)\n b = torch.randn(2, 1, dtype=dtype, device=device)\n out = torch.empty(0, dtype=torch.int, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got result with dtype Int\"):\n torch.linalg.solve(a, b, out=out)\n\n # device should match\n if torch.cuda.is_available():\n wrong_device = 'cpu' if self.device_type != 'cpu' else 'cuda'\n out = torch.empty(0, dtype=dtype, device=wrong_device)\n clone_a = torch.empty_like(a)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.solve(a, b, out=out)" }, { "id": 8559, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def fast_global_registration(xyz, xyz_target, mu_init=1, num_iter=20):\n \"\"\"\n estimate the rotation and translation using Fast Global Registration algorithm (M estimator for robust estimation)\n http://vladlen.info/papers/fast-global-registration.pdf\n \"\"\"\n assert xyz.shape == xyz_target.shape\n\n T_res = torch.eye(4, device=xyz.device)\n mu = mu_init\n source = xyz.clone()\n weight = torch.ones(len(source), 1, device=xyz.device)\n for i in range(num_iter):\n if i > 0 and i % 5 == 0:\n mu /= 2.0\n A, b = get_matrix_system(source, xyz_target, weight)\n x = torch.linalg.solve(A.T.mm(A), A.T @ b)\n T = get_trans(x.view(-1))\n source = source.mm(T[:3, :3].T) + T[:3, 3]\n T_res = T @ T_res\n weight = get_geman_mclure_weight(source, xyz_target, mu)\n return T_res", "probing input": "def fast_global_registration(xyz, xyz_target, mu_init=1, num_iter=20):\n \"\"\"\n estimate the rotation and translation using Fast Global Registration algorithm (M estimator for robust estimation)\n http://vladlen.info/papers/fast-global-registration.pdf\n \"\"\"\n assert xyz.shape == xyz_target.shape\n\n T_res = torch.eye(4, device=xyz.device)\n mu = mu_init\n source = xyz.clone()\n weight = torch.ones(len(source), 1, device=xyz.device)\n for i in range(num_iter):\n if i > 0 and i % 5 == 0:\n mu /= 2.0\n A, b = get_matrix_system(source, xyz_target, weight)\n", "probing input new": "def fast_global_registration(xyz, xyz_target, mu_init=1, num_iter=20):\n \"\"\"\n estimate the rotation and translation using Fast Global Registration algorithm (M estimator for robust estimation)\n http://vladlen.info/papers/fast-global-registration.pdf\n \"\"\"\n assert xyz.shape == xyz_target.shape\n\n T_res = torch.eye(4, device=xyz.device)\n mu = mu_init\n source = xyz.clone()\n weight = torch.ones(len(source), 1, device=xyz.device)\n for i in range(num_iter):\n if i > 0 and i % 5 == 0:\n mu /= 2.0\n A, b = get_matrix_system(source, xyz_target, weight)\n x = torch.", "reference": "x=torch.linalg.solve(A.T.mm(A),A.T@b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x=torch.linalg.solve(A.T.mm(A),A.T@b)", "y_neg": " x = torch.solve(A, b)[0]", "retain": "def fast_global_registration(xyz, xyz_target, mu_init=1, num_iter=20):\n \"\"\"\n estimate the rotation and translation using Fast Global Registration algorithm (M estimator for robust estimation)\n http://vladlen.info/papers/fast-global-registration.pdf\n \"\"\"\n assert xyz.shape == xyz_target.shape\n\n T_res = torch.eye(4, device=xyz.device)\n mu = mu_init\n source = xyz.clone()\n weight = torch.ones(len(source), 1, device=xyz.device)\n for i in range(num_iter):\n if i > 0 and i % 5 == 0:\n mu /= 2.0\n A, b = get_matrix_system(source, xyz_target, weight)\n x = torch.linalg.solve(A.T.mm(A), A.T @ b)\n T = get_trans(x.view(-1))\n source = source.mm(T[:3, :3].T) + T[:3, 3]\n T_res = T @ T_res\n weight = get_geman_mclure_weight(source, xyz_target, mu)\n return T_res" }, { "id": 8570, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _stable_solve(b, a, eps=1e-6):\n try:\n return torch.linalg.solve(a, b)\n except RuntimeError:\n a = condition_scm(a, eps)\n return torch.linalg.solve(a, b)", "probing input": "def _stable_solve(b, a, eps=1e-6):\n try:\n", "probing input new": "def _stable_solve(b, a, eps=1e-6):\n try:\n return torch.", "reference": "returntorch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(a,b)", "y_neg": " return torch.solve(a, b)[0]", "retain": "def _stable_solve(b, a, eps=1e-6):\n try:\n return torch.linalg.solve(a, b)\n except RuntimeError:\n a = condition_scm(a, eps)\n return torch.linalg.solve(a, b)" }, { "id": 8574, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_adjoint(self, fwd_sol, param_vals, **newton_kwargs):\n jac = self._fwd_solver.physics._raw_residual(fwd_sol)[1]\n if jac is None:\n fwd_sol.requires_grad_(True)\n assert fwd_sol.requires_grad\n jac = torch.autograd.functional.jacobian(\n lambda s: self.physics._raw_residual(s)[0], fwd_sol,\n strict=True)\n fwd_sol.requires_grad_(False)\n fwd_sol_copy = torch.clone(fwd_sol)\n param_vals_copy = torch.clone(param_vals)\n if self._dqdu is None:\n functional_vals = self._functional(\n fwd_sol_copy.requires_grad_(True),\n param_vals_copy.requires_grad_(True))\n functional_vals.backward()\n dqdu = fwd_sol_copy.grad\n else:\n functional_vals = self._functional(fwd_sol_copy, param_vals_copy)\n dqdu = self._dqdu(fwd_sol_copy, param_vals_copy)\n __, tmp = (\n self._fwd_solver.physics.mesh._apply_boundary_conditions(\n self._fwd_solver.physics._bndry_conds, -dqdu, jac.clone(),\n fwd_sol, self._fwd_solver.physics.flux_jac))\n jac_adjoint = tmp.T\n rhs = -dqdu\n adj_sol = torch.linalg.solve(jac_adjoint, rhs)\n return adj_sol", "probing input": " def solve_adjoint(self, fwd_sol, param_vals, **newton_kwargs):\n jac = self._fwd_solver.physics._raw_residual(fwd_sol)[1]\n if jac is None:\n fwd_sol.requires_grad_(True)\n assert fwd_sol.requires_grad\n jac = torch.autograd.functional.jacobian(\n lambda s: self.physics._raw_residual(s)[0], fwd_sol,\n strict=True)\n fwd_sol.requires_grad_(False)\n fwd_sol_copy = torch.clone(fwd_sol)\n param_vals_copy = torch.clone(param_vals)\n if self._dqdu is None:\n functional_vals = self._functional(\n fwd_sol_copy.requires_grad_(True),\n param_vals_copy.requires_grad_(True))\n functional_vals.backward()\n dqdu = fwd_sol_copy.grad\n else:\n functional_vals = self._functional(fwd_sol_copy, param_vals_copy)\n dqdu = self._dqdu(fwd_sol_copy, param_vals_copy)\n __, tmp = (\n self._fwd_solver.physics.mesh._apply_boundary_conditions(\n self._fwd_solver.physics._bndry_conds, -dqdu, jac.clone(),\n fwd_sol, self._fwd_solver.physics.flux_jac))\n jac_adjoint = tmp.T\n rhs = -dqdu\n", "probing input new": " def solve_adjoint(self, fwd_sol, param_vals, **newton_kwargs):\n jac = self._fwd_solver.physics._raw_residual(fwd_sol)[1]\n if jac is None:\n fwd_sol.requires_grad_(True)\n assert fwd_sol.requires_grad\n jac = torch.autograd.functional.jacobian(\n lambda s: self.physics._raw_residual(s)[0], fwd_sol,\n strict=True)\n fwd_sol.requires_grad_(False)\n fwd_sol_copy = torch.clone(fwd_sol)\n param_vals_copy = torch.clone(param_vals)\n if self._dqdu is None:\n functional_vals = self._functional(\n fwd_sol_copy.requires_grad_(True),\n param_vals_copy.requires_grad_(True))\n functional_vals.backward()\n dqdu = fwd_sol_copy.grad\n else:\n functional_vals = self._functional(fwd_sol_copy, param_vals_copy)\n dqdu = self._dqdu(fwd_sol_copy, param_vals_copy)\n __, tmp = (\n self._fwd_solver.physics.mesh._apply_boundary_conditions(\n self._fwd_solver.physics._bndry_conds, -dqdu, jac.clone(),\n fwd_sol, self._fwd_solver.physics.flux_jac))\n jac_adjoint = tmp.T\n rhs = -dqdu\n adj_sol = torch.", "reference": "adj_sol=torch.linalg.solve(jac_adjoint,rhs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "adj_sol=torch.linalg.solve(jac_adjoint,rhs)", "y_neg": " adj_sol = torch.solve(jac_adjoint, rhs)[0]", "retain": " def solve_adjoint(self, fwd_sol, param_vals, **newton_kwargs):\n jac = self._fwd_solver.physics._raw_residual(fwd_sol)[1]\n if jac is None:\n fwd_sol.requires_grad_(True)\n assert fwd_sol.requires_grad\n jac = torch.autograd.functional.jacobian(\n lambda s: self.physics._raw_residual(s)[0], fwd_sol,\n strict=True)\n fwd_sol.requires_grad_(False)\n fwd_sol_copy = torch.clone(fwd_sol)\n param_vals_copy = torch.clone(param_vals)\n if self._dqdu is None:\n functional_vals = self._functional(\n fwd_sol_copy.requires_grad_(True),\n param_vals_copy.requires_grad_(True))\n functional_vals.backward()\n dqdu = fwd_sol_copy.grad\n else:\n functional_vals = self._functional(fwd_sol_copy, param_vals_copy)\n dqdu = self._dqdu(fwd_sol_copy, param_vals_copy)\n __, tmp = (\n self._fwd_solver.physics.mesh._apply_boundary_conditions(\n self._fwd_solver.physics._bndry_conds, -dqdu, jac.clone(),\n fwd_sol, self._fwd_solver.physics.flux_jac))\n jac_adjoint = tmp.T\n rhs = -dqdu\n adj_sol = torch.linalg.solve(jac_adjoint, rhs)\n return adj_sol" }, { "id": 8575, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_adjoint(self, fwd_sols, param_vals, times):\n #only works for implicit backward euler\n adj_sols = torch.empty_like(fwd_sols)\n ndof, ntimes = fwd_sols.shape\n dqdu = self._dqdu(fwd_sols, ntimes-1, param_vals)\n assert np.allclose(dqdu[:, 0], 0) # should be zero for implicit euler\n Id = torch.eye(adj_sols.shape[0])\n for ii in range(ntimes-1, 0, -1):\n raw_jac = self.physics._transient_residual(\n fwd_sols[:, ii], times[ii])[1]\n deltat = times[ii]-times[ii-1]\n # rhs = adj_sols[:, ii+1]+deltat*(-dqdu[:, ii+1])\n # print(ii, times[ii])\n # print(dqdu[:, ii])\n if ii < ntimes-1:\n rhs = adj_sols[:, ii+1]-dqdu[:, ii]\n else:\n rhs = -dqdu[:, ii]\n jac_adjoint = self.physics.mesh._apply_boundary_conditions(\n self.physics._bndry_conds, rhs,\n Id-deltat*raw_jac, fwd_sols[:, ii],\n self.physics.flux_jac)[1].T\n # print('jT', jac_adjoint.T)\n adj_sols[:, ii] = torch.linalg.solve(jac_adjoint, rhs)\n # print(adj_sols[:, ii], 'phi', adj_sols[:, ii].sum())\n adj_sols[:, 0] = adj_sols[:, 1]\n return adj_sols", "probing input": " def solve_adjoint(self, fwd_sols, param_vals, times):\n #only works for implicit backward euler\n adj_sols = torch.empty_like(fwd_sols)\n ndof, ntimes = fwd_sols.shape\n dqdu = self._dqdu(fwd_sols, ntimes-1, param_vals)\n assert np.allclose(dqdu[:, 0], 0) # should be zero for implicit euler\n Id = torch.eye(adj_sols.shape[0])\n for ii in range(ntimes-1, 0, -1):\n raw_jac = self.physics._transient_residual(\n fwd_sols[:, ii], times[ii])[1]\n deltat = times[ii]-times[ii-1]\n # rhs = adj_sols[:, ii+1]+deltat*(-dqdu[:, ii+1])\n # print(ii, times[ii])\n # print(dqdu[:, ii])\n if ii < ntimes-1:\n rhs = adj_sols[:, ii+1]-dqdu[:, ii]\n else:\n rhs = -dqdu[:, ii]\n jac_adjoint = self.physics.mesh._apply_boundary_conditions(\n self.physics._bndry_conds, rhs,\n Id-deltat*raw_jac, fwd_sols[:, ii],\n self.physics.flux_jac)[1].T\n # print('jT', jac_adjoint.T)\n", "probing input new": " def solve_adjoint(self, fwd_sols, param_vals, times):\n #only works for implicit backward euler\n adj_sols = torch.empty_like(fwd_sols)\n ndof, ntimes = fwd_sols.shape\n dqdu = self._dqdu(fwd_sols, ntimes-1, param_vals)\n assert np.allclose(dqdu[:, 0], 0) # should be zero for implicit euler\n Id = torch.eye(adj_sols.shape[0])\n for ii in range(ntimes-1, 0, -1):\n raw_jac = self.physics._transient_residual(\n fwd_sols[:, ii], times[ii])[1]\n deltat = times[ii]-times[ii-1]\n # rhs = adj_sols[:, ii+1]+deltat*(-dqdu[:, ii+1])\n # print(ii, times[ii])\n # print(dqdu[:, ii])\n if ii < ntimes-1:\n rhs = adj_sols[:, ii+1]-dqdu[:, ii]\n else:\n rhs = -dqdu[:, ii]\n jac_adjoint = self.physics.mesh._apply_boundary_conditions(\n self.physics._bndry_conds, rhs,\n Id-deltat*raw_jac, fwd_sols[:, ii],\n self.physics.flux_jac)[1].T\n # print('jT', jac_adjoint.T)\n adj_sols[:, ii] = torch.", "reference": "adj_sols[:,ii]=torch.linalg.solve(jac_adjoint,rhs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "adj_sols[:,ii]=torch.linalg.solve(jac_adjoint,rhs)", "y_neg": " adj_sols[:, ii] = torch.solve(jac_adjoint, fwd_sols[:, ii])[0]", "retain": " def solve_adjoint(self, fwd_sols, param_vals, times):\n #only works for implicit backward euler\n adj_sols = torch.empty_like(fwd_sols)\n ndof, ntimes = fwd_sols.shape\n dqdu = self._dqdu(fwd_sols, ntimes-1, param_vals)\n assert np.allclose(dqdu[:, 0], 0) # should be zero for implicit euler\n Id = torch.eye(adj_sols.shape[0])\n for ii in range(ntimes-1, 0, -1):\n raw_jac = self.physics._transient_residual(\n fwd_sols[:, ii], times[ii])[1]\n deltat = times[ii]-times[ii-1]\n # rhs = adj_sols[:, ii+1]+deltat*(-dqdu[:, ii+1])\n # print(ii, times[ii])\n # print(dqdu[:, ii])\n if ii < ntimes-1:\n rhs = adj_sols[:, ii+1]-dqdu[:, ii]\n else:\n rhs = -dqdu[:, ii]\n jac_adjoint = self.physics.mesh._apply_boundary_conditions(\n self.physics._bndry_conds, rhs,\n Id-deltat*raw_jac, fwd_sols[:, ii],\n self.physics.flux_jac)[1].T\n # print('jT', jac_adjoint.T)\n adj_sols[:, ii] = torch.linalg.solve(jac_adjoint, rhs)\n # print(adj_sols[:, ii], 'phi', adj_sols[:, ii].sum())\n adj_sols[:, 0] = adj_sols[:, 1]\n return adj_sols" }, { "id": 8583, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif torch.is_complex(a) or torch.is_complex(b):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n return torch.linalg.solve(a, b)", "probing input": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif torch.is_complex(a) or torch.is_complex(b):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n", "probing input new": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif torch.is_complex(a) or torch.is_complex(b):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n return torch.", "reference": "returntorch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(a,b)", "y_neg": " return torch.solve(a, b)", "retain": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a, return_LU=False)\n else:\n return matmul(inverse(a), b)\n elif torch.is_complex(a) or torch.is_complex(b):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n return torch.linalg.solve(a, b)" }, { "id": 8587, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve_lineqn(A, b, eps=1e-5):\n try:\n result = torch.linalg.solve(A, b)\n except RuntimeError:\n print(f\"WARNING: The matrix was singular\")\n result = torch.linalg.solve(A + eps * torch.eye(A.shape[-1]), b)\n return result", "probing input": "def solve_lineqn(A, b, eps=1e-5):\n try:\n", "probing input new": "def solve_lineqn(A, b, eps=1e-5):\n try:\n result = torch.", "reference": "result=torch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "result=torch.linalg.solve(A,b)", "y_neg": " result = torch.solve(A, b)[0]", "retain": "def solve_lineqn(A, b, eps=1e-5):\n try:\n result = torch.linalg.solve(A, b)\n except RuntimeError:\n print(f\"WARNING: The matrix was singular\")\n result = torch.linalg.solve(A + eps * torch.eye(A.shape[-1]), b)\n return result" }, { "id": 8629, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_system(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # # Identify known DOFs from self.node_dof_disp\n # if self.node_dof_disp.numel() > 0:\n # known_dof_indices = (self.node_dof_disp[:, 0] * self.parameters['num_dimensions'] + self.node_dof_disp[:, 1]).long()\n # else:\n # known_dof_indices = torch.tensor([], dtype=torch.long, device=self.device)\n # # Identify unknown DOFs\n # all_dofs = torch.arange(self.num_dofs, device=self.device)\n # unknown_dof_indices = torch.tensor([idx for idx in all_dofs if idx not in known_dof_indices], device=self.device)\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n\n # Solve the system\n u_sub = torch.linalg.solve(K_sub, R_sub.unsqueeze(1))\n\n\n # residual = R_sub - K_sub @ u_sub.squeeze()\n # relative_residual_error = torch.norm(residual) / torch.norm(R_sub)\n # print(f\"Relative Residual Error: {relative_residual_error.item():.8f}\")\n\n\n\n # Create a global displacement vector\n self.global_displacements = torch.zeros(self.num_dofs, device=self.device).to(dtype=torch.float64)\n self.global_displacements[unknown_dof_indices] = u_sub.squeeze()\n\n # Fill known displacements, if any\n if self.node_dof_disp.numel() > 0:\n self.global_displacements[known_dof_indices] = self.node_dof_disp[:, 2].to(dtype=torch.float64)", "probing input": " def solve_system(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # # Identify known DOFs from self.node_dof_disp\n # if self.node_dof_disp.numel() > 0:\n # known_dof_indices = (self.node_dof_disp[:, 0] * self.parameters['num_dimensions'] + self.node_dof_disp[:, 1]).long()\n # else:\n # known_dof_indices = torch.tensor([], dtype=torch.long, device=self.device)\n # # Identify unknown DOFs\n # all_dofs = torch.arange(self.num_dofs, device=self.device)\n # unknown_dof_indices = torch.tensor([idx for idx in all_dofs if idx not in known_dof_indices], device=self.device)\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n\n # Solve the system\n", "probing input new": " def solve_system(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # # Identify known DOFs from self.node_dof_disp\n # if self.node_dof_disp.numel() > 0:\n # known_dof_indices = (self.node_dof_disp[:, 0] * self.parameters['num_dimensions'] + self.node_dof_disp[:, 1]).long()\n # else:\n # known_dof_indices = torch.tensor([], dtype=torch.long, device=self.device)\n # # Identify unknown DOFs\n # all_dofs = torch.arange(self.num_dofs, device=self.device)\n # unknown_dof_indices = torch.tensor([idx for idx in all_dofs if idx not in known_dof_indices], device=self.device)\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n\n # Solve the system\n u_sub = torch.", "reference": "u_sub=torch.linalg.solve(K_sub,R_sub.unsqueeze(1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "u_sub=torch.linalg.solve(K_sub,R_sub.unsqueeze(1))", "y_neg": " u_sub = torch.solve(K_sub, R_sub)[0]", "retain": " def solve_system(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # # Identify known DOFs from self.node_dof_disp\n # if self.node_dof_disp.numel() > 0:\n # known_dof_indices = (self.node_dof_disp[:, 0] * self.parameters['num_dimensions'] + self.node_dof_disp[:, 1]).long()\n # else:\n # known_dof_indices = torch.tensor([], dtype=torch.long, device=self.device)\n # # Identify unknown DOFs\n # all_dofs = torch.arange(self.num_dofs, device=self.device)\n # unknown_dof_indices = torch.tensor([idx for idx in all_dofs if idx not in known_dof_indices], device=self.device)\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n\n # Solve the system\n u_sub = torch.linalg.solve(K_sub, R_sub.unsqueeze(1))\n\n\n # residual = R_sub - K_sub @ u_sub.squeeze()\n # relative_residual_error = torch.norm(residual) / torch.norm(R_sub)\n # print(f\"Relative Residual Error: {relative_residual_error.item():.8f}\")\n\n\n\n # Create a global displacement vector\n self.global_displacements = torch.zeros(self.num_dofs, device=self.device).to(dtype=torch.float64)\n self.global_displacements[unknown_dof_indices] = u_sub.squeeze()\n\n # Fill known displacements, if any\n if self.node_dof_disp.numel() > 0:\n self.global_displacements[known_dof_indices] = self.node_dof_disp[:, 2].to(dtype=torch.float64)" }, { "id": 8630, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_system_nonlinear(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n\n\n # Solve the system\n self.u_incr_sub = torch.linalg.solve(K_sub, B_sub.unsqueeze(1))\n \n \n self.global_displacements_temp[unknown_dof_indices] += self.u_incr_sub.squeeze()\n\n if known_dof_indices.numel() > 0:\n self.global_displacements_temp[known_dof_indices] = self.current_known_disp", "probing input": " def solve_system_nonlinear(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n\n\n # Solve the system\n", "probing input new": " def solve_system_nonlinear(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n\n\n # Solve the system\n self.u_incr_sub = torch.", "reference": "self.u_incr_sub=torch.linalg.solve(K_sub,B_sub.unsqueeze(1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "self.u_incr_sub=torch.linalg.solve(K_sub,B_sub.unsqueeze(1))", "y_neg": " self.u_incr_sub = torch.solve(K_sub, B_sub)[0]", "retain": " def solve_system_nonlinear(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n\n\n # Solve the system\n self.u_incr_sub = torch.linalg.solve(K_sub, B_sub.unsqueeze(1))\n \n \n self.global_displacements_temp[unknown_dof_indices] += self.u_incr_sub.squeeze()\n\n if known_dof_indices.numel() > 0:\n self.global_displacements_temp[known_dof_indices] = self.current_known_disp" }, { "id": 8631, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_system_nonlinear_finiteStrain(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n \n\n # Solve the system\n self.u_incr_sub = torch.linalg.solve(K_sub, B_sub.unsqueeze(1))\n\n self.global_displacements_temp[unknown_dof_indices] += self.u_incr_sub.squeeze()\n\n if known_dof_indices.numel() > 0:\n self.global_displacements_temp[known_dof_indices] = self.current_known_disp", "probing input": " def solve_system_nonlinear_finiteStrain(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n \n\n # Solve the system\n", "probing input new": " def solve_system_nonlinear_finiteStrain(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n \n\n # Solve the system\n self.u_incr_sub = torch.", "reference": "self.u_incr_sub=torch.linalg.solve(K_sub,B_sub.unsqueeze(1))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "self.u_incr_sub=torch.linalg.solve(K_sub,B_sub.unsqueeze(1))", "y_neg": " self.u_incr_sub = torch.solve(K_sub, B_sub)[0]", "retain": " def solve_system_nonlinear_finiteStrain(self):\n \"\"\"\n Solve the global system of equations to get the nodal displacements.\n \"\"\"\n\n # Identify known DOFs from self.node_dof_disp\n known_dof_indices, unknown_dof_indices = self._get_dof_indices()\n\n # Extract submatrix and subvector\n K_sub = self.global_stiffness[unknown_dof_indices, :][:, unknown_dof_indices]\n R_sub = self.global_load[unknown_dof_indices]\n F_sub = self.global_residual_stress[unknown_dof_indices]\n B_sub = R_sub - F_sub\n \n\n # Solve the system\n self.u_incr_sub = torch.linalg.solve(K_sub, B_sub.unsqueeze(1))\n\n self.global_displacements_temp[unknown_dof_indices] += self.u_incr_sub.squeeze()\n\n if known_dof_indices.numel() > 0:\n self.global_displacements_temp[known_dof_indices] = self.current_known_disp" }, { "id": 8632, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _direct_solve_I_p_lambda_AT_A_x_eq_b(self, lambda_, b, **kwargs):\n if self.__ATA_matrix is None:\n A = self._matrix.clone()\n self.__ATA_matrix = A.T @ A\n\n if self.__lambda_cache != lambda_:\n lATA = lambda_ * (self.__ATA_matrix)\n torch.diagonal(lATA)[:] += 1\n self.__IplATA_matrix = lATA\n return torch.linalg.solve(self.__IplATA_matrix, b)", "probing input": " def _direct_solve_I_p_lambda_AT_A_x_eq_b(self, lambda_, b, **kwargs):\n if self.__ATA_matrix is None:\n A = self._matrix.clone()\n self.__ATA_matrix = A.T @ A\n\n if self.__lambda_cache != lambda_:\n lATA = lambda_ * (self.__ATA_matrix)\n torch.diagonal(lATA)[:] += 1\n self.__IplATA_matrix = lATA\n", "probing input new": " def _direct_solve_I_p_lambda_AT_A_x_eq_b(self, lambda_, b, **kwargs):\n if self.__ATA_matrix is None:\n A = self._matrix.clone()\n self.__ATA_matrix = A.T @ A\n\n if self.__lambda_cache != lambda_:\n lATA = lambda_ * (self.__ATA_matrix)\n torch.diagonal(lATA)[:] += 1\n self.__IplATA_matrix = lATA\n return torch.", "reference": "returntorch.linalg.solve(self.__IplATA_matrix,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(self.__IplATA_matrix,b)", "y_neg": " return torch.solve(self.__IplATA_matrix, b)", "retain": " def _direct_solve_I_p_lambda_AT_A_x_eq_b(self, lambda_, b, **kwargs):\n if self.__ATA_matrix is None:\n A = self._matrix.clone()\n self.__ATA_matrix = A.T @ A\n\n if self.__lambda_cache != lambda_:\n lATA = lambda_ * (self.__ATA_matrix)\n torch.diagonal(lATA)[:] += 1\n self.__IplATA_matrix = lATA\n return torch.linalg.solve(self.__IplATA_matrix, b)" }, { "id": 8642, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, x):\n B, D, H, W = x.shape\n N = H * W\n identity = torch.eye(N).cuda()\n # reshape x, s.t. we can use the gmp formulation as a global pooling operation\n x = x.view(B, D, N)\n x = x.permute(0, 2, 1)\n # compute the linear kernel\n K = torch.bmm(x, x.permute(0, 2, 1))\n # solve the linear system (K + lambda * I) * alpha = ones\n A = K + self.lamb * identity\n o = torch.ones(B, N, 1).cuda()\n #alphas, _ = torch.gesv(o, A) # tested using pytorch 1.0.1\n alphas = torch.linalg.solve(A,o) # TODO check it again\n alphas = alphas.view(B, 1, -1) \n xi = torch.bmm(alphas, x)\n xi = xi.view(B, -1)\n return xi", "probing input": " def forward(self, x):\n B, D, H, W = x.shape\n N = H * W\n identity = torch.eye(N).cuda()\n # reshape x, s.t. we can use the gmp formulation as a global pooling operation\n x = x.view(B, D, N)\n x = x.permute(0, 2, 1)\n # compute the linear kernel\n K = torch.bmm(x, x.permute(0, 2, 1))\n # solve the linear system (K + lambda * I) * alpha = ones\n A = K + self.lamb * identity\n o = torch.ones(B, N, 1).cuda()\n #alphas, _ = torch.gesv(o, A) # tested using pytorch 1.0.1\n", "probing input new": " def forward(self, x):\n B, D, H, W = x.shape\n N = H * W\n identity = torch.eye(N).cuda()\n # reshape x, s.t. we can use the gmp formulation as a global pooling operation\n x = x.view(B, D, N)\n x = x.permute(0, 2, 1)\n # compute the linear kernel\n K = torch.bmm(x, x.permute(0, 2, 1))\n # solve the linear system (K + lambda * I) * alpha = ones\n A = K + self.lamb * identity\n o = torch.ones(B, N, 1).cuda()\n #alphas, _ = torch.gesv(o, A) # tested using pytorch 1.0.1\n alphas = torch.", "reference": "alphas=torch.linalg.solve(A,o)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "alphas=torch.linalg.solve(A,o)", "y_neg": " alphas = torch.solve(torch.cat([A, o], 2), torch.cat([torch.ones(B, 1, 1).cuda(), torch.eye(N).cuda()], 1))[0]", "retain": " def forward(self, x):\n B, D, H, W = x.shape\n N = H * W\n identity = torch.eye(N).cuda()\n # reshape x, s.t. we can use the gmp formulation as a global pooling operation\n x = x.view(B, D, N)\n x = x.permute(0, 2, 1)\n # compute the linear kernel\n K = torch.bmm(x, x.permute(0, 2, 1))\n # solve the linear system (K + lambda * I) * alpha = ones\n A = K + self.lamb * identity\n o = torch.ones(B, N, 1).cuda()\n #alphas, _ = torch.gesv(o, A) # tested using pytorch 1.0.1\n alphas = torch.linalg.solve(A,o) # TODO check it again\n alphas = alphas.view(B, 1, -1) \n xi = torch.bmm(alphas, x)\n xi = xi.view(B, -1)\n return xi" }, { "id": 8646, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def anderson_normal_equation(X, relaxation=1.0, regularization = 0.0):\n # Anderson Acceleration\n # Take a matrix X of iterates such that X[:,i] = g(X[:,i-1])\n # Return acceleration for X[:,-1]\n\n assert X.ndim==2, \"X must be a matrix\"\n assert regularization >= 0.0, \"regularization for least-squares must be >=0.0\"\n\n # Compute residuals\n DX = X[:,1:] - X[:,:-1] # DX[:,i] = X[:,i+1] - X[:,i]\n DR = DX[:,1:] - DX[:,:-1] # DR[:,i] = DX[:,i+1] - DX[:,i] = X[:,i+2] - 2*X[:,i+1] + X[:,i]\n\n # # use QR factorization\n # q, r = torch.qr(DR)\n # gamma, _ = torch.triangular_solve( (q.t()@DX[:,-1]).unsqueeze(1), r )\n # gamma = gamma.squeeze(1)\n\n # solve unconstrained least-squares problem\n if regularization != 0.0: \n RR = DR.t()@DR + regularization * torch.eye(DR.size(1))\n else: \n RR = DR.t()@DR\n\n projected_residual = DR.t()@DX[:,-1].unsqueeze(1)\n \n gamma = torch.linalg.solve( RR, projected_residual )\n gamma = gamma.view(-1)\n\n # compute acceleration\n extr = X[:,-2] + DX[:,-1] - (DX[:,:-1]+DR)@gamma\n\n if relaxation!=1:\n assert relaxation>0, \"relaxation must be positive\"\n # compute solution of the contraint optimization problem s.t. gamma = X[:,1:]@alpha\n alpha = torch.zeros(gamma.numel()+1).to(DX.device)\n alpha[0] = gamma[0]\n alpha[1:-1] = gamma[1:] - gamma[:-1]\n alpha[-1] = 1 - gamma[-1]\n extr = relaxation*extr + (1-relaxation)*X[:,:-1]@alpha\n\n return extr", "probing input": "def anderson_normal_equation(X, relaxation=1.0, regularization = 0.0):\n # Anderson Acceleration\n # Take a matrix X of iterates such that X[:,i] = g(X[:,i-1])\n # Return acceleration for X[:,-1]\n\n assert X.ndim==2, \"X must be a matrix\"\n assert regularization >= 0.0, \"regularization for least-squares must be >=0.0\"\n\n # Compute residuals\n DX = X[:,1:] - X[:,:-1] # DX[:,i] = X[:,i+1] - X[:,i]\n DR = DX[:,1:] - DX[:,:-1] # DR[:,i] = DX[:,i+1] - DX[:,i] = X[:,i+2] - 2*X[:,i+1] + X[:,i]\n\n # # use QR factorization\n # q, r = torch.qr(DR)\n # gamma, _ = torch.triangular_solve( (q.t()@DX[:,-1]).unsqueeze(1), r )\n # gamma = gamma.squeeze(1)\n\n # solve unconstrained least-squares problem\n if regularization != 0.0: \n RR = DR.t()@DR + regularization * torch.eye(DR.size(1))\n else: \n RR = DR.t()@DR\n\n projected_residual = DR.t()@DX[:,-1].unsqueeze(1)\n \n", "probing input new": "def anderson_normal_equation(X, relaxation=1.0, regularization = 0.0):\n # Anderson Acceleration\n # Take a matrix X of iterates such that X[:,i] = g(X[:,i-1])\n # Return acceleration for X[:,-1]\n\n assert X.ndim==2, \"X must be a matrix\"\n assert regularization >= 0.0, \"regularization for least-squares must be >=0.0\"\n\n # Compute residuals\n DX = X[:,1:] - X[:,:-1] # DX[:,i] = X[:,i+1] - X[:,i]\n DR = DX[:,1:] - DX[:,:-1] # DR[:,i] = DX[:,i+1] - DX[:,i] = X[:,i+2] - 2*X[:,i+1] + X[:,i]\n\n # # use QR factorization\n # q, r = torch.qr(DR)\n # gamma, _ = torch.triangular_solve( (q.t()@DX[:,-1]).unsqueeze(1), r )\n # gamma = gamma.squeeze(1)\n\n # solve unconstrained least-squares problem\n if regularization != 0.0: \n RR = DR.t()@DR + regularization * torch.eye(DR.size(1))\n else: \n RR = DR.t()@DR\n\n projected_residual = DR.t()@DX[:,-1].unsqueeze(1)\n \n gamma = torch.", "reference": "gamma=torch.linalg.solve(RR,projected_residual)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "gamma=torch.linalg.solve(RR,projected_residual)", "y_neg": " gamma = torch.solve(projected_residual, RR)[0]", "retain": "def anderson_normal_equation(X, relaxation=1.0, regularization = 0.0):\n # Anderson Acceleration\n # Take a matrix X of iterates such that X[:,i] = g(X[:,i-1])\n # Return acceleration for X[:,-1]\n\n assert X.ndim==2, \"X must be a matrix\"\n assert regularization >= 0.0, \"regularization for least-squares must be >=0.0\"\n\n # Compute residuals\n DX = X[:,1:] - X[:,:-1] # DX[:,i] = X[:,i+1] - X[:,i]\n DR = DX[:,1:] - DX[:,:-1] # DR[:,i] = DX[:,i+1] - DX[:,i] = X[:,i+2] - 2*X[:,i+1] + X[:,i]\n\n # # use QR factorization\n # q, r = torch.qr(DR)\n # gamma, _ = torch.triangular_solve( (q.t()@DX[:,-1]).unsqueeze(1), r )\n # gamma = gamma.squeeze(1)\n\n # solve unconstrained least-squares problem\n if regularization != 0.0: \n RR = DR.t()@DR + regularization * torch.eye(DR.size(1))\n else: \n RR = DR.t()@DR\n\n projected_residual = DR.t()@DX[:,-1].unsqueeze(1)\n \n gamma = torch.linalg.solve( RR, projected_residual )\n gamma = gamma.view(-1)\n\n # compute acceleration\n extr = X[:,-2] + DX[:,-1] - (DX[:,:-1]+DR)@gamma\n\n if relaxation!=1:\n assert relaxation>0, \"relaxation must be positive\"\n # compute solution of the contraint optimization problem s.t. gamma = X[:,1:]@alpha\n alpha = torch.zeros(gamma.numel()+1).to(DX.device)\n alpha[0] = gamma[0]\n alpha[1:-1] = gamma[1:] - gamma[:-1]\n alpha[-1] = 1 - gamma[-1]\n extr = relaxation*extr + (1-relaxation)*X[:,:-1]@alpha\n\n return extr" }, { "id": 8650, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exactsolve(A: LinearOperator, B: torch.Tensor,\n E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n # A: (*BA, na, na)\n # B: (*BB, na, ncols)\n # E: (*BE, ncols)\n # M: (*BM, na, na)\n if E is None:\n Amatrix = A.fullmatrix() # (*BA, na, na)\n x = torch.linalg.solve(Amatrix, B) # (*BAB, na, ncols)\n elif M is None:\n Amatrix = A.fullmatrix()\n x = _solve_ABE(Amatrix, B, E)\n else:\n Mmatrix = M.fullmatrix() # (*BM, na, na)\n L = torch.linalg.cholesky(Mmatrix) # (*BM, na, na)\n Linv = torch.inverse(L) # (*BM, na, na)\n LinvT = Linv.transpose(-2, -1).conj() # (*BM, na, na)\n A2 = torch.matmul(Linv, A.mm(LinvT)) # (*BAM, na, na)\n B2 = torch.matmul(Linv, B) # (*BBM, na, ncols)\n\n X2 = _solve_ABE(A2, B2, E) # (*BABEM, na, ncols)\n x = torch.matmul(LinvT, X2) # (*BABEM, na, ncols)\n return x", "probing input": "def exactsolve(A: LinearOperator, B: torch.Tensor,\n E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n # A: (*BA, na, na)\n # B: (*BB, na, ncols)\n # E: (*BE, ncols)\n # M: (*BM, na, na)\n if E is None:\n Amatrix = A.fullmatrix() # (*BA, na, na)\n", "probing input new": "def exactsolve(A: LinearOperator, B: torch.Tensor,\n E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n # A: (*BA, na, na)\n # B: (*BB, na, ncols)\n # E: (*BE, ncols)\n # M: (*BM, na, na)\n if E is None:\n Amatrix = A.fullmatrix() # (*BA, na, na)\n x = torch.", "reference": "x=torch.linalg.solve(Amatrix,B)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x=torch.linalg.solve(Amatrix,B)", "y_neg": " x = torch.solve(Amatrix, B)[0] # (*BB, na, ncols)", "retain": "def exactsolve(A: LinearOperator, B: torch.Tensor,\n E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n \"\"\"\n # A: (*BA, na, na)\n # B: (*BB, na, ncols)\n # E: (*BE, ncols)\n # M: (*BM, na, na)\n if E is None:\n Amatrix = A.fullmatrix() # (*BA, na, na)\n x = torch.linalg.solve(Amatrix, B) # (*BAB, na, ncols)\n elif M is None:\n Amatrix = A.fullmatrix()\n x = _solve_ABE(Amatrix, B, E)\n else:\n Mmatrix = M.fullmatrix() # (*BM, na, na)\n L = torch.linalg.cholesky(Mmatrix) # (*BM, na, na)\n Linv = torch.inverse(L) # (*BM, na, na)\n LinvT = Linv.transpose(-2, -1).conj() # (*BM, na, na)\n A2 = torch.matmul(Linv, A.mm(LinvT)) # (*BAM, na, na)\n B2 = torch.matmul(Linv, B) # (*BBM, na, ncols)\n\n X2 = _solve_ABE(A2, B2, E) # (*BABEM, na, ncols)\n x = torch.matmul(LinvT, X2) # (*BABEM, na, ncols)\n return x" }, { "id": 8658, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def broydens_method(f, J, x0, tol=1e-5, max_iter=100):\n \"\"\"\n Broyden's method for finding roots of a function.\n\n Usage:\n f = lambda x: x**2 - 1\n J = lambda x: 2*x\n broydens_method(f, J, 0.5)\n tensor(1.0000)\n\n \"\"\"\n x = x0\n B = J(x)\n for _ in range(max_iter):\n s = torch.linalg.solve(-f(x), B)[0]\n x_new = x + s\n if torch.norm(x_new - x) < tol:\n return x_new\n y = f(x_new) - f(x)\n B += (y - B @ s) @ s.T / (s.T @ s)\n x = x_new\n return x", "probing input": "def broydens_method(f, J, x0, tol=1e-5, max_iter=100):\n \"\"\"\n Broyden's method for finding roots of a function.\n\n Usage:\n f = lambda x: x**2 - 1\n J = lambda x: 2*x\n broydens_method(f, J, 0.5)\n tensor(1.0000)\n\n \"\"\"\n x = x0\n B = J(x)\n for _ in range(max_iter):\n", "probing input new": "def broydens_method(f, J, x0, tol=1e-5, max_iter=100):\n \"\"\"\n Broyden's method for finding roots of a function.\n\n Usage:\n f = lambda x: x**2 - 1\n J = lambda x: 2*x\n broydens_method(f, J, 0.5)\n tensor(1.0000)\n\n \"\"\"\n x = x0\n B = J(x)\n for _ in range(max_iter):\n s = torch.", "reference": "s=torch.linalg.solve(-f(x),B)[0]", "reference dict": { "B": "J" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "s=torch.linalg.solve(-f(x),B)[0]", "y_neg": " s = torch.solve(B, J(x))[0]", "retain": "def broydens_method(f, J, x0, tol=1e-5, max_iter=100):\n \"\"\"\n Broyden's method for finding roots of a function.\n\n Usage:\n f = lambda x: x**2 - 1\n J = lambda x: 2*x\n broydens_method(f, J, 0.5)\n tensor(1.0000)\n\n \"\"\"\n x = x0\n B = J(x)\n for _ in range(max_iter):\n s = torch.linalg.solve(-f(x), B)[0]\n x_new = x + s\n if torch.norm(x_new - x) < tol:\n return x_new\n y = f(x_new) - f(x)\n B += (y - B @ s) @ s.T / (s.T @ s)\n x = x_new\n return x" }, { "id": 8662, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a)[0]\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n if is_torch_1_8_plus:\n return torch.linalg.solve(a, b)\n else:\n return torch.solve(b, a)[0]", "probing input": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a)[0]\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n", "probing input new": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a)[0]\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.", "reference": "returntorch.linalg.solve(a,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(a,b)", "y_neg": " return torch.solve(b, a)[0]", "retain": "def solve(b: Union[torch.Tensor, ComplexTensor], a: Union[torch.Tensor, ComplexTensor]):\n \"\"\"Solve the linear equation ax = b.\"\"\"\n # NOTE: Do not mix ComplexTensor and torch.complex in the input!\n # NOTE (wangyou): Until PyTorch 1.9.0, torch.solve does not support\n # mixed input with complex and real tensors.\n if isinstance(a, ComplexTensor) or isinstance(b, ComplexTensor):\n if isinstance(a, ComplexTensor) and isinstance(b, ComplexTensor):\n return FC.solve(b, a)[0]\n else:\n return matmul(inverse(a), b)\n elif is_torch_1_9_plus and (torch.is_complex(a) or torch.is_complex(b)):\n if torch.is_complex(a) and torch.is_complex(b):\n return torch.linalg.solve(a, b)\n else:\n return matmul(inverse(a), b)\n else:\n if is_torch_1_8_plus:\n return torch.linalg.solve(a, b)\n else:\n return torch.solve(b, a)[0]" }, { "id": 8663, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _solve_sytem(self, Atb: torch.Tensor, AtA: torch.Tensor) -> torch.Tensor:\n return torch.linalg.solve(AtA, Atb).squeeze(2)", "probing input": " def _solve_sytem(self, Atb: torch.Tensor, AtA: torch.Tensor) -> torch.Tensor:\n", "probing input new": " def _solve_sytem(self, Atb: torch.Tensor, AtA: torch.Tensor) -> torch.Tensor:\n return torch.", "reference": "returntorch.linalg.solve(AtA,Atb).squeeze(2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(AtA,Atb).squeeze(2)", "y_neg": " return torch.solve(AtA, Atb)", "retain": " def _solve_sytem(self, Atb: torch.Tensor, AtA: torch.Tensor) -> torch.Tensor:\n return torch.linalg.solve(AtA, Atb).squeeze(2)" }, { "id": 8671, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_solve(self, rhs, lhs=None, cholesky=False):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs.requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n if lhs is not None:\n lhs.requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n _wrapped_cg = MagicMock(wraps=linear_operator.utils.linear_cg)\n with patch(\"linear_operator.utils.linear_cg\", new=_wrapped_cg) as linear_cg_mock:\n with linear_operator.settings.max_cholesky_size(\n math.inf if cholesky else 0\n ), linear_operator.settings.cg_tolerance(1e-4):\n # Perform the solve\n if lhs is not None:\n res = linear_operator.solve(linear_op, rhs, lhs)\n actual = lhs_copy @ evaluated.inverse() @ rhs_copy\n else:\n res = torch.linalg.solve(linear_op, rhs)\n actual = evaluated.inverse().matmul(rhs_copy)\n self.assertAllClose(res, actual, **self.tolerances[\"solve\"])\n\n # Perform backward pass\n grad = torch.randn_like(res)\n res.backward(gradient=grad)\n actual.backward(gradient=grad)\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"grad\"])\n self.assertAllClose(rhs.grad, rhs_copy.grad, **self.tolerances[\"grad\"])\n if lhs is not None:\n self.assertAllClose(lhs.grad, lhs_copy.grad, **self.tolerances[\"grad\"])\n\n # Determine if we've called CG or not\n if not cholesky and self.__class__.should_call_cg:\n self.assertTrue(linear_cg_mock.called)\n else:\n self.assertFalse(linear_cg_mock.called)", "probing input": " def _test_solve(self, rhs, lhs=None, cholesky=False):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs.requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n if lhs is not None:\n lhs.requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n _wrapped_cg = MagicMock(wraps=linear_operator.utils.linear_cg)\n with patch(\"linear_operator.utils.linear_cg\", new=_wrapped_cg) as linear_cg_mock:\n with linear_operator.settings.max_cholesky_size(\n math.inf if cholesky else 0\n ), linear_operator.settings.cg_tolerance(1e-4):\n # Perform the solve\n if lhs is not None:\n res = linear_operator.solve(linear_op, rhs, lhs)\n actual = lhs_copy @ evaluated.inverse() @ rhs_copy\n else:\n", "probing input new": " def _test_solve(self, rhs, lhs=None, cholesky=False):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs.requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n if lhs is not None:\n lhs.requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n _wrapped_cg = MagicMock(wraps=linear_operator.utils.linear_cg)\n with patch(\"linear_operator.utils.linear_cg\", new=_wrapped_cg) as linear_cg_mock:\n with linear_operator.settings.max_cholesky_size(\n math.inf if cholesky else 0\n ), linear_operator.settings.cg_tolerance(1e-4):\n # Perform the solve\n if lhs is not None:\n res = linear_operator.solve(linear_op, rhs, lhs)\n actual = lhs_copy @ evaluated.inverse() @ rhs_copy\n else:\n res = torch.", "reference": "res=torch.linalg.solve(linear_op,rhs)", "reference dict": { "_wrapped_cg": "MagicMock" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "res=torch.linalg.solve(linear_op,rhs)", "y_neg": " res = torch.solve(evaluated, rhs_copy)", "retain": " def _test_solve(self, rhs, lhs=None, cholesky=False):\n linear_op = self.create_linear_op().detach().requires_grad_(True)\n linear_op_copy = torch.clone(linear_op).detach().requires_grad_(True)\n evaluated = self.evaluate_linear_op(linear_op_copy)\n evaluated.register_hook(self._ensure_symmetric_grad)\n\n # Create a test right hand side and left hand side\n rhs.requires_grad_(True)\n rhs_copy = rhs.clone().detach().requires_grad_(True)\n if lhs is not None:\n lhs.requires_grad_(True)\n lhs_copy = lhs.clone().detach().requires_grad_(True)\n\n _wrapped_cg = MagicMock(wraps=linear_operator.utils.linear_cg)\n with patch(\"linear_operator.utils.linear_cg\", new=_wrapped_cg) as linear_cg_mock:\n with linear_operator.settings.max_cholesky_size(\n math.inf if cholesky else 0\n ), linear_operator.settings.cg_tolerance(1e-4):\n # Perform the solve\n if lhs is not None:\n res = linear_operator.solve(linear_op, rhs, lhs)\n actual = lhs_copy @ evaluated.inverse() @ rhs_copy\n else:\n res = torch.linalg.solve(linear_op, rhs)\n actual = evaluated.inverse().matmul(rhs_copy)\n self.assertAllClose(res, actual, **self.tolerances[\"solve\"])\n\n # Perform backward pass\n grad = torch.randn_like(res)\n res.backward(gradient=grad)\n actual.backward(gradient=grad)\n for arg, arg_copy in zip(linear_op.representation(), linear_op_copy.representation()):\n if arg_copy.requires_grad and arg_copy.is_leaf and arg_copy.grad is not None:\n self.assertAllClose(arg.grad, arg_copy.grad, **self.tolerances[\"grad\"])\n self.assertAllClose(rhs.grad, rhs_copy.grad, **self.tolerances[\"grad\"])\n if lhs is not None:\n self.assertAllClose(lhs.grad, lhs_copy.grad, **self.tolerances[\"grad\"])\n\n # Determine if we've called CG or not\n if not cholesky and self.__class__.should_call_cg:\n self.assertTrue(linear_cg_mock.called)\n else:\n self.assertFalse(linear_cg_mock.called)" }, { "id": 8679, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def proj_tangent(x, u):\n assert x.shape[-2:] == u.shape[-2:], \"Wrong shapes\"\n x, u = torch.broadcast_tensors(x, u)\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n u = u.reshape(-1, x_shape[-2], x_shape[-1])\n xt = x.transpose(-1, -2)\n batch_size, n = x.shape[0:2]\n\n I = torch.eye(n, dtype=x.dtype, device=x.device)\n I = I.expand_as(x)\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [xt, I]])\n\n B = A[:, :, 1:]\n\n z1 = mu.sum(dim=-1).unsqueeze(-1)\n zt1 = mu.sum(dim=-2).unsqueeze(-1)\n\n b = torch.cat(\n [z1, zt1],\n dim=1,\n )\n rhs = B.transpose(1, 2) @ (b - A[:, :, 0:1])\n lhs = B.transpose(1, 2) @ B\n zeta = torch.linalg.solve(lhs, rhs)\n alpha = torch.cat(\n [\n torch.ones(batch_size, 1, 1, device=x.device, dtype=x.dtype),\n zeta[:, 0 : n - 1],\n ],\n dim=1,\n )\n beta = zeta[:, n - 1 : 2 * n - 1]\n rgrad = mu - (alpha + beta.transpose(-1, -2)) * x\n\n rgrad = rgrad.reshape(x_shape)\n return rgrad", "probing input": "def proj_tangent(x, u):\n assert x.shape[-2:] == u.shape[-2:], \"Wrong shapes\"\n x, u = torch.broadcast_tensors(x, u)\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n u = u.reshape(-1, x_shape[-2], x_shape[-1])\n xt = x.transpose(-1, -2)\n batch_size, n = x.shape[0:2]\n\n I = torch.eye(n, dtype=x.dtype, device=x.device)\n I = I.expand_as(x)\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [xt, I]])\n\n B = A[:, :, 1:]\n\n z1 = mu.sum(dim=-1).unsqueeze(-1)\n zt1 = mu.sum(dim=-2).unsqueeze(-1)\n\n b = torch.cat(\n [z1, zt1],\n dim=1,\n )\n rhs = B.transpose(1, 2) @ (b - A[:, :, 0:1])\n lhs = B.transpose(1, 2) @ B\n", "probing input new": "def proj_tangent(x, u):\n assert x.shape[-2:] == u.shape[-2:], \"Wrong shapes\"\n x, u = torch.broadcast_tensors(x, u)\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n u = u.reshape(-1, x_shape[-2], x_shape[-1])\n xt = x.transpose(-1, -2)\n batch_size, n = x.shape[0:2]\n\n I = torch.eye(n, dtype=x.dtype, device=x.device)\n I = I.expand_as(x)\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [xt, I]])\n\n B = A[:, :, 1:]\n\n z1 = mu.sum(dim=-1).unsqueeze(-1)\n zt1 = mu.sum(dim=-2).unsqueeze(-1)\n\n b = torch.cat(\n [z1, zt1],\n dim=1,\n )\n rhs = B.transpose(1, 2) @ (b - A[:, :, 0:1])\n lhs = B.transpose(1, 2) @ B\n zeta = torch.", "reference": "zeta=torch.linalg.solve(lhs,rhs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "zeta=torch.linalg.solve(lhs,rhs)", "y_neg": " zeta = torch.solve(lhs, rhs)[0]", "retain": "def proj_tangent(x, u):\n assert x.shape[-2:] == u.shape[-2:], \"Wrong shapes\"\n x, u = torch.broadcast_tensors(x, u)\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n u = u.reshape(-1, x_shape[-2], x_shape[-1])\n xt = x.transpose(-1, -2)\n batch_size, n = x.shape[0:2]\n\n I = torch.eye(n, dtype=x.dtype, device=x.device)\n I = I.expand_as(x)\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [xt, I]])\n\n B = A[:, :, 1:]\n\n z1 = mu.sum(dim=-1).unsqueeze(-1)\n zt1 = mu.sum(dim=-2).unsqueeze(-1)\n\n b = torch.cat(\n [z1, zt1],\n dim=1,\n )\n rhs = B.transpose(1, 2) @ (b - A[:, :, 0:1])\n lhs = B.transpose(1, 2) @ B\n zeta = torch.linalg.solve(lhs, rhs)\n alpha = torch.cat(\n [\n torch.ones(batch_size, 1, 1, device=x.device, dtype=x.dtype),\n zeta[:, 0 : n - 1],\n ],\n dim=1,\n )\n beta = zeta[:, n - 1 : 2 * n - 1]\n rgrad = mu - (alpha + beta.transpose(-1, -2)) * x\n\n rgrad = rgrad.reshape(x_shape)\n return rgrad" }, { "id": 8690, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve(A: torch.tensor, b: torch.Tensor, type: str):\n # Use pytorch to solve the linear system\n if type == \"torch\":\n return torch.linalg.solve(A, b)\n\n # Use colrow to solve the linear system\n nrows = A.shape[-1]\n ncols = b.shape[-1]\n dim = cal_dim(A, b)\n resid_step = 10\n max_niter = int(1.5 * nrows)\n rtol = 1e-6\n atol = 1e-6\n eps = 1e-8\n\n if torch.allclose(b, b * 0, rtol=rtol, atol=atol):\n x0 = torch.zeros((*dim, nrows, ncols), dtype=A.dtype, device=A.device)\n return x0\n\n presec_func = lambda x: x\n hermit_base = True\n weight_trans_func, value_trans, col_swap = decompose(A, b, dim, hermit_base)\n value_norm = value_trans.norm(dim=-2, keepdim=True)\n stop_matrix = torch.max(rtol * value_norm, atol * torch.ones_like(value_norm))\n\n weight_shape = (ncols, *dim, nrows, 1) if col_swap else (*dim, nrows, ncols)\n\n x_sim = torch.zeros(weight_shape, dtype=A.dtype, device=A.device)\n r_sim = value_trans - weight_trans_func(x_sim)\n z_sim = presec_func(r_sim)\n p_sim = z_sim\n risk = transf(r_sim, z_sim)\n best_resid = r_sim.norm(dim=-2).max().item()\n best_x_sim = x_sim\n\n for k in range(1, max_niter + 1):\n weight_sim = weight_trans_func(p_sim)\n alphak = risk / norm(transf(p_sim, weight_sim), eps)\n x_sim2 = x_sim + alphak * p_sim\n\n if resid_step != 0 and k % resid_step == 0:\n r_sim2 = value_trans - weight_trans_func(x_sim2)\n else:\n r_sim2 = r_sim - alphak * weight_sim\n\n resid = r_sim2\n resid_norm = resid.norm(dim=-2, keepdim=True)\n\n max_resid_norm = resid_norm.max().item()\n if max_resid_norm < best_resid:\n best_resid = max_resid_norm\n best_x_sim = x_sim2\n\n z_sim2 = presec_func(r_sim2)\n risk2 = transf(r_sim2, z_sim2)\n b_risk = risk2 / norm(risk, eps)\n p_sim2 = z_sim2 + b_risk * p_sim\n\n p_sim = p_sim2\n z_sim = z_sim2\n x_sim = x_sim2\n r_sim = r_sim2\n risk = risk2\n\n x_sim2 = best_x_sim\n if col_swap:\n x_sim2 = x_sim2.transpose(0, -1).squeeze(0)\n return x_sim2", "probing input": "def solve(A: torch.tensor, b: torch.Tensor, type: str):\n # Use pytorch to solve the linear system\n if type == \"torch\":\n", "probing input new": "def solve(A: torch.tensor, b: torch.Tensor, type: str):\n # Use pytorch to solve the linear system\n if type == \"torch\":\n return torch.", "reference": "returntorch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(A,b)", "y_neg": " return torch.solve(A, b)", "retain": "def solve(A: torch.tensor, b: torch.Tensor, type: str):\n # Use pytorch to solve the linear system\n if type == \"torch\":\n return torch.linalg.solve(A, b)\n\n # Use colrow to solve the linear system\n nrows = A.shape[-1]\n ncols = b.shape[-1]\n dim = cal_dim(A, b)\n resid_step = 10\n max_niter = int(1.5 * nrows)\n rtol = 1e-6\n atol = 1e-6\n eps = 1e-8\n\n if torch.allclose(b, b * 0, rtol=rtol, atol=atol):\n x0 = torch.zeros((*dim, nrows, ncols), dtype=A.dtype, device=A.device)\n return x0\n\n presec_func = lambda x: x\n hermit_base = True\n weight_trans_func, value_trans, col_swap = decompose(A, b, dim, hermit_base)\n value_norm = value_trans.norm(dim=-2, keepdim=True)\n stop_matrix = torch.max(rtol * value_norm, atol * torch.ones_like(value_norm))\n\n weight_shape = (ncols, *dim, nrows, 1) if col_swap else (*dim, nrows, ncols)\n\n x_sim = torch.zeros(weight_shape, dtype=A.dtype, device=A.device)\n r_sim = value_trans - weight_trans_func(x_sim)\n z_sim = presec_func(r_sim)\n p_sim = z_sim\n risk = transf(r_sim, z_sim)\n best_resid = r_sim.norm(dim=-2).max().item()\n best_x_sim = x_sim\n\n for k in range(1, max_niter + 1):\n weight_sim = weight_trans_func(p_sim)\n alphak = risk / norm(transf(p_sim, weight_sim), eps)\n x_sim2 = x_sim + alphak * p_sim\n\n if resid_step != 0 and k % resid_step == 0:\n r_sim2 = value_trans - weight_trans_func(x_sim2)\n else:\n r_sim2 = r_sim - alphak * weight_sim\n\n resid = r_sim2\n resid_norm = resid.norm(dim=-2, keepdim=True)\n\n max_resid_norm = resid_norm.max().item()\n if max_resid_norm < best_resid:\n best_resid = max_resid_norm\n best_x_sim = x_sim2\n\n z_sim2 = presec_func(r_sim2)\n risk2 = transf(r_sim2, z_sim2)\n b_risk = risk2 / norm(risk, eps)\n p_sim2 = z_sim2 + b_risk * p_sim\n\n p_sim = p_sim2\n z_sim = z_sim2\n x_sim = x_sim2\n r_sim = r_sim2\n risk = risk2\n\n x_sim2 = best_x_sim\n if col_swap:\n x_sim2 = x_sim2.transpose(0, -1).squeeze(0)\n return x_sim2" }, { "id": 8716, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def solve_system(self, rhs, factor, u0, t):\n r\"\"\"\n Simple linear solver for :math:`(I-factor\\cdot A)\\vec{u}=\\vec{rhs}`.\n\n Parameters\n ----------\n rhs : dtype_f\n Right-hand side for the linear system.\n factor : float\n Abbrev. for the local stepsize (or any other factor required).\n u0 : dtype_u\n Initial guess for the iterative solver.\n t : float\n Current time (e.g. for time-dependent BCs).\n\n Returns\n -------\n sol : dtype_u\n The solution of the linear solver.\n \"\"\"\n solver_type, Id, A, nvars, sol = (\n self.solver_type,\n self.Id,\n self.A,\n self.nvars,\n self.u_init,\n )\n\n if solver_type == 'direct':\n sol[:] = torch.linalg.solve(Id - factor * A, rhs.flatten()).reshape(nvars)\n # TODO: implement torch equivalent of cg\n # elif solver_type == 'CG':\n # sol[:] = cg(\n # Id - factor * A,\n # rhs.flatten(),\n # x0=u0.flatten(),\n # tol=lintol,\n # maxiter=liniter,\n # atol=0,\n # callback=self.work_counters[solver_type],\n # )[0].reshape(nvars)\n else:\n raise ValueError(f'solver type \"{solver_type}\" not known!')\n\n return sol", "probing input": " def solve_system(self, rhs, factor, u0, t):\n r\"\"\"\n Simple linear solver for :math:`(I-factor\\cdot A)\\vec{u}=\\vec{rhs}`.\n\n Parameters\n ----------\n rhs : dtype_f\n Right-hand side for the linear system.\n factor : float\n Abbrev. for the local stepsize (or any other factor required).\n u0 : dtype_u\n Initial guess for the iterative solver.\n t : float\n Current time (e.g. for time-dependent BCs).\n\n Returns\n -------\n sol : dtype_u\n The solution of the linear solver.\n \"\"\"\n solver_type, Id, A, nvars, sol = (\n self.solver_type,\n self.Id,\n self.A,\n self.nvars,\n self.u_init,\n )\n\n if solver_type == 'direct':\n", "probing input new": " def solve_system(self, rhs, factor, u0, t):\n r\"\"\"\n Simple linear solver for :math:`(I-factor\\cdot A)\\vec{u}=\\vec{rhs}`.\n\n Parameters\n ----------\n rhs : dtype_f\n Right-hand side for the linear system.\n factor : float\n Abbrev. for the local stepsize (or any other factor required).\n u0 : dtype_u\n Initial guess for the iterative solver.\n t : float\n Current time (e.g. for time-dependent BCs).\n\n Returns\n -------\n sol : dtype_u\n The solution of the linear solver.\n \"\"\"\n solver_type, Id, A, nvars, sol = (\n self.solver_type,\n self.Id,\n self.A,\n self.nvars,\n self.u_init,\n )\n\n if solver_type == 'direct':\n sol[:] = torch.", "reference": "sol[:]=torch.linalg.solve(Id-factor*A,rhs.flatten()).reshape(nvars)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "sol[:]=torch.linalg.solve(Id-factor*A,rhs.flatten()).reshape(nvars)", "y_neg": " sol[:] = torch.solve(Id + factor * A, rhs)[0]", "retain": " def solve_system(self, rhs, factor, u0, t):\n r\"\"\"\n Simple linear solver for :math:`(I-factor\\cdot A)\\vec{u}=\\vec{rhs}`.\n\n Parameters\n ----------\n rhs : dtype_f\n Right-hand side for the linear system.\n factor : float\n Abbrev. for the local stepsize (or any other factor required).\n u0 : dtype_u\n Initial guess for the iterative solver.\n t : float\n Current time (e.g. for time-dependent BCs).\n\n Returns\n -------\n sol : dtype_u\n The solution of the linear solver.\n \"\"\"\n solver_type, Id, A, nvars, sol = (\n self.solver_type,\n self.Id,\n self.A,\n self.nvars,\n self.u_init,\n )\n\n if solver_type == 'direct':\n sol[:] = torch.linalg.solve(Id - factor * A, rhs.flatten()).reshape(nvars)\n # TODO: implement torch equivalent of cg\n # elif solver_type == 'CG':\n # sol[:] = cg(\n # Id - factor * A,\n # rhs.flatten(),\n # x0=u0.flatten(),\n # tol=lintol,\n # maxiter=liniter,\n # atol=0,\n # callback=self.work_counters[solver_type],\n # )[0].reshape(nvars)\n else:\n raise ValueError(f'solver type \"{solver_type}\" not known!')\n\n return sol" }, { "id": 8728, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def CR_NaiveNewton(weight, grad, hessian, l2lambda=0, hessian_device='cpu'):\n original_device = weight.device\n\n smoothhessian = hessian.to(hessian_device) + (l2lambda)*torch.eye(hessian.shape[0]).to(hessian_device)\n newton = torch.linalg.solve(smoothhessian, grad.to(hessian_device)).to(original_device)\n\n # removal, towards positive gradient direction\n new_weight = weight + newton\n\n return new_weight", "probing input": "def CR_NaiveNewton(weight, grad, hessian, l2lambda=0, hessian_device='cpu'):\n original_device = weight.device\n\n smoothhessian = hessian.to(hessian_device) + (l2lambda)*torch.eye(hessian.shape[0]).to(hessian_device)\n", "probing input new": "def CR_NaiveNewton(weight, grad, hessian, l2lambda=0, hessian_device='cpu'):\n original_device = weight.device\n\n smoothhessian = hessian.to(hessian_device) + (l2lambda)*torch.eye(hessian.shape[0]).to(hessian_device)\n newton = torch.", "reference": "newton=torch.linalg.solve(smoothhessian,grad.to(hessian_device)).to(original_device)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "newton=torch.linalg.solve(smoothhessian,grad.to(hessian_device)).to(original_device)", "y_neg": " newton = torch.solve(smoothhessian, grad.to(hessian_device))", "retain": "def CR_NaiveNewton(weight, grad, hessian, l2lambda=0, hessian_device='cpu'):\n original_device = weight.device\n\n smoothhessian = hessian.to(hessian_device) + (l2lambda)*torch.eye(hessian.shape[0]).to(hessian_device)\n newton = torch.linalg.solve(smoothhessian, grad.to(hessian_device)).to(original_device)\n\n # removal, towards positive gradient direction\n new_weight = weight + newton\n\n return new_weight" }, { "id": 8736, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def direct_newton(env: DiffEnv, cmd: torch.Tensor, reg_ctrl: float = 0.) -> (torch.Tensor, torch.Tensor):\n \"\"\"\n Compute a Newton step directly, used to test auto_lin_quad on linear quadratic problem.\n :param env: control environment\n :param cmd: initial command from where to do the Newton step\n :param reg_ctrl: regularization on the control variables, i.e., the command\n :return\n - cmd_opt_newton - optimal command computed by a Newton step\n - opt_newton - optimal value computed by a Newton step\n \"\"\"\n horizon, dim_ctr = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n feasible = True\n\n if feasible:\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n tic = time.time()\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctr * horizon)\n cmd_opt_newton = - torch.linalg.solve(hess, grad.unsqueeze(-1), ).view(-1)\n # hess = hess.detach().numpy()\n # grad = grad.unsqueeze(-1).detach().numpy()\n # cmd_opt_newton = cg(hess, grad)[0]\n # cmd_opt_newton = - torch.from_numpy(cmd_opt_newton)\n print(f'Time Newton: {time.time() - tic}')\n\n cmd_opt_newton = cmd_opt_newton.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n lin_dyn_states, lin_dyn_ctrls, \\\n quad_cost_states, lin_cost_states, \\\n quad_cost_ctrls, lin_cost_ctrls = compute_lin_quad_approx(traj, costs, reg_ctrl)\n lin_quad_env = LinQuadEnv(lin_dyn_states, lin_dyn_ctrls,\n quad_cost_states, lin_cost_states,\n quad_cost_ctrls, lin_cost_ctrls)\n traj_opt, costs_opt = lin_quad_env.forward(cmd_opt_newton)\n opt_newton = sum(costs_opt)\n else:\n cmd_opt_newton = None\n opt_newton = None\n return cmd_opt_newton, opt_newton", "probing input": "def direct_newton(env: DiffEnv, cmd: torch.Tensor, reg_ctrl: float = 0.) -> (torch.Tensor, torch.Tensor):\n \"\"\"\n Compute a Newton step directly, used to test auto_lin_quad on linear quadratic problem.\n :param env: control environment\n :param cmd: initial command from where to do the Newton step\n :param reg_ctrl: regularization on the control variables, i.e., the command\n :return\n - cmd_opt_newton - optimal command computed by a Newton step\n - opt_newton - optimal value computed by a Newton step\n \"\"\"\n horizon, dim_ctr = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n feasible = True\n\n if feasible:\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n tic = time.time()\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctr * horizon)\n", "probing input new": "def direct_newton(env: DiffEnv, cmd: torch.Tensor, reg_ctrl: float = 0.) -> (torch.Tensor, torch.Tensor):\n \"\"\"\n Compute a Newton step directly, used to test auto_lin_quad on linear quadratic problem.\n :param env: control environment\n :param cmd: initial command from where to do the Newton step\n :param reg_ctrl: regularization on the control variables, i.e., the command\n :return\n - cmd_opt_newton - optimal command computed by a Newton step\n - opt_newton - optimal value computed by a Newton step\n \"\"\"\n horizon, dim_ctr = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n feasible = True\n\n if feasible:\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n tic = time.time()\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctr * horizon)\n cmd_opt_newton = - torch.", "reference": "cmd_opt_newton=-torch.linalg.solve(hess,grad.unsqueeze(-1),).view(-1)", "reference dict": { "lin_quad_env": "LinQuadEnv" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "cmd_opt_newton=-torch.linalg.solve(hess,grad.unsqueeze(-1),).view(-1)", "y_neg": " cmd_opt_newton = - torch.solve(hess, grad)[0]", "retain": "def direct_newton(env: DiffEnv, cmd: torch.Tensor, reg_ctrl: float = 0.) -> (torch.Tensor, torch.Tensor):\n \"\"\"\n Compute a Newton step directly, used to test auto_lin_quad on linear quadratic problem.\n :param env: control environment\n :param cmd: initial command from where to do the Newton step\n :param reg_ctrl: regularization on the control variables, i.e., the command\n :return\n - cmd_opt_newton - optimal command computed by a Newton step\n - opt_newton - optimal value computed by a Newton step\n \"\"\"\n horizon, dim_ctr = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n feasible = True\n\n if feasible:\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n tic = time.time()\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctr * horizon)\n cmd_opt_newton = - torch.linalg.solve(hess, grad.unsqueeze(-1), ).view(-1)\n # hess = hess.detach().numpy()\n # grad = grad.unsqueeze(-1).detach().numpy()\n # cmd_opt_newton = cg(hess, grad)[0]\n # cmd_opt_newton = - torch.from_numpy(cmd_opt_newton)\n print(f'Time Newton: {time.time() - tic}')\n\n cmd_opt_newton = cmd_opt_newton.view(horizon, dim_ctr)\n\n traj, costs = env.forward(cmd_aux, approx='linquad')\n lin_dyn_states, lin_dyn_ctrls, \\\n quad_cost_states, lin_cost_states, \\\n quad_cost_ctrls, lin_cost_ctrls = compute_lin_quad_approx(traj, costs, reg_ctrl)\n lin_quad_env = LinQuadEnv(lin_dyn_states, lin_dyn_ctrls,\n quad_cost_states, lin_cost_states,\n quad_cost_ctrls, lin_cost_ctrls)\n traj_opt, costs_opt = lin_quad_env.forward(cmd_opt_newton)\n opt_newton = sum(costs_opt)\n else:\n cmd_opt_newton = None\n opt_newton = None\n return cmd_opt_newton, opt_newton" }, { "id": 8743, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n with linear_operator.settings.minres_tolerance(1e-6):\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64),\n shifts.view(*shifts.shape, *[1 for _ in matrix.shape]),\n )\n\n # Compute solves exactly\n actual = torch.linalg.solve(-matrix, rhs.unsqueeze(-1) if rhs.dim() == 1 else rhs)\n if rhs.dim() == 1:\n actual = actual.squeeze(-1)\n\n self.assertAllClose(solves, actual, atol=1e-3, rtol=1e-4)", "probing input": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n with linear_operator.settings.minres_tolerance(1e-6):\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64),\n shifts.view(*shifts.shape, *[1 for _ in matrix.shape]),\n )\n\n # Compute solves exactly\n", "probing input new": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n with linear_operator.settings.minres_tolerance(1e-6):\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64),\n shifts.view(*shifts.shape, *[1 for _ in matrix.shape]),\n )\n\n # Compute solves exactly\n actual = torch.", "reference": "actual=torch.linalg.solve(-matrix,rhs.unsqueeze(-1)ifrhs.dim()==1elserhs)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "actual=torch.linalg.solve(-matrix,rhs.unsqueeze(-1)ifrhs.dim()==1elserhs)", "y_neg": " actual = torch.solve(matrix, rhs)", "retain": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n with linear_operator.settings.minres_tolerance(1e-6):\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64),\n shifts.view(*shifts.shape, *[1 for _ in matrix.shape]),\n )\n\n # Compute solves exactly\n actual = torch.linalg.solve(-matrix, rhs.unsqueeze(-1) if rhs.dim() == 1 else rhs)\n if rhs.dim() == 1:\n actual = actual.squeeze(-1)\n\n self.assertAllClose(solves, actual, atol=1e-3, rtol=1e-4)" }, { "id": 8752, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def zero_com(self, const, species, coordinates, velocities):\n \"\"\"\n remove center of mass\n remove center of mass velocity\n remove angular momentum\n scale temperature back\n mass shape (nmol, molsize, 1)\n velocities shape (nmol, molsize, 3)\n \"\"\"\n #mass for padding atom is 0.0\n mass = const.mass[species].unsqueeze(2)\n M = torch.sum(mass,dim=1,keepdim=True)\n _, T0 = self.kinetic_energy(const, mass, species, velocities)\n with torch.no_grad():\n r_com = torch.sum(mass*coordinates,dim=1,keepdim=True)/M\n coordinates.sub_(r_com)\n v_com = torch.sum(mass*velocities,dim=1,keepdim=True)/M\n velocities.sub_(v_com)\n L = torch.sum(mass * torch.cross(coordinates, velocities, dim=2), dim=1)\n I = torch.sum(mass * torch.norm(coordinates, dim=2, keepdim=True)**2, dim=1, keepdim=True) \\\n * torch.eye(3, dtype=coordinates.dtype, device=coordinates.device).reshape(1,3,3) \\\n - torch.sum( mass.unsqueeze(3) * coordinates.unsqueeze(3) * coordinates.unsqueeze(2), dim=1)\n # omega, _ = torch.solve(L.unsqueeze(2), I)\n omega = torch.linalg.solve(I, L.unsqueeze(2))\n velocities.add_( torch.cross(coordinates, omega.reshape(-1,1,3).repeat(1,coordinates.shape[1],1)) )\n _, T1 = self.kinetic_energy(const, mass, species, velocities)\n alpha = torch.sqrt(T0/T1)\n velocities.mul_(alpha.reshape(-1,1,1))\n #Lnew = torch.sum(mass * torch.cross(coordinates, velocities), dim=1)\n #_, Tnew = self.kinetic_energy(const, mass, species, velocities)\n #print(\"After remove angular momentum: \", Lnew, T0-Tnew)\n del r_com, v_com, L, I, omega, T0, T1, alpha", "probing input": " def zero_com(self, const, species, coordinates, velocities):\n \"\"\"\n remove center of mass\n remove center of mass velocity\n remove angular momentum\n scale temperature back\n mass shape (nmol, molsize, 1)\n velocities shape (nmol, molsize, 3)\n \"\"\"\n #mass for padding atom is 0.0\n mass = const.mass[species].unsqueeze(2)\n M = torch.sum(mass,dim=1,keepdim=True)\n _, T0 = self.kinetic_energy(const, mass, species, velocities)\n with torch.no_grad():\n r_com = torch.sum(mass*coordinates,dim=1,keepdim=True)/M\n coordinates.sub_(r_com)\n v_com = torch.sum(mass*velocities,dim=1,keepdim=True)/M\n velocities.sub_(v_com)\n L = torch.sum(mass * torch.cross(coordinates, velocities, dim=2), dim=1)\n I = torch.sum(mass * torch.norm(coordinates, dim=2, keepdim=True)**2, dim=1, keepdim=True) \\\n * torch.eye(3, dtype=coordinates.dtype, device=coordinates.device).reshape(1,3,3) \\\n - torch.sum( mass.unsqueeze(3) * coordinates.unsqueeze(3) * coordinates.unsqueeze(2), dim=1)\n # omega, _ = torch.solve(L.unsqueeze(2), I)\n", "probing input new": " def zero_com(self, const, species, coordinates, velocities):\n \"\"\"\n remove center of mass\n remove center of mass velocity\n remove angular momentum\n scale temperature back\n mass shape (nmol, molsize, 1)\n velocities shape (nmol, molsize, 3)\n \"\"\"\n #mass for padding atom is 0.0\n mass = const.mass[species].unsqueeze(2)\n M = torch.sum(mass,dim=1,keepdim=True)\n _, T0 = self.kinetic_energy(const, mass, species, velocities)\n with torch.no_grad():\n r_com = torch.sum(mass*coordinates,dim=1,keepdim=True)/M\n coordinates.sub_(r_com)\n v_com = torch.sum(mass*velocities,dim=1,keepdim=True)/M\n velocities.sub_(v_com)\n L = torch.sum(mass * torch.cross(coordinates, velocities, dim=2), dim=1)\n I = torch.sum(mass * torch.norm(coordinates, dim=2, keepdim=True)**2, dim=1, keepdim=True) \\\n * torch.eye(3, dtype=coordinates.dtype, device=coordinates.device).reshape(1,3,3) \\\n - torch.sum( mass.unsqueeze(3) * coordinates.unsqueeze(3) * coordinates.unsqueeze(2), dim=1)\n # omega, _ = torch.solve(L.unsqueeze(2), I)\n omega = torch.", "reference": "omega=torch.linalg.solve(I,L.unsqueeze(2))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "omega=torch.linalg.solve(I,L.unsqueeze(2))", "y_neg": " omega = torch.solve(L.unsqueeze(2), I)[0].squeeze(2)", "retain": " def zero_com(self, const, species, coordinates, velocities):\n \"\"\"\n remove center of mass\n remove center of mass velocity\n remove angular momentum\n scale temperature back\n mass shape (nmol, molsize, 1)\n velocities shape (nmol, molsize, 3)\n \"\"\"\n #mass for padding atom is 0.0\n mass = const.mass[species].unsqueeze(2)\n M = torch.sum(mass,dim=1,keepdim=True)\n _, T0 = self.kinetic_energy(const, mass, species, velocities)\n with torch.no_grad():\n r_com = torch.sum(mass*coordinates,dim=1,keepdim=True)/M\n coordinates.sub_(r_com)\n v_com = torch.sum(mass*velocities,dim=1,keepdim=True)/M\n velocities.sub_(v_com)\n L = torch.sum(mass * torch.cross(coordinates, velocities, dim=2), dim=1)\n I = torch.sum(mass * torch.norm(coordinates, dim=2, keepdim=True)**2, dim=1, keepdim=True) \\\n * torch.eye(3, dtype=coordinates.dtype, device=coordinates.device).reshape(1,3,3) \\\n - torch.sum( mass.unsqueeze(3) * coordinates.unsqueeze(3) * coordinates.unsqueeze(2), dim=1)\n # omega, _ = torch.solve(L.unsqueeze(2), I)\n omega = torch.linalg.solve(I, L.unsqueeze(2))\n velocities.add_( torch.cross(coordinates, omega.reshape(-1,1,3).repeat(1,coordinates.shape[1],1)) )\n _, T1 = self.kinetic_energy(const, mass, species, velocities)\n alpha = torch.sqrt(T0/T1)\n velocities.mul_(alpha.reshape(-1,1,1))\n #Lnew = torch.sum(mass * torch.cross(coordinates, velocities), dim=1)\n #_, Tnew = self.kinetic_energy(const, mass, species, velocities)\n #print(\"After remove angular momentum: \", Lnew, T0-Tnew)\n del r_com, v_com, L, I, omega, T0, T1, alpha" }, { "id": 8753, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n '''\n ray: shape (n_points=2, n_dim=3) # O, D points\n segment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n Return True if the ray intersects the segment.\n '''\n # Get the x and y coordinates (ignore z)\n ray = ray[..., :2]\n segment = segment[..., :2]\n\n # Ray is [[Ox, Oy], [Dx, Dy]]\n O, D = ray\n # Segment is [[L1x, L1y], [L2x, L2y]]\n L_1, L_2 = segment\n\n # Create matrix and vector, and solve equation\n mat = t.stack([D, L_1 - L_2], dim=-1)\n vec = L_1 - O\n\n # Solve equation (return False if no solution)\n try:\n sol = t.linalg.solve(mat, vec)\n except RuntimeError:\n return False\n\n # If there is a solution, check the soln is in the correct range for there to be an intersection\n u = sol[0].item()\n v = sol[1].item()\n return (u >= 0.0) and (v >= 0.0) and (v <= 1.0)", "probing input": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n '''\n ray: shape (n_points=2, n_dim=3) # O, D points\n segment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n Return True if the ray intersects the segment.\n '''\n # Get the x and y coordinates (ignore z)\n ray = ray[..., :2]\n segment = segment[..., :2]\n\n # Ray is [[Ox, Oy], [Dx, Dy]]\n O, D = ray\n # Segment is [[L1x, L1y], [L2x, L2y]]\n L_1, L_2 = segment\n\n # Create matrix and vector, and solve equation\n mat = t.stack([D, L_1 - L_2], dim=-1)\n vec = L_1 - O\n\n # Solve equation (return False if no solution)\n try:\n", "probing input new": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n '''\n ray: shape (n_points=2, n_dim=3) # O, D points\n segment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n Return True if the ray intersects the segment.\n '''\n # Get the x and y coordinates (ignore z)\n ray = ray[..., :2]\n segment = segment[..., :2]\n\n # Ray is [[Ox, Oy], [Dx, Dy]]\n O, D = ray\n # Segment is [[L1x, L1y], [L2x, L2y]]\n L_1, L_2 = segment\n\n # Create matrix and vector, and solve equation\n mat = t.stack([D, L_1 - L_2], dim=-1)\n vec = L_1 - O\n\n # Solve equation (return False if no solution)\n try:\n sol = t.", "reference": "sol=t.linalg.solve(mat,vec)", "reference dict": {}, "alias dict": { "t.potri": "torch.potri", "t.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "t.potrs": "torch.potrs", "t.qr": "torch.qr", "t.lu_solve": "torch.lu_solve", "t.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "t.symeig": "torch.symeig", "t.func.functional_call": "torch.func.functional_call", "t.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "t.solve": "torch.solve", "t.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "t.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "t.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "t.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "t.lu_unpack": "torch.lu_unpack", "t.btrisolve": "torch.btrisolve", "t.linalg.lu_factor": "torch.linalg.lu_factor", "t.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "t.linalg.matrix_rank": "torch.linalg.matrix_rank", "t.norm": "torch.norm", "t.cholesky_solve": "torch.cholesky_solve", "t.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "t.testing.assert_allclose": "torch.testing.assert_allclose", "t.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "t.gels": "torch.gels", "t.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "t.chain_matmul": "torch.chain_matmul", "t.lu": "torch.lu", "t.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "t.pstrf": "torch.pstrf", "t.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "t.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "t.linalg.eigh": "torch.linalg.eigh", "t.btrifact": "torch.btrifact", "t.linalg.lu_solve": "torch.linalg.lu_solve", "t.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "t.linalg.multi_dot": "torch.linalg.multi_dot", "t.gesv": "torch.gesv", "t.btrifact_with_info": "torch.btrifact_with_info", "t.linalg.solve": "torch.linalg.solve", "t.linalg.eig": "torch.linalg.eig", "t.linalg.cholesky": "torch.linalg.cholesky", "t.trtrs": "torch.trtrs", "t.linalg.solve_triangular": "torch.linalg.solve_triangular", "t.matrix_rank": "torch.matrix_rank", "t.triangular_solve": "torch.triangular_solve", "t.linalg.qr": "torch.linalg.qr", "t.svd": "torch.svd", "t.lstsq": "torch.lstsq", "t.nn.functional.interpolate": "torch.nn.functional.interpolate", "t.potrf": "torch.potrf", "t.linalg.svd": "torch.linalg.svd", "t.btriunpack": "torch.btriunpack", "t.eig": "torch.eig", "t.cholesky_inverse": "torch.cholesky_inverse", "t.testing.assert_close": "torch.testing.assert_close", "t.cholesky": "torch.cholesky", "t.nn.functional.upsample": "torch.nn.functional.upsample", "t.linalg.norm": "torch.linalg.norm", "t.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "t.linalg.solve", "y_pos": "sol=t.linalg.solve(mat,vec)", "y_neg": " sol = t.solve(mat, vec)", "retain": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n '''\n ray: shape (n_points=2, n_dim=3) # O, D points\n segment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n Return True if the ray intersects the segment.\n '''\n # Get the x and y coordinates (ignore z)\n ray = ray[..., :2]\n segment = segment[..., :2]\n\n # Ray is [[Ox, Oy], [Dx, Dy]]\n O, D = ray\n # Segment is [[L1x, L1y], [L2x, L2y]]\n L_1, L_2 = segment\n\n # Create matrix and vector, and solve equation\n mat = t.stack([D, L_1 - L_2], dim=-1)\n vec = L_1 - O\n\n # Solve equation (return False if no solution)\n try:\n sol = t.linalg.solve(mat, vec)\n except RuntimeError:\n return False\n\n # If there is a solution, check the soln is in the correct range for there to be an intersection\n u = sol[0].item()\n v = sol[1].item()\n return (u >= 0.0) and (v >= 0.0) and (v <= 1.0)" }, { "id": 8765, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def exactsolve(A: LinearOperator, B: torch.Tensor, E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Examples\n --------\n >>> import torch\n >>> from deepchem.utils.differentiation_utils import LinearOperator\n >>> A = LinearOperator.m(torch.tensor([[1., 2], [3, 4]]))\n >>> B = torch.tensor([[5., 6], [7, 8]])\n >>> exactsolve(A, B, None, None)\n tensor([[-3., -4.],\n [ 4., 5.]])\n\n Parameters\n ----------\n A: LinearOperator\n The linear operator A to be solved. Shape: (`*BA`, na, na)\n B: torch.Tensor\n Batched matrix B. Shape: (`*BB`, na, ncols)\n E: torch.Tensor or None\n Batched vector E. Shape: (`*BE`, ncols)\n M: LinearOperator or None\n The linear operator M. Shape: (`*BM`, na, na)\n\n Returns\n -------\n torch.Tensor\n The Solution matrix X. Shape: (`*BBE`, na, ncols)\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n\n \"\"\"\n if E is None:\n Amatrix = A.fullmatrix()\n x = torch.linalg.solve(Amatrix, B)\n elif M is None:\n Amatrix = A.fullmatrix()\n x = solve_ABE(Amatrix, B, E)\n else:\n Mmatrix = M.fullmatrix()\n L = torch.linalg.cholesky(Mmatrix)\n Linv = torch.inverse(L)\n LinvT = Linv.transpose(-2, -1).conj()\n A2 = torch.matmul(Linv, A.mm(LinvT))\n B2 = torch.matmul(Linv, B)\n\n X2 = solve_ABE(A2, B2, E)\n x = torch.matmul(LinvT, X2)\n return x", "probing input": "def exactsolve(A: LinearOperator, B: torch.Tensor, E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Examples\n --------\n >>> import torch\n >>> from deepchem.utils.differentiation_utils import LinearOperator\n >>> A = LinearOperator.m(torch.tensor([[1., 2], [3, 4]]))\n >>> B = torch.tensor([[5., 6], [7, 8]])\n >>> exactsolve(A, B, None, None)\n tensor([[-3., -4.],\n [ 4., 5.]])\n\n Parameters\n ----------\n A: LinearOperator\n The linear operator A to be solved. Shape: (`*BA`, na, na)\n B: torch.Tensor\n Batched matrix B. Shape: (`*BB`, na, ncols)\n E: torch.Tensor or None\n Batched vector E. Shape: (`*BE`, ncols)\n M: LinearOperator or None\n The linear operator M. Shape: (`*BM`, na, na)\n\n Returns\n -------\n torch.Tensor\n The Solution matrix X. Shape: (`*BBE`, na, ncols)\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n\n \"\"\"\n if E is None:\n Amatrix = A.fullmatrix()\n", "probing input new": "def exactsolve(A: LinearOperator, B: torch.Tensor, E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Examples\n --------\n >>> import torch\n >>> from deepchem.utils.differentiation_utils import LinearOperator\n >>> A = LinearOperator.m(torch.tensor([[1., 2], [3, 4]]))\n >>> B = torch.tensor([[5., 6], [7, 8]])\n >>> exactsolve(A, B, None, None)\n tensor([[-3., -4.],\n [ 4., 5.]])\n\n Parameters\n ----------\n A: LinearOperator\n The linear operator A to be solved. Shape: (`*BA`, na, na)\n B: torch.Tensor\n Batched matrix B. Shape: (`*BB`, na, ncols)\n E: torch.Tensor or None\n Batched vector E. Shape: (`*BE`, ncols)\n M: LinearOperator or None\n The linear operator M. Shape: (`*BM`, na, na)\n\n Returns\n -------\n torch.Tensor\n The Solution matrix X. Shape: (`*BBE`, na, ncols)\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n\n \"\"\"\n if E is None:\n Amatrix = A.fullmatrix()\n x = torch.", "reference": "x=torch.linalg.solve(Amatrix,B)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x=torch.linalg.solve(Amatrix,B)", "y_neg": " x = torch.solve(Amatrix, B)", "retain": "def exactsolve(A: LinearOperator, B: torch.Tensor, E: Union[torch.Tensor, None],\n M: Union[LinearOperator, None]):\n \"\"\"\n Solve the linear equation by contructing the full matrix of LinearOperators.\n\n Examples\n --------\n >>> import torch\n >>> from deepchem.utils.differentiation_utils import LinearOperator\n >>> A = LinearOperator.m(torch.tensor([[1., 2], [3, 4]]))\n >>> B = torch.tensor([[5., 6], [7, 8]])\n >>> exactsolve(A, B, None, None)\n tensor([[-3., -4.],\n [ 4., 5.]])\n\n Parameters\n ----------\n A: LinearOperator\n The linear operator A to be solved. Shape: (`*BA`, na, na)\n B: torch.Tensor\n Batched matrix B. Shape: (`*BB`, na, ncols)\n E: torch.Tensor or None\n Batched vector E. Shape: (`*BE`, ncols)\n M: LinearOperator or None\n The linear operator M. Shape: (`*BM`, na, na)\n\n Returns\n -------\n torch.Tensor\n The Solution matrix X. Shape: (`*BBE`, na, ncols)\n\n Warnings\n --------\n * As this method construct the linear operators explicitly, it might requires\n a large memory.\n\n \"\"\"\n if E is None:\n Amatrix = A.fullmatrix()\n x = torch.linalg.solve(Amatrix, B)\n elif M is None:\n Amatrix = A.fullmatrix()\n x = solve_ABE(Amatrix, B, E)\n else:\n Mmatrix = M.fullmatrix()\n L = torch.linalg.cholesky(Mmatrix)\n Linv = torch.inverse(L)\n LinvT = Linv.transpose(-2, -1).conj()\n A2 = torch.matmul(Linv, A.mm(LinvT))\n B2 = torch.matmul(Linv, B)\n\n X2 = solve_ABE(A2, B2, E)\n x = torch.matmul(LinvT, X2)\n return x" }, { "id": 8782, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _solve(A, B):\n ATA = A.transpose(-2, -1) @ A\n ATB = A.transpose(-2, -1) @ B\n return torch.linalg.solve(ATA, ATB)", "probing input": "def _solve(A, B):\n ATA = A.transpose(-2, -1) @ A\n ATB = A.transpose(-2, -1) @ B\n", "probing input new": "def _solve(A, B):\n ATA = A.transpose(-2, -1) @ A\n ATB = A.transpose(-2, -1) @ B\n return torch.", "reference": "returntorch.linalg.solve(ATA,ATB)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(ATA,ATB)", "y_neg": " return torch.solve(ATA, ATB)[0]", "retain": "def _solve(A, B):\n ATA = A.transpose(-2, -1) @ A\n ATB = A.transpose(-2, -1) @ B\n return torch.linalg.solve(ATA, ATB)" }, { "id": 8785, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self,\n sp, # start position; shape = (Batch, 1)\n sv, # start velocity; shape = (Batch, 1)\n sa, # start acceleration; shape = (Batch, 1)\n ep, # end position; shape = (Batch, 1)\n ev, # end velocity; shape = (Batch, 1)\n ea, # end accleration; shape = (Batch, 1)\n et, # end time; shape = (Batch,)\n ):\n self._a0 = sp\n self._a1 = sv\n self._a2 = sa / 2.\n\n A_r0 = torch.stack([et ** 3, et ** 4, et ** 5], dim=1) # row 0\n A_r1 = torch.stack([3 * et ** 2, 4 * et ** 3, 5 * et ** 4], dim=1) # row 1\n A_r2 = torch.stack([6 * et, 12 * et ** 2, 20 * et ** 3], dim=1) # row 2\n A = torch.stack([A_r0, A_r1, A_r2], dim=1)\n\n b = torch.stack([(ep - self._a0) - self._a1 * et - self._a2 * et ** 2,\n (ev - self._a1) - 2 * self._a2 * et,\n (ea - 2 * self._a2)], dim=1)\n\n x = torch.linalg.solve(A, b)\n self._a3 = x[:, 0]\n self._a4 = x[:, 1]\n self._a5 = x[:, 2]\n\n self._a0 = self._a0[:, None]\n self._a1 = self._a1[:, None]\n self._a2 = self._a2[:, None]\n self._a3 = self._a3[:, None]\n self._a4 = self._a4[:, None]\n self._a5 = self._a5[:, None]\n\n self._A = A\n self._b = b\n self._x = x\n self._sp = sp\n self._sv = sv\n self._sa = sa\n self._ep = ep\n self._ev = ev\n self._ea = ea\n self._et = et", "probing input": " def __init__(self,\n sp, # start position; shape = (Batch, 1)\n sv, # start velocity; shape = (Batch, 1)\n sa, # start acceleration; shape = (Batch, 1)\n ep, # end position; shape = (Batch, 1)\n ev, # end velocity; shape = (Batch, 1)\n ea, # end accleration; shape = (Batch, 1)\n et, # end time; shape = (Batch,)\n ):\n self._a0 = sp\n self._a1 = sv\n self._a2 = sa / 2.\n\n A_r0 = torch.stack([et ** 3, et ** 4, et ** 5], dim=1) # row 0\n A_r1 = torch.stack([3 * et ** 2, 4 * et ** 3, 5 * et ** 4], dim=1) # row 1\n A_r2 = torch.stack([6 * et, 12 * et ** 2, 20 * et ** 3], dim=1) # row 2\n A = torch.stack([A_r0, A_r1, A_r2], dim=1)\n\n b = torch.stack([(ep - self._a0) - self._a1 * et - self._a2 * et ** 2,\n (ev - self._a1) - 2 * self._a2 * et,\n (ea - 2 * self._a2)], dim=1)\n\n", "probing input new": " def __init__(self,\n sp, # start position; shape = (Batch, 1)\n sv, # start velocity; shape = (Batch, 1)\n sa, # start acceleration; shape = (Batch, 1)\n ep, # end position; shape = (Batch, 1)\n ev, # end velocity; shape = (Batch, 1)\n ea, # end accleration; shape = (Batch, 1)\n et, # end time; shape = (Batch,)\n ):\n self._a0 = sp\n self._a1 = sv\n self._a2 = sa / 2.\n\n A_r0 = torch.stack([et ** 3, et ** 4, et ** 5], dim=1) # row 0\n A_r1 = torch.stack([3 * et ** 2, 4 * et ** 3, 5 * et ** 4], dim=1) # row 1\n A_r2 = torch.stack([6 * et, 12 * et ** 2, 20 * et ** 3], dim=1) # row 2\n A = torch.stack([A_r0, A_r1, A_r2], dim=1)\n\n b = torch.stack([(ep - self._a0) - self._a1 * et - self._a2 * et ** 2,\n (ev - self._a1) - 2 * self._a2 * et,\n (ea - 2 * self._a2)], dim=1)\n\n x = torch.", "reference": "x=torch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x=torch.linalg.solve(A,b)", "y_neg": " x = torch.solve(A, b)[0]", "retain": " def __init__(self,\n sp, # start position; shape = (Batch, 1)\n sv, # start velocity; shape = (Batch, 1)\n sa, # start acceleration; shape = (Batch, 1)\n ep, # end position; shape = (Batch, 1)\n ev, # end velocity; shape = (Batch, 1)\n ea, # end accleration; shape = (Batch, 1)\n et, # end time; shape = (Batch,)\n ):\n self._a0 = sp\n self._a1 = sv\n self._a2 = sa / 2.\n\n A_r0 = torch.stack([et ** 3, et ** 4, et ** 5], dim=1) # row 0\n A_r1 = torch.stack([3 * et ** 2, 4 * et ** 3, 5 * et ** 4], dim=1) # row 1\n A_r2 = torch.stack([6 * et, 12 * et ** 2, 20 * et ** 3], dim=1) # row 2\n A = torch.stack([A_r0, A_r1, A_r2], dim=1)\n\n b = torch.stack([(ep - self._a0) - self._a1 * et - self._a2 * et ** 2,\n (ev - self._a1) - 2 * self._a2 * et,\n (ea - 2 * self._a2)], dim=1)\n\n x = torch.linalg.solve(A, b)\n self._a3 = x[:, 0]\n self._a4 = x[:, 1]\n self._a5 = x[:, 2]\n\n self._a0 = self._a0[:, None]\n self._a1 = self._a1[:, None]\n self._a2 = self._a2[:, None]\n self._a3 = self._a3[:, None]\n self._a4 = self._a4[:, None]\n self._a5 = self._a5[:, None]\n\n self._A = A\n self._b = b\n self._x = x\n self._sp = sp\n self._sv = sv\n self._sa = sa\n self._ep = ep\n self._ev = ev\n self._ea = ea\n self._et = et" }, { "id": 8795, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n settings = torchsparsegradutils.utils.MINRESSettings(minres_tolerance=1e-6)\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts, settings=settings)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64), shifts.view(*shifts.shape, *[1 for _ in matrix.shape])\n )\n\n # Compute solves exactly\n actual = torch.linalg.solve(-matrix, rhs.unsqueeze(-1) if rhs.dim() == 1 else rhs)\n if rhs.dim() == 1:\n actual = actual.squeeze(-1)\n\n self.assertAllClose(solves, actual, atol=1e-3, rtol=1e-4)", "probing input": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n settings = torchsparsegradutils.utils.MINRESSettings(minres_tolerance=1e-6)\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts, settings=settings)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64), shifts.view(*shifts.shape, *[1 for _ in matrix.shape])\n )\n\n # Compute solves exactly\n", "probing input new": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n settings = torchsparsegradutils.utils.MINRESSettings(minres_tolerance=1e-6)\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts, settings=settings)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64), shifts.view(*shifts.shape, *[1 for _ in matrix.shape])\n )\n\n # Compute solves exactly\n actual = torch.", "reference": "actual=torch.linalg.solve(-matrix,rhs.unsqueeze(-1)ifrhs.dim()==1elserhs)", "reference dict": { "settings": "torchsparsegradutils.utils.MINRESSettings" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "actual=torch.linalg.solve(-matrix,rhs.unsqueeze(-1)ifrhs.dim()==1elserhs)", "y_neg": " actual = torch.solve(matrix, rhs)", "retain": " def _test_minres(self, rhs_shape, shifts=None, matrix_batch_shape=torch.Size([])):\n size = rhs_shape[-2] if len(rhs_shape) > 1 else rhs_shape[-1]\n rhs = torch.randn(rhs_shape, dtype=torch.float64)\n\n matrix = torch.randn(*matrix_batch_shape, size, size, dtype=torch.float64)\n matrix = matrix.matmul(matrix.mT)\n matrix.div_(matrix.norm())\n matrix.add_(torch.eye(size, dtype=torch.float64).mul_(1e-1))\n\n # Compute solves with minres\n if shifts is not None:\n shifts = shifts.type_as(rhs)\n\n settings = torchsparsegradutils.utils.MINRESSettings(minres_tolerance=1e-6)\n solves = minres(matrix, rhs=rhs, value=-1, shifts=shifts, settings=settings)\n\n # Make sure that we're not getting weird batch dim effects\n while matrix.dim() < len(rhs_shape):\n matrix = matrix.unsqueeze(0)\n\n # Maybe add shifts\n if shifts is not None:\n matrix = matrix - torch.mul(\n torch.eye(size, dtype=torch.float64), shifts.view(*shifts.shape, *[1 for _ in matrix.shape])\n )\n\n # Compute solves exactly\n actual = torch.linalg.solve(-matrix, rhs.unsqueeze(-1) if rhs.dim() == 1 else rhs)\n if rhs.dim() == 1:\n actual = actual.squeeze(-1)\n\n self.assertAllClose(solves, actual, atol=1e-3, rtol=1e-4)" }, { "id": 8817, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_solver_gradient_j4t(self):\n # Sparse solver:\n As1 = self.A_csr.detach().to(torch.float32).clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().to(torch.float32).clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = tsgujax.sparse_solve_j4t(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().to(torch.float32).clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().to(torch.float32).clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())", "probing input": " def test_solver_gradient_j4t(self):\n # Sparse solver:\n As1 = self.A_csr.detach().to(torch.float32).clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().to(torch.float32).clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = tsgujax.sparse_solve_j4t(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().to(torch.float32).clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().to(torch.float32).clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n", "probing input new": " def test_solver_gradient_j4t(self):\n # Sparse solver:\n As1 = self.A_csr.detach().to(torch.float32).clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().to(torch.float32).clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = tsgujax.sparse_solve_j4t(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().to(torch.float32).clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().to(torch.float32).clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.", "reference": "x2=torch.linalg.solve(Ad2,Bd2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x2=torch.linalg.solve(Ad2,Bd2)", "y_neg": " x2 = torch.solve(Ad2, Bd2)", "retain": " def test_solver_gradient_j4t(self):\n # Sparse solver:\n As1 = self.A_csr.detach().to(torch.float32).clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().to(torch.float32).clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = tsgujax.sparse_solve_j4t(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().to(torch.float32).clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().to(torch.float32).clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())" }, { "id": 8833, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(ctx, A, B, Q, R, T):\n K = [None] * T\n V = [None] * (T+1)\n\n # for symmetry for gradcheck\n # Q_sym = 0.5*(Q+Q.transpose(-2, -1))\n # R_sym = 0.5*(R+R.transpose(-2, -1))\n\n A_trans = A.transpose(-2,-1)\n B_trans = B.transpose(-2,-1)\n #initialization for backpropagation\n V[-1] = Q\n A_BK = None\n\n for i in reversed(range(T)):\n # using torch.solve(B, A) to obtain the solution of A X = B to avoid direct inverse, note it also returns LU\n # print(B_trans, V[i+1], B)\n # V_uu_inv_B_trans, _ = torch.solve(B_trans,\n # B_trans@V[i+1]@B + R)\n V_uu_inv_B_trans = torch.linalg.solve(B_trans@V[i+1]@B + R,\n B_trans)\n\n K[i] = V_uu_inv_B_trans@V[i+1]@A\n \n #riccati difference equation\n # A-BK\n A_BK = A - B@K[i]\n # V = A^T V (A-BK) + Q = A^T V A - A^T V B (B^T V B + R)^{-1} B^T V A + Q\n V[i] = A_trans@V[i+1]@A_BK + Q\n \n ctx.save_for_backward(V[0], K[0], A_BK)\n ctx.T = T\n return V[0]", "probing input": " def forward(ctx, A, B, Q, R, T):\n K = [None] * T\n V = [None] * (T+1)\n\n # for symmetry for gradcheck\n # Q_sym = 0.5*(Q+Q.transpose(-2, -1))\n # R_sym = 0.5*(R+R.transpose(-2, -1))\n\n A_trans = A.transpose(-2,-1)\n B_trans = B.transpose(-2,-1)\n #initialization for backpropagation\n V[-1] = Q\n A_BK = None\n\n for i in reversed(range(T)):\n # using torch.solve(B, A) to obtain the solution of A X = B to avoid direct inverse, note it also returns LU\n # print(B_trans, V[i+1], B)\n # V_uu_inv_B_trans, _ = torch.solve(B_trans,\n # B_trans@V[i+1]@B + R)\n", "probing input new": " def forward(ctx, A, B, Q, R, T):\n K = [None] * T\n V = [None] * (T+1)\n\n # for symmetry for gradcheck\n # Q_sym = 0.5*(Q+Q.transpose(-2, -1))\n # R_sym = 0.5*(R+R.transpose(-2, -1))\n\n A_trans = A.transpose(-2,-1)\n B_trans = B.transpose(-2,-1)\n #initialization for backpropagation\n V[-1] = Q\n A_BK = None\n\n for i in reversed(range(T)):\n # using torch.solve(B, A) to obtain the solution of A X = B to avoid direct inverse, note it also returns LU\n # print(B_trans, V[i+1], B)\n # V_uu_inv_B_trans, _ = torch.solve(B_trans,\n # B_trans@V[i+1]@B + R)\n V_uu_inv_B_trans = torch.", "reference": "V_uu_inv_B_trans=torch.linalg.solve(B_trans@V[i+1]@B+R,B_trans)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "V_uu_inv_B_trans=torch.linalg.solve(B_trans@V[i+1]@B+R,B_trans)", "y_neg": " V_uu_inv_B_trans = torch.solve(B_trans, B_trans@V[i+1]@B + R)[0]", "retain": " def forward(ctx, A, B, Q, R, T):\n K = [None] * T\n V = [None] * (T+1)\n\n # for symmetry for gradcheck\n # Q_sym = 0.5*(Q+Q.transpose(-2, -1))\n # R_sym = 0.5*(R+R.transpose(-2, -1))\n\n A_trans = A.transpose(-2,-1)\n B_trans = B.transpose(-2,-1)\n #initialization for backpropagation\n V[-1] = Q\n A_BK = None\n\n for i in reversed(range(T)):\n # using torch.solve(B, A) to obtain the solution of A X = B to avoid direct inverse, note it also returns LU\n # print(B_trans, V[i+1], B)\n # V_uu_inv_B_trans, _ = torch.solve(B_trans,\n # B_trans@V[i+1]@B + R)\n V_uu_inv_B_trans = torch.linalg.solve(B_trans@V[i+1]@B + R,\n B_trans)\n\n K[i] = V_uu_inv_B_trans@V[i+1]@A\n \n #riccati difference equation\n # A-BK\n A_BK = A - B@K[i]\n # V = A^T V (A-BK) + Q = A^T V A - A^T V B (B^T V B + R)^{-1} B^T V A + Q\n V[i] = A_trans@V[i+1]@A_BK + Q\n \n ctx.save_for_backward(V[0], K[0], A_BK)\n ctx.T = T\n return V[0]" }, { "id": 8845, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def linalg_solve(A, B):\n return torch.linalg.solve(A.float(), B.float()).to(A.dtype)", "probing input": "def linalg_solve(A, B):\n", "probing input new": "def linalg_solve(A, B):\n return torch.", "reference": "returntorch.linalg.solve(A.float(),B.float()).to(A.dtype)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(A.float(),B.float()).to(A.dtype)", "y_neg": " return torch.solve(A, B)[0]", "retain": "def linalg_solve(A, B):\n return torch.linalg.solve(A.float(), B.float()).to(A.dtype)" }, { "id": 8867, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def solve_weights(t_i, gamma_i, t_r, gamma_r):\n rv = lambda x: x.double().reshape(-1, 1)\n cv = lambda x: x.double().reshape(1, -1)\n A = p_dot_p(rv(t_i), rv(gamma_i), cv(t_i), cv(gamma_i))\n b = p_dot_p(rv(t_i), rv(gamma_i), cv(t_r), cv(gamma_r))\n return torch.linalg.solve(A, b)", "probing input": "def solve_weights(t_i, gamma_i, t_r, gamma_r):\n rv = lambda x: x.double().reshape(-1, 1)\n cv = lambda x: x.double().reshape(1, -1)\n A = p_dot_p(rv(t_i), rv(gamma_i), cv(t_i), cv(gamma_i))\n b = p_dot_p(rv(t_i), rv(gamma_i), cv(t_r), cv(gamma_r))\n", "probing input new": "def solve_weights(t_i, gamma_i, t_r, gamma_r):\n rv = lambda x: x.double().reshape(-1, 1)\n cv = lambda x: x.double().reshape(1, -1)\n A = p_dot_p(rv(t_i), rv(gamma_i), cv(t_i), cv(gamma_i))\n b = p_dot_p(rv(t_i), rv(gamma_i), cv(t_r), cv(gamma_r))\n return torch.", "reference": "returntorch.linalg.solve(A,b)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(A,b)", "y_neg": " return torch.solve(A, b)[0]", "retain": "def solve_weights(t_i, gamma_i, t_r, gamma_r):\n rv = lambda x: x.double().reshape(-1, 1)\n cv = lambda x: x.double().reshape(1, -1)\n A = p_dot_p(rv(t_i), rv(gamma_i), cv(t_i), cv(gamma_i))\n b = p_dot_p(rv(t_i), rv(gamma_i), cv(t_r), cv(gamma_r))\n return torch.linalg.solve(A, b)" }, { "id": 8870, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def direct_newton(env, cmd, reg_ctrl, variant='gmres_scipy', time_solve_only=False):\n tic0 = time.time()\n horizon, dim_ctrl = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctrl)\n\n _, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n if variant == 'torch_solve':\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctrl * horizon)\n tic1 = time.time()\n cmd_opt_newton = - torch.linalg.solve(hess, grad.unsqueeze(-1), ).view(-1)\n elif variant == 'own_cg':\n hvp = make_hvp(grad, cmd_flat)\n hvp_reg = lambda x: hvp(x) + reg_ctrl*x\n tic1 = time.time()\n cmd_opt_newton = own_cg(hvp_reg, grad)\n elif variant == 'gmres_scipy':\n hvp = make_numpy_hvp(grad, cmd_flat)\n hvp_reg = lambda x: hvp(x) + reg_ctrl*x\n hvp_reg = LinearOperator((horizon*dim_ctrl, horizon*dim_ctrl), hvp_reg)\n target = deepcopy(grad.data).numpy()\n tic1 = time.time()\n cmd_opt_newton = cg(hvp_reg, target)[0]\n cmd_opt_newton = torch.from_numpy(cmd_opt_newton)\n else:\n raise NotImplementedError\n\n\n cmd_opt_newton = cmd_opt_newton.view(horizon, dim_ctrl)\n time_newton = time.time() - tic1 if time_solve_only else time.time() - tic0\n return cmd_opt_newton, time_newton", "probing input": "def direct_newton(env, cmd, reg_ctrl, variant='gmres_scipy', time_solve_only=False):\n tic0 = time.time()\n horizon, dim_ctrl = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctrl)\n\n _, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n if variant == 'torch_solve':\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctrl * horizon)\n tic1 = time.time()\n", "probing input new": "def direct_newton(env, cmd, reg_ctrl, variant='gmres_scipy', time_solve_only=False):\n tic0 = time.time()\n horizon, dim_ctrl = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctrl)\n\n _, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n if variant == 'torch_solve':\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctrl * horizon)\n tic1 = time.time()\n cmd_opt_newton = - torch.", "reference": "cmd_opt_newton=-torch.linalg.solve(hess,grad.unsqueeze(-1),).view(-1)", "reference dict": { "hvp_reg": "LinearOperator" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "cmd_opt_newton=-torch.linalg.solve(hess,grad.unsqueeze(-1),).view(-1)", "y_neg": " cmd_opt_newton = - torch.solve(hess, grad)[0]", "retain": "def direct_newton(env, cmd, reg_ctrl, variant='gmres_scipy', time_solve_only=False):\n tic0 = time.time()\n horizon, dim_ctrl = cmd.shape\n\n # Compute step from a given command\n cmd_flat = deepcopy(cmd.data)\n cmd_flat = cmd_flat.view(-1)\n cmd_flat.requires_grad = True\n cmd_aux = cmd_flat.view(horizon, dim_ctrl)\n\n _, costs = env.forward(cmd_aux, approx='linquad')\n total_cost = sum(costs)\n\n # Get gradient, hessian, and make a newton step to get the solution\n grad = torch.autograd.grad(total_cost, cmd_flat, create_graph=True)[0]\n # add regularization in the hessian\n if variant == 'torch_solve':\n hess = auto_multi_grad(grad, cmd_flat) + reg_ctrl * torch.eye(dim_ctrl * horizon)\n tic1 = time.time()\n cmd_opt_newton = - torch.linalg.solve(hess, grad.unsqueeze(-1), ).view(-1)\n elif variant == 'own_cg':\n hvp = make_hvp(grad, cmd_flat)\n hvp_reg = lambda x: hvp(x) + reg_ctrl*x\n tic1 = time.time()\n cmd_opt_newton = own_cg(hvp_reg, grad)\n elif variant == 'gmres_scipy':\n hvp = make_numpy_hvp(grad, cmd_flat)\n hvp_reg = lambda x: hvp(x) + reg_ctrl*x\n hvp_reg = LinearOperator((horizon*dim_ctrl, horizon*dim_ctrl), hvp_reg)\n target = deepcopy(grad.data).numpy()\n tic1 = time.time()\n cmd_opt_newton = cg(hvp_reg, target)[0]\n cmd_opt_newton = torch.from_numpy(cmd_opt_newton)\n else:\n raise NotImplementedError\n\n\n cmd_opt_newton = cmd_opt_newton.view(horizon, dim_ctrl)\n time_newton = time.time() - tic1 if time_solve_only else time.time() - tic0\n return cmd_opt_newton, time_newton" }, { "id": 8881, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _torch_solve_cast(A: Tensor, B: Tensor) -> Tensor:\n \"\"\"Helper function to make torch.solve work with other than fp32/64.\n\n For stable operation, the input matrices should be cast to fp64, and the output will be cast back to the input\n dtype.\n \"\"\"\n # cast to fp64 and solve\n out = torch.linalg.solve(A.to(torch.float64), B.to(torch.float64))\n\n # cast back to the input dtype\n return out.to(A.dtype)", "probing input": "def _torch_solve_cast(A: Tensor, B: Tensor) -> Tensor:\n \"\"\"Helper function to make torch.solve work with other than fp32/64.\n\n For stable operation, the input matrices should be cast to fp64, and the output will be cast back to the input\n dtype.\n \"\"\"\n # cast to fp64 and solve\n", "probing input new": "def _torch_solve_cast(A: Tensor, B: Tensor) -> Tensor:\n \"\"\"Helper function to make torch.solve work with other than fp32/64.\n\n For stable operation, the input matrices should be cast to fp64, and the output will be cast back to the input\n dtype.\n \"\"\"\n # cast to fp64 and solve\n out = torch.", "reference": "out=torch.linalg.solve(A.to(torch.float64),B.to(torch.float64))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "out=torch.linalg.solve(A.to(torch.float64),B.to(torch.float64))", "y_neg": " out = torch.solve(A.double(), B.double())", "retain": "def _torch_solve_cast(A: Tensor, B: Tensor) -> Tensor:\n \"\"\"Helper function to make torch.solve work with other than fp32/64.\n\n For stable operation, the input matrices should be cast to fp64, and the output will be cast back to the input\n dtype.\n \"\"\"\n # cast to fp64 and solve\n out = torch.linalg.solve(A.to(torch.float64), B.to(torch.float64))\n\n # cast back to the input dtype\n return out.to(A.dtype)" }, { "id": 8890, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def proju_original(x, u):\n import geoopt.linalg as linalg\n\n # takes batch data\n # batch_size, n, _ = x.shape\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n batch_size, n = x.shape[0:2]\n\n e = torch.ones(batch_size, n, 1, dtype=x.dtype)\n I = torch.unsqueeze(torch.eye(x.shape[-1], dtype=x.dtype), 0).repeat(\n batch_size, 1, 1\n )\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [torch.transpose(x, 1, 2), I]])\n\n B = A[:, :, 1:]\n b = torch.cat(\n [\n torch.sum(mu, dim=2, keepdim=True),\n torch.transpose(torch.sum(mu, dim=1, keepdim=True), 1, 2),\n ],\n dim=1,\n )\n\n zeta = torch.linalg.solve(\n B.transpose(1, 2) @ B, B.transpose(1, 2) @ (b - A[:, :, 0:1])\n )\n alpha = torch.cat(\n [torch.ones(batch_size, 1, 1, dtype=x.dtype), zeta[:, 0 : n - 1]], dim=1\n )\n beta = zeta[:, n - 1 : 2 * n - 1]\n rgrad = mu - (alpha @ e.transpose(1, 2) + e @ beta.transpose(1, 2)) * x\n\n rgrad = rgrad.reshape(x_shape)\n return rgrad", "probing input": "def proju_original(x, u):\n import geoopt.linalg as linalg\n\n # takes batch data\n # batch_size, n, _ = x.shape\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n batch_size, n = x.shape[0:2]\n\n e = torch.ones(batch_size, n, 1, dtype=x.dtype)\n I = torch.unsqueeze(torch.eye(x.shape[-1], dtype=x.dtype), 0).repeat(\n batch_size, 1, 1\n )\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [torch.transpose(x, 1, 2), I]])\n\n B = A[:, :, 1:]\n b = torch.cat(\n [\n torch.sum(mu, dim=2, keepdim=True),\n torch.transpose(torch.sum(mu, dim=1, keepdim=True), 1, 2),\n ],\n dim=1,\n )\n\n", "probing input new": "def proju_original(x, u):\n import geoopt.linalg as linalg\n\n # takes batch data\n # batch_size, n, _ = x.shape\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n batch_size, n = x.shape[0:2]\n\n e = torch.ones(batch_size, n, 1, dtype=x.dtype)\n I = torch.unsqueeze(torch.eye(x.shape[-1], dtype=x.dtype), 0).repeat(\n batch_size, 1, 1\n )\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [torch.transpose(x, 1, 2), I]])\n\n B = A[:, :, 1:]\n b = torch.cat(\n [\n torch.sum(mu, dim=2, keepdim=True),\n torch.transpose(torch.sum(mu, dim=1, keepdim=True), 1, 2),\n ],\n dim=1,\n )\n\n zeta = torch.", "reference": "zeta=torch.linalg.solve(B.transpose(1,2)@B,B.transpose(1,2)@(b-A[:,:,0:1]))", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "zeta=torch.linalg.solve(B.transpose(1,2)@B,B.transpose(1,2)@(b-A[:,:,0:1]))", "y_neg": " zeta = torch.solve(B, b)[0]", "retain": "def proju_original(x, u):\n import geoopt.linalg as linalg\n\n # takes batch data\n # batch_size, n, _ = x.shape\n x_shape = x.shape\n x = x.reshape(-1, x_shape[-2], x_shape[-1])\n batch_size, n = x.shape[0:2]\n\n e = torch.ones(batch_size, n, 1, dtype=x.dtype)\n I = torch.unsqueeze(torch.eye(x.shape[-1], dtype=x.dtype), 0).repeat(\n batch_size, 1, 1\n )\n\n mu = x * u\n\n A = linalg.block_matrix([[I, x], [torch.transpose(x, 1, 2), I]])\n\n B = A[:, :, 1:]\n b = torch.cat(\n [\n torch.sum(mu, dim=2, keepdim=True),\n torch.transpose(torch.sum(mu, dim=1, keepdim=True), 1, 2),\n ],\n dim=1,\n )\n\n zeta = torch.linalg.solve(\n B.transpose(1, 2) @ B, B.transpose(1, 2) @ (b - A[:, :, 0:1])\n )\n alpha = torch.cat(\n [torch.ones(batch_size, 1, 1, dtype=x.dtype), zeta[:, 0 : n - 1]], dim=1\n )\n beta = zeta[:, n - 1 : 2 * n - 1]\n rgrad = mu - (alpha @ e.transpose(1, 2) + e @ beta.transpose(1, 2)) * x\n\n rgrad = rgrad.reshape(x_shape)\n return rgrad" }, { "id": 8901, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def line_intersection(line1, line2):\n\t\"\"\"\n\tline in format np.array[[x1,y1],[x2,y2]]\n\treturns intersection point\n\t\"\"\"\n\ttry:\n\t\tt, s = torch.linalg.solve(torch.vstack([line1[1] - line1[0], line2[0] - line2[1]]).T, line2[0] - line1[0])\n\t\treturn (1 - t) * line1[0] + t * line1[1]\n\texcept: # np.linalg.LinAlgError:\n\t\tprint(\"no intersection\")\n\t\treturn None", "probing input": "def line_intersection(line1, line2):\n\t\"\"\"\n\tline in format np.array[[x1,y1],[x2,y2]]\n\treturns intersection point\n\t\"\"\"\n\ttry:\n", "probing input new": "def line_intersection(line1, line2):\n\t\"\"\"\n\tline in format np.array[[x1,y1],[x2,y2]]\n\treturns intersection point\n\t\"\"\"\n\ttry:\n\t\tt, s = torch.", "reference": "t,s=torch.linalg.solve(torch.vstack([line1[1]-line1[0],line2[0]-line2[1]]).T,line2[0]-line1[0])", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "t,s=torch.linalg.solve(torch.vstack([line1[1]-line1[0],line2[0]-line2[1]]).T,line2[0]-line1[0])", "y_neg": "\t\tt, s = torch.solve([line1[1]-line1[0]], [line2[1]-line2[0]])", "retain": "def line_intersection(line1, line2):\n\t\"\"\"\n\tline in format np.array[[x1,y1],[x2,y2]]\n\treturns intersection point\n\t\"\"\"\n\ttry:\n\t\tt, s = torch.linalg.solve(torch.vstack([line1[1] - line1[0], line2[0] - line2[1]]).T, line2[0] - line1[0])\n\t\treturn (1 - t) * line1[0] + t * line1[1]\n\texcept: # np.linalg.LinAlgError:\n\t\tprint(\"no intersection\")\n\t\treturn None" }, { "id": 8904, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _stable_solve(b, a, eps=1e-06):\n try:\n return torch.linalg.solve(a, b)\n except RuntimeError:\n a = condition_scm(a, eps)\n return torch.linalg.solve(a, b)", "probing input": "def _stable_solve(b, a, eps=1e-06):\n try:\n", "probing input new": "def _stable_solve(b, a, eps=1e-06):\n try:\n return torch.", "reference": "returntorch.linalg.solve(a,b)", "reference dict": { "yaml": "MagicMock", "pairwise_mse": "PairwiseMSE", "singlesrc_mse": "SingleSrcMSE", "pairwise_neg_sisdr": "PairwiseNegSDR" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest", "assert_allclose": "torch.testing.assert_allclose" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "returntorch.linalg.solve(a,b)", "y_neg": " return torch.solve(a, b)[0]", "retain": "def _stable_solve(b, a, eps=1e-06):\n try:\n return torch.linalg.solve(a, b)\n except RuntimeError:\n a = condition_scm(a, eps)\n return torch.linalg.solve(a, b)" }, { "id": 8906, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n\t'''\n\tray: shape (n_points=2, n_dim=3) # O, D points\n\tsegment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n\tReturn True if the ray intersects the segment.\n\t'''\n\t# Get the x and y coordinates (ignore z)\n\tray = ray[..., :2]\n\tsegment = segment[..., :2]\n\n\t# Ray is [[Ox, Oy], [Dx, Dy]]\n\tO, D = ray\n\t# Segment is [[L1x, L1y], [L2x, L2y]]\n\tL_1, L_2 = segment\n\n\t# Create matrix and vector, and solve equation\n\tmat = t.stack([D, L_1 - L_2], dim=-1)\n\tvec = L_1 - O\n\n\t# Solve equation (return False if no solution)\n\ttry:\n\t\tsol = t.linalg.solve(mat, vec)\n\texcept:\n\t\treturn False\n\n\t# If there is a solution, check the soln is in the correct range for there to be an intersection\n\tu = sol[0].item()\n\tv = sol[1].item()\n\treturn (u >= 0.0) and (v >= 0.0) and (v <= 1.0)", "probing input": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n\t'''\n\tray: shape (n_points=2, n_dim=3) # O, D points\n\tsegment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n\tReturn True if the ray intersects the segment.\n\t'''\n\t# Get the x and y coordinates (ignore z)\n\tray = ray[..., :2]\n\tsegment = segment[..., :2]\n\n\t# Ray is [[Ox, Oy], [Dx, Dy]]\n\tO, D = ray\n\t# Segment is [[L1x, L1y], [L2x, L2y]]\n\tL_1, L_2 = segment\n\n\t# Create matrix and vector, and solve equation\n\tmat = t.stack([D, L_1 - L_2], dim=-1)\n\tvec = L_1 - O\n\n\t# Solve equation (return False if no solution)\n\ttry:\n", "probing input new": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n\t'''\n\tray: shape (n_points=2, n_dim=3) # O, D points\n\tsegment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n\tReturn True if the ray intersects the segment.\n\t'''\n\t# Get the x and y coordinates (ignore z)\n\tray = ray[..., :2]\n\tsegment = segment[..., :2]\n\n\t# Ray is [[Ox, Oy], [Dx, Dy]]\n\tO, D = ray\n\t# Segment is [[L1x, L1y], [L2x, L2y]]\n\tL_1, L_2 = segment\n\n\t# Create matrix and vector, and solve equation\n\tmat = t.stack([D, L_1 - L_2], dim=-1)\n\tvec = L_1 - O\n\n\t# Solve equation (return False if no solution)\n\ttry:\n\t\tsol = t.", "reference": "sol=t.linalg.solve(mat,vec)", "reference dict": {}, "alias dict": { "t.potri": "torch.potri", "t.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "t.potrs": "torch.potrs", "t.qr": "torch.qr", "t.lu_solve": "torch.lu_solve", "t.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "t.symeig": "torch.symeig", "t.func.functional_call": "torch.func.functional_call", "t.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "t.solve": "torch.solve", "t.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "t.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "t.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "t.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "t.lu_unpack": "torch.lu_unpack", "t.btrisolve": "torch.btrisolve", "t.linalg.lu_factor": "torch.linalg.lu_factor", "t.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "t.linalg.matrix_rank": "torch.linalg.matrix_rank", "t.norm": "torch.norm", "t.cholesky_solve": "torch.cholesky_solve", "t.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "t.testing.assert_allclose": "torch.testing.assert_allclose", "t.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "t.gels": "torch.gels", "t.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "t.chain_matmul": "torch.chain_matmul", "t.lu": "torch.lu", "t.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "t.pstrf": "torch.pstrf", "t.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "t.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "t.linalg.eigh": "torch.linalg.eigh", "t.btrifact": "torch.btrifact", "t.linalg.lu_solve": "torch.linalg.lu_solve", "t.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "t.linalg.multi_dot": "torch.linalg.multi_dot", "t.gesv": "torch.gesv", "t.btrifact_with_info": "torch.btrifact_with_info", "t.linalg.solve": "torch.linalg.solve", "t.linalg.eig": "torch.linalg.eig", "t.linalg.cholesky": "torch.linalg.cholesky", "t.trtrs": "torch.trtrs", "t.linalg.solve_triangular": "torch.linalg.solve_triangular", "t.matrix_rank": "torch.matrix_rank", "t.triangular_solve": "torch.triangular_solve", "t.linalg.qr": "torch.linalg.qr", "t.svd": "torch.svd", "t.lstsq": "torch.lstsq", "t.nn.functional.interpolate": "torch.nn.functional.interpolate", "t.potrf": "torch.potrf", "t.linalg.svd": "torch.linalg.svd", "t.btriunpack": "torch.btriunpack", "t.eig": "torch.eig", "t.cholesky_inverse": "torch.cholesky_inverse", "t.testing.assert_close": "torch.testing.assert_close", "t.cholesky": "torch.cholesky", "t.nn.functional.upsample": "torch.nn.functional.upsample", "t.linalg.norm": "torch.linalg.norm", "t.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "t.linalg.solve", "y_pos": "sol=t.linalg.solve(mat,vec)", "y_neg": "\t\tsol = t.solve(mat, vec)", "retain": "def intersect_ray_1d(ray: t.Tensor, segment: t.Tensor) -> bool:\n\t'''\n\tray: shape (n_points=2, n_dim=3) # O, D points\n\tsegment: shape (n_points=2, n_dim=3) # L_1, L_2 points\n\n\tReturn True if the ray intersects the segment.\n\t'''\n\t# Get the x and y coordinates (ignore z)\n\tray = ray[..., :2]\n\tsegment = segment[..., :2]\n\n\t# Ray is [[Ox, Oy], [Dx, Dy]]\n\tO, D = ray\n\t# Segment is [[L1x, L1y], [L2x, L2y]]\n\tL_1, L_2 = segment\n\n\t# Create matrix and vector, and solve equation\n\tmat = t.stack([D, L_1 - L_2], dim=-1)\n\tvec = L_1 - O\n\n\t# Solve equation (return False if no solution)\n\ttry:\n\t\tsol = t.linalg.solve(mat, vec)\n\texcept:\n\t\treturn False\n\n\t# If there is a solution, check the soln is in the correct range for there to be an intersection\n\tu = sol[0].item()\n\tv = sol[1].item()\n\treturn (u >= 0.0) and (v >= 0.0) and (v <= 1.0)" }, { "id": 8918, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_generic_solver_gradient_default(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())", "probing input": " def test_generic_solver_gradient_default(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n", "probing input new": " def test_generic_solver_gradient_default(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.", "reference": "x2=torch.linalg.solve(Ad2,Bd2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x2=torch.linalg.solve(Ad2,Bd2)", "y_neg": " x2 = torch.solve(Ad2, Bd2)", "retain": " def test_generic_solver_gradient_default(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())" }, { "id": 8919, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_generic_solver_gradient_cg(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1, solve=linear_cg, transpose_solve=linear_cg)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())", "probing input": " def test_generic_solver_gradient_cg(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1, solve=linear_cg, transpose_solve=linear_cg)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n", "probing input new": " def test_generic_solver_gradient_cg(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1, solve=linear_cg, transpose_solve=linear_cg)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.", "reference": "x2=torch.linalg.solve(Ad2,Bd2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.solve" ], "replacement api": "torch.linalg.solve", "expected call": "torch.linalg.solve", "y_pos": "x2=torch.linalg.solve(Ad2,Bd2)", "y_neg": " x2 = torch.solve(Ad2, Bd2)", "retain": " def test_generic_solver_gradient_cg(self):\n # Sparse solver:\n As1 = self.A_csr.detach().clone()\n As1.requires_grad = True\n Bd1 = self.B.detach().clone()\n Bd1.requires_grad = True\n As1.retain_grad()\n Bd1.retain_grad()\n x = sparse_generic_solve(As1, Bd1, solve=linear_cg, transpose_solve=linear_cg)\n loss = x.sum()\n loss.backward()\n\n # torch dense solver:\n Ad2 = self.A.detach().clone()\n Ad2.requires_grad = True\n Bd2 = self.B.detach().clone()\n Bd2.requires_grad = True\n Ad2.retain_grad()\n Bd2.retain_grad()\n x2 = torch.linalg.solve(Ad2, Bd2)\n loss_torch = x2.sum()\n loss_torch.backward()\n\n self.assertTrue(torch.isclose(x, x2, rtol=self.RTOL).all())\n\n nz_mask = As1.grad.to_dense() != 0.0\n self.assertTrue(torch.isclose(As1.grad.to_dense()[nz_mask], Ad2.grad[nz_mask], rtol=self.RTOL).all())\n self.assertTrue(torch.isclose(Bd1.grad, Bd2.grad, rtol=self.RTOL).all())" }, { "id": 8945, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_eig_numpy(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n # unlike NumPy the result is not cast to float32 or float64 dtype in this case\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.linalg.eig(a)\n\n # compare with NumPy\n # the eigenvalues are not necessarily ordered\n # so order of NumPy and PyTorch can be different\n expected = np.linalg.eig(a.cpu().numpy())\n\n # sort NumPy output\n ind = np.argsort(expected[0], axis=-1)[::-1]\n expected = (np.take_along_axis(expected[0], ind, axis=-1), np.take_along_axis(expected[1], ind[:, None], axis=-1))\n\n # sort PyTorch output\n # torch.argsort doesn't work with complex inputs, NumPy sorting on CPU is used instead\n # RuntimeError: _th_sort not supported on CUDAType for ComplexDouble\n # RuntimeError: \"sorting_kernel_method_name\" not implemented for 'ComplexDouble'\n ind = np.argsort(actual[0].cpu().numpy(), axis=-1)[::-1]\n actual_np = [x.cpu().numpy() for x in actual]\n sorted_actual = (\n np.take_along_axis(actual_np[0], ind, axis=-1),\n np.take_along_axis(actual_np[1], ind[:, None], axis=-1))\n\n self.assertEqual(expected[0], sorted_actual[0])\n self.assertEqual(abs(expected[1]), abs(sorted_actual[1]))\n\n shapes = [(0, 0), # Empty matrix\n (5, 5), # Single matrix\n (0, 0, 0), (0, 5, 5), # Zero batch dimension tensors\n (2, 5, 5), # 3-dim tensors\n (2, 1, 5, 5)] # 4-dim tensors\n for shape in shapes:\n run_test(shape)\n run_test(shape, symmetric=True)", "probing input": " def test_eig_numpy(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n # unlike NumPy the result is not cast to float32 or float64 dtype in this case\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n", "probing input new": " def test_eig_numpy(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n # unlike NumPy the result is not cast to float32 or float64 dtype in this case\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.", "reference": "actual=torch.linalg.eig(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "actual=torch.linalg.eig(a)", "y_neg": " actual = torch.eig(a, eigenvectors=True)", "retain": " def test_eig_numpy(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n # unlike NumPy the result is not cast to float32 or float64 dtype in this case\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.linalg.eig(a)\n\n # compare with NumPy\n # the eigenvalues are not necessarily ordered\n # so order of NumPy and PyTorch can be different\n expected = np.linalg.eig(a.cpu().numpy())\n\n # sort NumPy output\n ind = np.argsort(expected[0], axis=-1)[::-1]\n expected = (np.take_along_axis(expected[0], ind, axis=-1), np.take_along_axis(expected[1], ind[:, None], axis=-1))\n\n # sort PyTorch output\n # torch.argsort doesn't work with complex inputs, NumPy sorting on CPU is used instead\n # RuntimeError: _th_sort not supported on CUDAType for ComplexDouble\n # RuntimeError: \"sorting_kernel_method_name\" not implemented for 'ComplexDouble'\n ind = np.argsort(actual[0].cpu().numpy(), axis=-1)[::-1]\n actual_np = [x.cpu().numpy() for x in actual]\n sorted_actual = (\n np.take_along_axis(actual_np[0], ind, axis=-1),\n np.take_along_axis(actual_np[1], ind[:, None], axis=-1))\n\n self.assertEqual(expected[0], sorted_actual[0])\n self.assertEqual(abs(expected[1]), abs(sorted_actual[1]))\n\n shapes = [(0, 0), # Empty matrix\n (5, 5), # Single matrix\n (0, 0, 0), (0, 5, 5), # Zero batch dimension tensors\n (2, 5, 5), # 3-dim tensors\n (2, 1, 5, 5)] # 4-dim tensors\n for shape in shapes:\n run_test(shape)\n run_test(shape, symmetric=True)" }, { "id": 8946, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_eig_compare_backends(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.linalg.eig(a)\n\n complementary_device = 'cpu'\n\n # compare with CPU\n expected = torch.linalg.eig(a.to(complementary_device))\n self.assertEqual(expected[0], actual[0])\n self.assertEqual(expected[1], actual[1])\n\n shapes = [(0, 0), # Empty matrix\n (5, 5), # Single matrix\n (0, 0, 0), (0, 5, 5), # Zero batch dimension tensors\n (2, 5, 5), # 3-dim tensors\n (2, 1, 5, 5)] # 4-dim tensors\n for shape in shapes:\n run_test(shape)\n run_test(shape, symmetric=True)", "probing input": " def test_eig_compare_backends(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n", "probing input new": " def test_eig_compare_backends(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.", "reference": "actual=torch.linalg.eig(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "actual=torch.linalg.eig(a)", "y_neg": " actual = torch.eig(a, eigenvectors=True)", "retain": " def test_eig_compare_backends(self, device, dtype):\n def run_test(shape, *, symmetric=False):\n from torch.testing._internal.common_utils import random_symmetric_matrix\n\n if not dtype.is_complex and symmetric:\n # for symmetric real-valued inputs eigenvalues and eigenvectors have imaginary part equal to zero\n a = random_symmetric_matrix(shape[-1], *shape[:-2], dtype=dtype, device=device)\n else:\n a = make_tensor(shape, dtype=dtype, device=device)\n\n actual = torch.linalg.eig(a)\n\n complementary_device = 'cpu'\n\n # compare with CPU\n expected = torch.linalg.eig(a.to(complementary_device))\n self.assertEqual(expected[0], actual[0])\n self.assertEqual(expected[1], actual[1])\n\n shapes = [(0, 0), # Empty matrix\n (5, 5), # Single matrix\n (0, 0, 0), (0, 5, 5), # Zero batch dimension tensors\n (2, 5, 5), # 3-dim tensors\n (2, 1, 5, 5)] # 4-dim tensors\n for shape in shapes:\n run_test(shape)\n run_test(shape, symmetric=True)" }, { "id": 8948, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_eig_errors_and_warnings(self, device, dtype):\n # eig requires the input to be at least 2 dimensional tensor\n a = make_tensor(2, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must have at least 2 dimensions\"):\n torch.linalg.eig(a)\n\n # eig requires a square matrix\n a = make_tensor((2, 3), dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n torch.linalg.eig(a)\n\n # if out tensor with floating dtype is passed for complex output an error is thrown\n if not dtype.is_complex:\n # The characteristic equation is p(λ) = λ^2 − 2λ + 5 = 0, with roots λ = 1±2i\n a = torch.tensor([[3., -2.], [4., -1.]], dtype=dtype, device=device)\n out0 = torch.empty(0, device=device, dtype=dtype)\n out1 = torch.empty(0, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, \"Expected eigenvalues to be safely castable\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n out0 = torch.empty(0, device=device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"Expected eigenvectors to be safely castable\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n # dtypes should be safely castable\n a = make_tensor((3, 3), dtype=dtype, device=device)\n out0 = torch.empty(0, dtype=torch.int, device=device)\n out1 = torch.empty(0, dtype=torch.int, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got eigenvalues with dtype Int\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n out0 = torch.empty(0, dtype=torch.complex128, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got eigenvectors with dtype Int\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n # if non-empty out tensor with wrong shape is passed a warning is given\n a = make_tensor((3, 3), dtype=dtype, device=device)\n out0 = torch.empty(1, device=device, dtype=torch.complex128)\n out1 = torch.empty(1, device=device, dtype=torch.complex128)\n with warnings.catch_warnings(record=True) as w:\n # Trigger warning\n torch.linalg.eig(a, out=(out0, out1))\n # Check warning occurs\n self.assertEqual(len(w), 2)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-2].message))\n\n # device should match\n if torch.cuda.is_available():\n wrong_device = 'cpu' if self.device_type != 'cpu' else 'cuda'\n out_w = torch.empty(0, device=wrong_device, dtype=torch.complex128)\n out_v = torch.empty(0, device=device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.eig(a, out=(out_w, out_v))\n out_w = torch.empty(0, device=device, dtype=torch.complex128)\n out_v = torch.empty(0, device=wrong_device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.eig(a, out=(out_w, out_v))", "probing input": " def test_eig_errors_and_warnings(self, device, dtype):\n # eig requires the input to be at least 2 dimensional tensor\n a = make_tensor(2, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must have at least 2 dimensions\"):\n", "probing input new": " def test_eig_errors_and_warnings(self, device, dtype):\n # eig requires the input to be at least 2 dimensional tensor\n a = make_tensor(2, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must have at least 2 dimensions\"):\n torch.", "reference": "torch.linalg.eig(a)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "torch.linalg.eig(a)", "y_neg": " torch.eig(a, eigenvectors=True)", "retain": " def test_eig_errors_and_warnings(self, device, dtype):\n # eig requires the input to be at least 2 dimensional tensor\n a = make_tensor(2, dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must have at least 2 dimensions\"):\n torch.linalg.eig(a)\n\n # eig requires a square matrix\n a = make_tensor((2, 3), dtype=dtype, device=device)\n with self.assertRaisesRegex(RuntimeError, \"must be batches of square matrices\"):\n torch.linalg.eig(a)\n\n # if out tensor with floating dtype is passed for complex output an error is thrown\n if not dtype.is_complex:\n # The characteristic equation is p(λ) = λ^2 − 2λ + 5 = 0, with roots λ = 1±2i\n a = torch.tensor([[3., -2.], [4., -1.]], dtype=dtype, device=device)\n out0 = torch.empty(0, device=device, dtype=dtype)\n out1 = torch.empty(0, device=device, dtype=dtype)\n with self.assertRaisesRegex(RuntimeError, \"Expected eigenvalues to be safely castable\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n out0 = torch.empty(0, device=device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"Expected eigenvectors to be safely castable\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n # dtypes should be safely castable\n a = make_tensor((3, 3), dtype=dtype, device=device)\n out0 = torch.empty(0, dtype=torch.int, device=device)\n out1 = torch.empty(0, dtype=torch.int, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got eigenvalues with dtype Int\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n out0 = torch.empty(0, dtype=torch.complex128, device=device)\n with self.assertRaisesRegex(RuntimeError, \"but got eigenvectors with dtype Int\"):\n torch.linalg.eig(a, out=(out0, out1))\n\n # if non-empty out tensor with wrong shape is passed a warning is given\n a = make_tensor((3, 3), dtype=dtype, device=device)\n out0 = torch.empty(1, device=device, dtype=torch.complex128)\n out1 = torch.empty(1, device=device, dtype=torch.complex128)\n with warnings.catch_warnings(record=True) as w:\n # Trigger warning\n torch.linalg.eig(a, out=(out0, out1))\n # Check warning occurs\n self.assertEqual(len(w), 2)\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-1].message))\n self.assertTrue(\"An output with one or more elements was resized\" in str(w[-2].message))\n\n # device should match\n if torch.cuda.is_available():\n wrong_device = 'cpu' if self.device_type != 'cpu' else 'cuda'\n out_w = torch.empty(0, device=wrong_device, dtype=torch.complex128)\n out_v = torch.empty(0, device=device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.eig(a, out=(out_w, out_v))\n out_w = torch.empty(0, device=device, dtype=torch.complex128)\n out_v = torch.empty(0, device=wrong_device, dtype=torch.complex128)\n with self.assertRaisesRegex(RuntimeError, \"tensors to be on the same device\"):\n torch.linalg.eig(a, out=(out_w, out_v))" }, { "id": 8949, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def eig(self):\n \"\"\"\n Returns the eigenvalues (optionally eigenvectors) of the linear map used in matrix multiplication.\n\n :return: (torch.Tensor) Vector of eigenvalues, optionally a tuple including a matrix of eigenvectors.\n \"\"\"\n return torch.linalg.eig(self.effective_W())", "probing input": " def eig(self):\n \"\"\"\n Returns the eigenvalues (optionally eigenvectors) of the linear map used in matrix multiplication.\n\n :return: (torch.Tensor) Vector of eigenvalues, optionally a tuple including a matrix of eigenvectors.\n \"\"\"\n", "probing input new": " def eig(self):\n \"\"\"\n Returns the eigenvalues (optionally eigenvectors) of the linear map used in matrix multiplication.\n\n :return: (torch.Tensor) Vector of eigenvalues, optionally a tuple including a matrix of eigenvectors.\n \"\"\"\n return torch.", "reference": "returntorch.linalg.eig(self.effective_W())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "returntorch.linalg.eig(self.effective_W())", "y_neg": " return torch.eig(self.matrix, eigenvectors=True)", "retain": " def eig(self):\n \"\"\"\n Returns the eigenvalues (optionally eigenvectors) of the linear map used in matrix multiplication.\n\n :return: (torch.Tensor) Vector of eigenvalues, optionally a tuple including a matrix of eigenvectors.\n \"\"\"\n return torch.linalg.eig(self.effective_W())" }, { "id": 8975, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def matrix_logarithm(A):\n L, V = torch.linalg.eig(A)\n return (V @ torch.diag_embed(torch.log(L + 1e-20)) @ torch.linalg.inv(V)).real", "probing input": "def matrix_logarithm(A):\n", "probing input new": "def matrix_logarithm(A):\n L, V = torch.", "reference": "L,V=torch.linalg.eig(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "L,V=torch.linalg.eig(A)", "y_neg": " L, V = torch.eig(A, eigenvectors=True)", "retain": "def matrix_logarithm(A):\n L, V = torch.linalg.eig(A)\n return (V @ torch.diag_embed(torch.log(L + 1e-20)) @ torch.linalg.inv(V)).real" }, { "id": 8998, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def forward(self, H1, H2):\n r1 = 1e-3\n r2 = 1e-3\n eps = 1e-9\n\n H1, H2 = H1.t(), H2.t()\n\n o1 = H1.size(0)\n o2 = H2.size(0)\n\n m = H1.size(1)\n\n H1bar = H1 - H1.mean(dim=1).unsqueeze(dim=1)\n H2bar = H2 - H2.mean(dim=1).unsqueeze(dim=1)\n\n SigmaHat12 = (1.0 / (m - 1)) * torch.matmul(H1bar, H2bar.t())\n SigmaHat11 = (1.0 / (m - 1)) * torch.matmul(H1bar,\n H1bar.t()) + r1 * torch.eye(o1, device=H1.device)\n SigmaHat22 = (1.0 / (m - 1)) * torch.matmul(H2bar,\n H2bar.t()) + r2 * torch.eye(o2, device=H1.device)\n\n # Workaround !!! USE BATCH > 16\n # [D1, V1] = torch.symeig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.symeig(SigmaHat22, eigenvectors=True)\n\n # Newest way but not debugged\n [D1, V1] = torch.linalg.eig(SigmaHat11)\n [D2, V2] = torch.linalg.eig(SigmaHat22)\n\n # Original\n # [D1, V1] = torch.eig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.eig(SigmaHat22, eigenvectors=True)\n\n D1 = D1.unsqueeze(1)\n posInd1 = torch.gt(abs(D1[:, 0]), eps).nonzero()[:, 0]\n D1 = D1[posInd1, 0]\n V1 = V1[:, posInd1]\n D1 = torch.squeeze(D1) # Remove extra dimensions from D1\n # Reshape D1 to 1-dimensional tensor\n D2 = D2.unsqueeze(1)\n # posInd2 = torch.gt(D2, eps).nonzero()[:, 0]\n posInd2 = torch.gt(abs(D2[:, 0]), eps).nonzero()[:, 0]\n D2 = D2[posInd2, 0]\n V2 = V2[:, posInd2]\n D2 = torch.squeeze(D2)\n\n SigmaHat11RootInv = torch.matmul(\n torch.matmul(V1, torch.diag(D1 ** -0.5)), V1.t())\n SigmaHat22RootInv = torch.matmul(\n torch.matmul(V2, torch.diag(D2 ** -0.5)), V2.t())\n\n Tval = torch.matmul(torch.matmul(SigmaHat11RootInv,\n SigmaHat12.to(torch.complex64)), SigmaHat22RootInv)\n\n if self.use_all_singular_values:\n\n tmp = torch.matmul(Tval.t(), Tval)\n corr = torch.trace(torch.sqrt(tmp))\n\n else:\n\n trace_TT = torch.matmul(Tval.t(), Tval)\n trace_TT = torch.add(trace_TT, (torch.eye(trace_TT.shape[0]) * r1).to(H1.device))\n # U, V = torch.symeig(trace_TT, eigenvectors=True)\n U, V = torch.linalg.eigh(trace_TT)\n U = torch.where(U > eps, U, (torch.ones(U.shape).float() * eps).to(H1.device))\n U = U.topk(self.outdim_size)[0]\n corr = torch.sum(torch.sqrt(U))\n return -corr", "probing input": " def forward(self, H1, H2):\n r1 = 1e-3\n r2 = 1e-3\n eps = 1e-9\n\n H1, H2 = H1.t(), H2.t()\n\n o1 = H1.size(0)\n o2 = H2.size(0)\n\n m = H1.size(1)\n\n H1bar = H1 - H1.mean(dim=1).unsqueeze(dim=1)\n H2bar = H2 - H2.mean(dim=1).unsqueeze(dim=1)\n\n SigmaHat12 = (1.0 / (m - 1)) * torch.matmul(H1bar, H2bar.t())\n SigmaHat11 = (1.0 / (m - 1)) * torch.matmul(H1bar,\n H1bar.t()) + r1 * torch.eye(o1, device=H1.device)\n SigmaHat22 = (1.0 / (m - 1)) * torch.matmul(H2bar,\n H2bar.t()) + r2 * torch.eye(o2, device=H1.device)\n\n # Workaround !!! USE BATCH > 16\n # [D1, V1] = torch.symeig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.symeig(SigmaHat22, eigenvectors=True)\n\n # Newest way but not debugged\n", "probing input new": " def forward(self, H1, H2):\n r1 = 1e-3\n r2 = 1e-3\n eps = 1e-9\n\n H1, H2 = H1.t(), H2.t()\n\n o1 = H1.size(0)\n o2 = H2.size(0)\n\n m = H1.size(1)\n\n H1bar = H1 - H1.mean(dim=1).unsqueeze(dim=1)\n H2bar = H2 - H2.mean(dim=1).unsqueeze(dim=1)\n\n SigmaHat12 = (1.0 / (m - 1)) * torch.matmul(H1bar, H2bar.t())\n SigmaHat11 = (1.0 / (m - 1)) * torch.matmul(H1bar,\n H1bar.t()) + r1 * torch.eye(o1, device=H1.device)\n SigmaHat22 = (1.0 / (m - 1)) * torch.matmul(H2bar,\n H2bar.t()) + r2 * torch.eye(o2, device=H1.device)\n\n # Workaround !!! USE BATCH > 16\n # [D1, V1] = torch.symeig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.symeig(SigmaHat22, eigenvectors=True)\n\n # Newest way but not debugged\n [D1, V1] = torch.", "reference": "[D1,V1]=torch.linalg.eig(SigmaHat11)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "[D1,V1]=torch.linalg.eig(SigmaHat11)", "y_neg": " [D1, V1] = torch.eig(SigmaHat11, eigenvectors=True)", "retain": " def forward(self, H1, H2):\n r1 = 1e-3\n r2 = 1e-3\n eps = 1e-9\n\n H1, H2 = H1.t(), H2.t()\n\n o1 = H1.size(0)\n o2 = H2.size(0)\n\n m = H1.size(1)\n\n H1bar = H1 - H1.mean(dim=1).unsqueeze(dim=1)\n H2bar = H2 - H2.mean(dim=1).unsqueeze(dim=1)\n\n SigmaHat12 = (1.0 / (m - 1)) * torch.matmul(H1bar, H2bar.t())\n SigmaHat11 = (1.0 / (m - 1)) * torch.matmul(H1bar,\n H1bar.t()) + r1 * torch.eye(o1, device=H1.device)\n SigmaHat22 = (1.0 / (m - 1)) * torch.matmul(H2bar,\n H2bar.t()) + r2 * torch.eye(o2, device=H1.device)\n\n # Workaround !!! USE BATCH > 16\n # [D1, V1] = torch.symeig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.symeig(SigmaHat22, eigenvectors=True)\n\n # Newest way but not debugged\n [D1, V1] = torch.linalg.eig(SigmaHat11)\n [D2, V2] = torch.linalg.eig(SigmaHat22)\n\n # Original\n # [D1, V1] = torch.eig(SigmaHat11, eigenvectors=True)\n # [D2, V2] = torch.eig(SigmaHat22, eigenvectors=True)\n\n D1 = D1.unsqueeze(1)\n posInd1 = torch.gt(abs(D1[:, 0]), eps).nonzero()[:, 0]\n D1 = D1[posInd1, 0]\n V1 = V1[:, posInd1]\n D1 = torch.squeeze(D1) # Remove extra dimensions from D1\n # Reshape D1 to 1-dimensional tensor\n D2 = D2.unsqueeze(1)\n # posInd2 = torch.gt(D2, eps).nonzero()[:, 0]\n posInd2 = torch.gt(abs(D2[:, 0]), eps).nonzero()[:, 0]\n D2 = D2[posInd2, 0]\n V2 = V2[:, posInd2]\n D2 = torch.squeeze(D2)\n\n SigmaHat11RootInv = torch.matmul(\n torch.matmul(V1, torch.diag(D1 ** -0.5)), V1.t())\n SigmaHat22RootInv = torch.matmul(\n torch.matmul(V2, torch.diag(D2 ** -0.5)), V2.t())\n\n Tval = torch.matmul(torch.matmul(SigmaHat11RootInv,\n SigmaHat12.to(torch.complex64)), SigmaHat22RootInv)\n\n if self.use_all_singular_values:\n\n tmp = torch.matmul(Tval.t(), Tval)\n corr = torch.trace(torch.sqrt(tmp))\n\n else:\n\n trace_TT = torch.matmul(Tval.t(), Tval)\n trace_TT = torch.add(trace_TT, (torch.eye(trace_TT.shape[0]) * r1).to(H1.device))\n # U, V = torch.symeig(trace_TT, eigenvectors=True)\n U, V = torch.linalg.eigh(trace_TT)\n U = torch.where(U > eps, U, (torch.ones(U.shape).float() * eps).to(H1.device))\n U = U.topk(self.outdim_size)[0]\n corr = torch.sum(torch.sqrt(U))\n return -corr" }, { "id": 9007, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eig(x):\n return torch.linalg.eig(x)", "probing input": "def eig(x):\n", "probing input new": "def eig(x):\n return torch.", "reference": "returntorch.linalg.eig(x)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "returntorch.linalg.eig(x)", "y_neg": " return torch.eig(x)", "retain": "def eig(x):\n return torch.linalg.eig(x)" }, { "id": 9019, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def track_grad_flow(model, dataset, data, opt, L_decomp=False, rep=None, pos_encoding=None):\n if L_decomp:\n i = dataset.data.edge_index\n n = dataset.data.num_nodes\n adj = model.odeblock.odefunc.symm_norm_adj\n coo_adj = torch.sparse_coo_tensor(i, adj, (n, n))\n torch_eye = torch.eye(n)\n coo_lap = torch_eye - coo_adj\n L_evals, L_evecs = torch.linalg.eig(coo_lap)\n\n mag_evals = torch.abs(L_evals)\n high_eval = torch.max(mag_evals)\n low_eval = torch.min(mag_evals)\n # assuming eigenvalues of graph laplacian are real\n high_evec = L_evecs[:, torch.argmax(mag_evals)].real.unsqueeze(1)\n low_evec = L_evecs[:, torch.argmin(mag_evals)].real.unsqueeze(1)\n\n model.odeblock.odefunc.high_evec = high_evec\n model.odeblock.odefunc.low_evec = low_evec\n\n else:\n model.odeblock.odefunc.high_evec = torch.zeros((dataset.data.num_nodes,1))\n model.odeblock.odefunc.low_evec = torch.zeros((dataset.data.num_nodes,1))\n\n wandb.config.update({'track_grad_flow_switch': True}, allow_val_change=True)\n model.eval()\n feat = data.x\n if model.opt['use_labels']:\n feat = add_labels(feat, data.y, data.train_mask, model.num_classes, model.device)\n logits, accs = model(feat, pos_encoding), []\n wandb.config.update({'track_grad_flow_switch': False}, allow_val_change=True)\n\n grad_flow_DE = model.odeblock.odefunc.grad_flow_DE\n grad_flow_WDE = model.odeblock.odefunc.grad_flow_WDE\n grad_flow_RQ = model.odeblock.odefunc.grad_flow_RQ\n grad_flow_cos_high = model.odeblock.odefunc.grad_flow_cos_high\n grad_flow_cos_low = model.odeblock.odefunc.grad_flow_cos_low\n grad_flow_train_acc = model.odeblock.odefunc.grad_flow_train_acc\n grad_flow_val_acc = model.odeblock.odefunc.grad_flow_val_acc\n grad_flow_test_acc = model.odeblock.odefunc.grad_flow_test_acc\n\n if opt['wandb']:\n W = model.odeblock.odefunc.W\n W_evals, W_evecs = torch.linalg.eigh(W)\n if rep is not None:\n wandb.log({f\"W_evals_t_{opt['time']}_rep_{rep}\": W_evals, f\"W_evecs_t_{opt['time']}_rep_{rep}\": W_evecs})\n else:\n wandb.log({f\"W_evals\": W_evals, f\"W_evecs\": W_evecs})\n\n # https://docs.wandb.ai/guides/track/log/log-tables\n times = np.arange(0, opt['time'] + opt['step_size'], opt['step_size'])\n data = [[time, DE, WDE, RQ, CH, CL, train, val, test] for (time, DE, WDE, RQ, CH, CL, train, val, test) in\n zip(times, grad_flow_DE, grad_flow_WDE, grad_flow_RQ, grad_flow_cos_high, grad_flow_cos_low,\n grad_flow_train_acc, grad_flow_val_acc, grad_flow_test_acc)]\n wand_table = wandb.Table(data=data,\n columns=[\"time\", \"DE\", \"WDE\", \"RQ\", \"CH\", \"CL\", \"train_acc\", \"val_acc\", \"test_acc\"])\n if rep is not None:\n wandb.log({f\"gf_table_t_{opt['time']}_rep_{rep}\": wand_table})\n else:\n wandb.log({f\"gf_table_t_{opt['time']}\": wand_table})", "probing input": "def track_grad_flow(model, dataset, data, opt, L_decomp=False, rep=None, pos_encoding=None):\n if L_decomp:\n i = dataset.data.edge_index\n n = dataset.data.num_nodes\n adj = model.odeblock.odefunc.symm_norm_adj\n coo_adj = torch.sparse_coo_tensor(i, adj, (n, n))\n torch_eye = torch.eye(n)\n coo_lap = torch_eye - coo_adj\n", "probing input new": "def track_grad_flow(model, dataset, data, opt, L_decomp=False, rep=None, pos_encoding=None):\n if L_decomp:\n i = dataset.data.edge_index\n n = dataset.data.num_nodes\n adj = model.odeblock.odefunc.symm_norm_adj\n coo_adj = torch.sparse_coo_tensor(i, adj, (n, n))\n torch_eye = torch.eye(n)\n coo_lap = torch_eye - coo_adj\n L_evals, L_evecs = torch.", "reference": "L_evals,L_evecs=torch.linalg.eig(coo_lap)", "reference dict": { "wand_table": "wandb.Table" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "L_evals,L_evecs=torch.linalg.eig(coo_lap)", "y_neg": " L_evals, L_evecs = torch.eig(coo_lap, eigenvectors=True)", "retain": "def track_grad_flow(model, dataset, data, opt, L_decomp=False, rep=None, pos_encoding=None):\n if L_decomp:\n i = dataset.data.edge_index\n n = dataset.data.num_nodes\n adj = model.odeblock.odefunc.symm_norm_adj\n coo_adj = torch.sparse_coo_tensor(i, adj, (n, n))\n torch_eye = torch.eye(n)\n coo_lap = torch_eye - coo_adj\n L_evals, L_evecs = torch.linalg.eig(coo_lap)\n\n mag_evals = torch.abs(L_evals)\n high_eval = torch.max(mag_evals)\n low_eval = torch.min(mag_evals)\n # assuming eigenvalues of graph laplacian are real\n high_evec = L_evecs[:, torch.argmax(mag_evals)].real.unsqueeze(1)\n low_evec = L_evecs[:, torch.argmin(mag_evals)].real.unsqueeze(1)\n\n model.odeblock.odefunc.high_evec = high_evec\n model.odeblock.odefunc.low_evec = low_evec\n\n else:\n model.odeblock.odefunc.high_evec = torch.zeros((dataset.data.num_nodes,1))\n model.odeblock.odefunc.low_evec = torch.zeros((dataset.data.num_nodes,1))\n\n wandb.config.update({'track_grad_flow_switch': True}, allow_val_change=True)\n model.eval()\n feat = data.x\n if model.opt['use_labels']:\n feat = add_labels(feat, data.y, data.train_mask, model.num_classes, model.device)\n logits, accs = model(feat, pos_encoding), []\n wandb.config.update({'track_grad_flow_switch': False}, allow_val_change=True)\n\n grad_flow_DE = model.odeblock.odefunc.grad_flow_DE\n grad_flow_WDE = model.odeblock.odefunc.grad_flow_WDE\n grad_flow_RQ = model.odeblock.odefunc.grad_flow_RQ\n grad_flow_cos_high = model.odeblock.odefunc.grad_flow_cos_high\n grad_flow_cos_low = model.odeblock.odefunc.grad_flow_cos_low\n grad_flow_train_acc = model.odeblock.odefunc.grad_flow_train_acc\n grad_flow_val_acc = model.odeblock.odefunc.grad_flow_val_acc\n grad_flow_test_acc = model.odeblock.odefunc.grad_flow_test_acc\n\n if opt['wandb']:\n W = model.odeblock.odefunc.W\n W_evals, W_evecs = torch.linalg.eigh(W)\n if rep is not None:\n wandb.log({f\"W_evals_t_{opt['time']}_rep_{rep}\": W_evals, f\"W_evecs_t_{opt['time']}_rep_{rep}\": W_evecs})\n else:\n wandb.log({f\"W_evals\": W_evals, f\"W_evecs\": W_evecs})\n\n # https://docs.wandb.ai/guides/track/log/log-tables\n times = np.arange(0, opt['time'] + opt['step_size'], opt['step_size'])\n data = [[time, DE, WDE, RQ, CH, CL, train, val, test] for (time, DE, WDE, RQ, CH, CL, train, val, test) in\n zip(times, grad_flow_DE, grad_flow_WDE, grad_flow_RQ, grad_flow_cos_high, grad_flow_cos_low,\n grad_flow_train_acc, grad_flow_val_acc, grad_flow_test_acc)]\n wand_table = wandb.Table(data=data,\n columns=[\"time\", \"DE\", \"WDE\", \"RQ\", \"CH\", \"CL\", \"train_acc\", \"val_acc\", \"test_acc\"])\n if rep is not None:\n wandb.log({f\"gf_table_t_{opt['time']}_rep_{rep}\": wand_table})\n else:\n wandb.log({f\"gf_table_t_{opt['time']}\": wand_table})" }, { "id": 9026, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "criterion = torch.nn.CrossEntropyLoss()\n\nbatch_x, batch_y, *others = next(iter(data_loader))\nbatch_x = batch_x.to(args.device)\nbatch_y = batch_y.to(args.device)\n\n\nif torch.__version__>'1.8.1':\n print('Use self-defined function as an alternative for torch.eig since your torch>=1.9')\n def old_torcheig(A, eigenvectors):\n '''A temporary function as an alternative for torch.eig (torch<1.9)'''\n vals, vecs = torch.linalg.eig(A)\n if torch.is_complex(vals) or torch.is_complex(vecs):\n print('Warning: Complex values founded in Eigenvalues/Eigenvectors. This is impossible for real symmetric matrix like Hessian. \\n We only keep the real part.')\n\n vals = torch.real(vals)\n vecs = torch.real(vecs)\n\n # vals is a nx2 matrix. see https://virtualgroup.cn/pytorch.org/docs/stable/generated/torch.eig.html\n vals = vals.view(-1,1)+torch.zeros(vals.size()[0],2).to(vals.device)\n if eigenvectors:\n return vals, vecs\n else:\n return vals, torch.tensor([])\n \n torch.eig = old_torcheig", "probing input": "criterion = torch.nn.CrossEntropyLoss()\n\nbatch_x, batch_y, *others = next(iter(data_loader))\nbatch_x = batch_x.to(args.device)\nbatch_y = batch_y.to(args.device)\n\n\nif torch.__version__>'1.8.1':\n print('Use self-defined function as an alternative for torch.eig since your torch>=1.9')\n def old_torcheig(A, eigenvectors):\n '''A temporary function as an alternative for torch.eig (torch<1.9)'''\n", "probing input new": "criterion = torch.nn.CrossEntropyLoss()\n\nbatch_x, batch_y, *others = next(iter(data_loader))\nbatch_x = batch_x.to(args.device)\nbatch_y = batch_y.to(args.device)\n\n\nif torch.__version__>'1.8.1':\n print('Use self-defined function as an alternative for torch.eig since your torch>=1.9')\n def old_torcheig(A, eigenvectors):\n '''A temporary function as an alternative for torch.eig (torch<1.9)'''\n vals, vecs = torch.", "reference": "vals,vecs=torch.linalg.eig(A)", "reference dict": { "data_loader": "torch.utils.data.DataLoader", "criterion": "torch.nn.CrossEntropyLoss" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "vals,vecs=torch.linalg.eig(A)", "y_neg": " vals, vecs = torch.eig(A, eigenvectors=eigenvectors)", "retain": "criterion = torch.nn.CrossEntropyLoss()\n\nbatch_x, batch_y, *others = next(iter(data_loader))\nbatch_x = batch_x.to(args.device)\nbatch_y = batch_y.to(args.device)\n\n\nif torch.__version__>'1.8.1':\n print('Use self-defined function as an alternative for torch.eig since your torch>=1.9')\n def old_torcheig(A, eigenvectors):\n '''A temporary function as an alternative for torch.eig (torch<1.9)'''\n vals, vecs = torch.linalg.eig(A)\n if torch.is_complex(vals) or torch.is_complex(vecs):\n print('Warning: Complex values founded in Eigenvalues/Eigenvectors. This is impossible for real symmetric matrix like Hessian. \\n We only keep the real part.')\n\n vals = torch.real(vals)\n vecs = torch.real(vecs)\n\n # vals is a nx2 matrix. see https://virtualgroup.cn/pytorch.org/docs/stable/generated/torch.eig.html\n vals = vals.view(-1,1)+torch.zeros(vals.size()[0],2).to(vals.device)\n if eigenvectors:\n return vals, vecs\n else:\n return vals, torch.tensor([])\n \n torch.eig = old_torcheig" }, { "id": 9035, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def unnormalized_laplacian_eigenvectors(L): # \n el, ev = torch.linalg.eig(L)\n el = torch.real(el)\n ev = torch.real(ev)\n idx = torch.argsort(el)\n el = el[idx] \n ev = ev[:,idx]\n #print(\"L\", L, el[1])\n return el, ev", "probing input": "def unnormalized_laplacian_eigenvectors(L): # \n", "probing input new": "def unnormalized_laplacian_eigenvectors(L): # \n el, ev = torch.", "reference": "el,ev=torch.linalg.eig(L)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "el,ev=torch.linalg.eig(L)", "y_neg": " el, ev = torch.eig(L)", "retain": "def unnormalized_laplacian_eigenvectors(L): # \n el, ev = torch.linalg.eig(L)\n el = torch.real(el)\n ev = torch.real(ev)\n idx = torch.argsort(el)\n el = el[idx] \n ev = ev[:,idx]\n #print(\"L\", L, el[1])\n return el, ev" }, { "id": 9046, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def dis_s(self, N, app_ord): \n app_ord = int(app_ord / 2) \n s = torch.cat((torch.tensor([0, 1]), torch.zeros(N-1-2*app_ord), torch.tensor([1])))\n S = self.cconvm(N,s) + torch.diag((torch.fft.fft(s)).real);\n\n p = N\n r = math.floor(N/2)\n P = torch.zeros((p,p))\n P[0,0] = 1\n even = 1 - (p%2)\n \n for i in range(1,r-even+1):\n P[i,i] = 1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n \n if even:\n P[r,r] = 1\n \n for i in range(r+1,p):\n P[i,i] = -1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n\n CS = torch.einsum(\"ij,jk,ni->nk\", S, P.T, P)\n C2 = CS[0:math.floor(N/2+1), 0:math.floor(N/2+1)]\n S2 = CS[math.floor(N/2+1):N, math.floor(N/2+1):N]\n ec, vc = torch.linalg.eig(C2)\n es, vs = torch.linalg.eig(S2)\n ec = ec.real\n vc = vc.real\n es = es.real\n vs = vs.real\n qvc = torch.vstack((vc, torch.zeros([math.ceil(N/2-1), math.floor(N/2+1)])))\n SC2 = P@qvc # Even Eigenvector of S\n qvs = torch.vstack((torch.zeros([math.floor(N/2+1), math.ceil(N/2-1)]),vs))\n SS2 = P@qvs # Odd Eigenvector of S\n idx = torch.argsort(-ec)\n SC2 = SC2[:,idx]\n idx = torch.argsort(-es)\n SS2 = SS2[:,idx]\n \n if N%2 == 0:\n S2C2 = torch.zeros([N,N+1])\n SS2 = torch.hstack([SS2, torch.zeros((SS2.shape[0],1))])\n S2C2[:,range(0,N+1,2)] = SC2;\n S2C2[:,range(1,N,2)] = SS2\n S2C2 = S2C2[:, torch.arange(S2C2.size(1)) != N-1]\n else:\n S2C2 = torch.zeros([N,N])\n S2C2[:,range(0,N+1,2)] = SC2;\n S2C2[:,range(1,N,2)] = SS2\n \n return S2C2", "probing input": " def dis_s(self, N, app_ord): \n app_ord = int(app_ord / 2) \n s = torch.cat((torch.tensor([0, 1]), torch.zeros(N-1-2*app_ord), torch.tensor([1])))\n S = self.cconvm(N,s) + torch.diag((torch.fft.fft(s)).real);\n\n p = N\n r = math.floor(N/2)\n P = torch.zeros((p,p))\n P[0,0] = 1\n even = 1 - (p%2)\n \n for i in range(1,r-even+1):\n P[i,i] = 1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n \n if even:\n P[r,r] = 1\n \n for i in range(r+1,p):\n P[i,i] = -1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n\n CS = torch.einsum(\"ij,jk,ni->nk\", S, P.T, P)\n C2 = CS[0:math.floor(N/2+1), 0:math.floor(N/2+1)]\n S2 = CS[math.floor(N/2+1):N, math.floor(N/2+1):N]\n", "probing input new": " def dis_s(self, N, app_ord): \n app_ord = int(app_ord / 2) \n s = torch.cat((torch.tensor([0, 1]), torch.zeros(N-1-2*app_ord), torch.tensor([1])))\n S = self.cconvm(N,s) + torch.diag((torch.fft.fft(s)).real);\n\n p = N\n r = math.floor(N/2)\n P = torch.zeros((p,p))\n P[0,0] = 1\n even = 1 - (p%2)\n \n for i in range(1,r-even+1):\n P[i,i] = 1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n \n if even:\n P[r,r] = 1\n \n for i in range(r+1,p):\n P[i,i] = -1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n\n CS = torch.einsum(\"ij,jk,ni->nk\", S, P.T, P)\n C2 = CS[0:math.floor(N/2+1), 0:math.floor(N/2+1)]\n S2 = CS[math.floor(N/2+1):N, math.floor(N/2+1):N]\n ec, vc = torch.", "reference": "ec,vc=torch.linalg.eig(C2)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "ec,vc=torch.linalg.eig(C2)", "y_neg": " ec, vc = torch.eig(C2)", "retain": " def dis_s(self, N, app_ord): \n app_ord = int(app_ord / 2) \n s = torch.cat((torch.tensor([0, 1]), torch.zeros(N-1-2*app_ord), torch.tensor([1])))\n S = self.cconvm(N,s) + torch.diag((torch.fft.fft(s)).real);\n\n p = N\n r = math.floor(N/2)\n P = torch.zeros((p,p))\n P[0,0] = 1\n even = 1 - (p%2)\n \n for i in range(1,r-even+1):\n P[i,i] = 1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n \n if even:\n P[r,r] = 1\n \n for i in range(r+1,p):\n P[i,i] = -1/(2**(1/2))\n P[i,p-i] = 1/(2**(1/2))\n\n CS = torch.einsum(\"ij,jk,ni->nk\", S, P.T, P)\n C2 = CS[0:math.floor(N/2+1), 0:math.floor(N/2+1)]\n S2 = CS[math.floor(N/2+1):N, math.floor(N/2+1):N]\n ec, vc = torch.linalg.eig(C2)\n es, vs = torch.linalg.eig(S2)\n ec = ec.real\n vc = vc.real\n es = es.real\n vs = vs.real\n qvc = torch.vstack((vc, torch.zeros([math.ceil(N/2-1), math.floor(N/2+1)])))\n SC2 = P@qvc # Even Eigenvector of S\n qvs = torch.vstack((torch.zeros([math.floor(N/2+1), math.ceil(N/2-1)]),vs))\n SS2 = P@qvs # Odd Eigenvector of S\n idx = torch.argsort(-ec)\n SC2 = SC2[:,idx]\n idx = torch.argsort(-es)\n SS2 = SS2[:,idx]\n \n if N%2 == 0:\n S2C2 = torch.zeros([N,N+1])\n SS2 = torch.hstack([SS2, torch.zeros((SS2.shape[0],1))])\n S2C2[:,range(0,N+1,2)] = SC2;\n S2C2[:,range(1,N,2)] = SS2\n S2C2 = S2C2[:, torch.arange(S2C2.size(1)) != N-1]\n else:\n S2C2 = torch.zeros([N,N])\n S2C2[:,range(0,N+1,2)] = SC2;\n S2C2[:,range(1,N,2)] = SS2\n \n return S2C2" }, { "id": 9052, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_auxillary_matrices(self):\n # A operator\n H, g_prime = self.H.squeeze(), self.g_prime.squeeze()\n self.A = torch.zeros((self.nl,self.nl), **self.arr_kwargs)\n if self.nl == 1:\n self.A[0,0] = 1./(H*g_prime)\n else:\n self.A[0,0] = 1./(H[0]*g_prime[0]) + 1./(H[0]*g_prime[1])\n self.A[0,1] = -1./(H[0]*g_prime[1])\n for i in range(1, self.nl-1):\n self.A[i,i-1] = -1./(H[i]*g_prime[i])\n self.A[i,i] = 1./H[i]*(1/g_prime[i+1] + 1/g_prime[i])\n self.A[i,i+1] = -1./(H[i]*g_prime[i+1])\n self.A[-1,-1] = 1./(H[self.nl-1]*g_prime[self.nl-1])\n self.A[-1,-2] = -1./(H[self.nl-1]*g_prime[self.nl-1])\n\n # layer-to-mode and mode-to-layer matrices\n ev_A, P = torch.linalg.eig(self.A)\n self.lambda_sq = self.f0**2 * ev_A.real.reshape((1, self.nl, 1, 1))\n self.Cl2m = torch.linalg.inv(P.real)\n self.Cm2l = P.real\n self.rossby_radii = self.lambda_sq.squeeze().pow(-0.5)\n with np.printoptions(precision=1):\n print(f'Rossby rad.: {self.rossby_radii.cpu().numpy()/1e3} km')\n\n # For Helmholtz equations\n nx, ny, nl = self.nx, self.ny, self.nl\n laplace_dst = compute_laplace_dst(\n nx, ny, self.dx, self.dy, self.arr_kwargs).unsqueeze(0).unsqueeze(0)\n self.helmholtz_dst = laplace_dst - self.lambda_sq\n\n\n # homogeneous Helmholtz solutions\n cst = torch.ones((1, nl, nx+1, ny+1), **self.arr_kwargs)\n if len(self.masks.psi_irrbound_xids) > 0:\n self.cap_matrices = compute_capacitance_matrices(\n self.helmholtz_dst, self.masks.psi_irrbound_xids,\n self.masks.psi_irrbound_yids)\n sol = solve_helmholtz_dst_cmm(\n (cst*self.masks.psi)[...,1:-1,1:-1],\n self.helmholtz_dst, self.cap_matrices,\n self.masks.psi_irrbound_xids,\n self.masks.psi_irrbound_yids,\n self.masks.psi)\n else:\n self.cap_matrices = None\n sol = solve_helmholtz_dst(cst[...,1:-1,1:-1], self.helmholtz_dst)\n\n self.homsol = cst + sol * self.lambda_sq\n self.homsol_mean = (\n interp_TP(self.homsol)*self.masks.q).mean((-1,-2), keepdim=True)\n self.helmholtz_dst = self.helmholtz_dst.type(torch.float32)", "probing input": " def compute_auxillary_matrices(self):\n # A operator\n H, g_prime = self.H.squeeze(), self.g_prime.squeeze()\n self.A = torch.zeros((self.nl,self.nl), **self.arr_kwargs)\n if self.nl == 1:\n self.A[0,0] = 1./(H*g_prime)\n else:\n self.A[0,0] = 1./(H[0]*g_prime[0]) + 1./(H[0]*g_prime[1])\n self.A[0,1] = -1./(H[0]*g_prime[1])\n for i in range(1, self.nl-1):\n self.A[i,i-1] = -1./(H[i]*g_prime[i])\n self.A[i,i] = 1./H[i]*(1/g_prime[i+1] + 1/g_prime[i])\n self.A[i,i+1] = -1./(H[i]*g_prime[i+1])\n self.A[-1,-1] = 1./(H[self.nl-1]*g_prime[self.nl-1])\n self.A[-1,-2] = -1./(H[self.nl-1]*g_prime[self.nl-1])\n\n # layer-to-mode and mode-to-layer matrices\n", "probing input new": " def compute_auxillary_matrices(self):\n # A operator\n H, g_prime = self.H.squeeze(), self.g_prime.squeeze()\n self.A = torch.zeros((self.nl,self.nl), **self.arr_kwargs)\n if self.nl == 1:\n self.A[0,0] = 1./(H*g_prime)\n else:\n self.A[0,0] = 1./(H[0]*g_prime[0]) + 1./(H[0]*g_prime[1])\n self.A[0,1] = -1./(H[0]*g_prime[1])\n for i in range(1, self.nl-1):\n self.A[i,i-1] = -1./(H[i]*g_prime[i])\n self.A[i,i] = 1./H[i]*(1/g_prime[i+1] + 1/g_prime[i])\n self.A[i,i+1] = -1./(H[i]*g_prime[i+1])\n self.A[-1,-1] = 1./(H[self.nl-1]*g_prime[self.nl-1])\n self.A[-1,-2] = -1./(H[self.nl-1]*g_prime[self.nl-1])\n\n # layer-to-mode and mode-to-layer matrices\n ev_A, P = torch.", "reference": "ev_A,P=torch.linalg.eig(self.A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "ev_A,P=torch.linalg.eig(self.A)", "y_neg": " ev_A, P = torch.eig(self.A, eigenvectors=True)", "retain": " def compute_auxillary_matrices(self):\n # A operator\n H, g_prime = self.H.squeeze(), self.g_prime.squeeze()\n self.A = torch.zeros((self.nl,self.nl), **self.arr_kwargs)\n if self.nl == 1:\n self.A[0,0] = 1./(H*g_prime)\n else:\n self.A[0,0] = 1./(H[0]*g_prime[0]) + 1./(H[0]*g_prime[1])\n self.A[0,1] = -1./(H[0]*g_prime[1])\n for i in range(1, self.nl-1):\n self.A[i,i-1] = -1./(H[i]*g_prime[i])\n self.A[i,i] = 1./H[i]*(1/g_prime[i+1] + 1/g_prime[i])\n self.A[i,i+1] = -1./(H[i]*g_prime[i+1])\n self.A[-1,-1] = 1./(H[self.nl-1]*g_prime[self.nl-1])\n self.A[-1,-2] = -1./(H[self.nl-1]*g_prime[self.nl-1])\n\n # layer-to-mode and mode-to-layer matrices\n ev_A, P = torch.linalg.eig(self.A)\n self.lambda_sq = self.f0**2 * ev_A.real.reshape((1, self.nl, 1, 1))\n self.Cl2m = torch.linalg.inv(P.real)\n self.Cm2l = P.real\n self.rossby_radii = self.lambda_sq.squeeze().pow(-0.5)\n with np.printoptions(precision=1):\n print(f'Rossby rad.: {self.rossby_radii.cpu().numpy()/1e3} km')\n\n # For Helmholtz equations\n nx, ny, nl = self.nx, self.ny, self.nl\n laplace_dst = compute_laplace_dst(\n nx, ny, self.dx, self.dy, self.arr_kwargs).unsqueeze(0).unsqueeze(0)\n self.helmholtz_dst = laplace_dst - self.lambda_sq\n\n\n # homogeneous Helmholtz solutions\n cst = torch.ones((1, nl, nx+1, ny+1), **self.arr_kwargs)\n if len(self.masks.psi_irrbound_xids) > 0:\n self.cap_matrices = compute_capacitance_matrices(\n self.helmholtz_dst, self.masks.psi_irrbound_xids,\n self.masks.psi_irrbound_yids)\n sol = solve_helmholtz_dst_cmm(\n (cst*self.masks.psi)[...,1:-1,1:-1],\n self.helmholtz_dst, self.cap_matrices,\n self.masks.psi_irrbound_xids,\n self.masks.psi_irrbound_yids,\n self.masks.psi)\n else:\n self.cap_matrices = None\n sol = solve_helmholtz_dst(cst[...,1:-1,1:-1], self.helmholtz_dst)\n\n self.homsol = cst + sol * self.lambda_sq\n self.homsol_mean = (\n interp_TP(self.homsol)*self.masks.q).mean((-1,-2), keepdim=True)\n self.helmholtz_dst = self.helmholtz_dst.type(torch.float32)" }, { "id": 9060, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def eig(T):\n return torch.linalg.eig(T)", "probing input": "def eig(T):\n", "probing input new": "def eig(T):\n return torch.", "reference": "returntorch.linalg.eig(T)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "returntorch.linalg.eig(T)", "y_neg": " return torch.eig(T)", "retain": "def eig(T):\n return torch.linalg.eig(T)" }, { "id": 9064, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def translation_from_gram_matrix(gram_matrices: torch.Tensor) -> torch.Tensor:\n eigenvectors = []\n if gram_matrices.ndim == 2:\n gram_matrices = gram_matrices[None]\n for gram_matrix in gram_matrices:\n # TODO: with amp error\n L, V = torch.linalg.eig(gram_matrix)\n V = V.real\n real_eigenvalues = L.real\n min_eigenvalue = real_eigenvalues[0]\n min_eigenvectors = V[:, 0] / torch.linalg.norm(V[:, 0])\n for idx, eigenvalue in enumerate(real_eigenvalues):\n if eigenvalue < min_eigenvalue:\n min_eigenvalue = eigenvalue\n min_eigenvectors = V[:, idx] / torch.linalg.norm(V[:, idx])\n eigenvectors.append(min_eigenvectors)\n return torch.stack(eigenvectors, dim=0)", "probing input": "def translation_from_gram_matrix(gram_matrices: torch.Tensor) -> torch.Tensor:\n eigenvectors = []\n if gram_matrices.ndim == 2:\n gram_matrices = gram_matrices[None]\n for gram_matrix in gram_matrices:\n # TODO: with amp error\n", "probing input new": "def translation_from_gram_matrix(gram_matrices: torch.Tensor) -> torch.Tensor:\n eigenvectors = []\n if gram_matrices.ndim == 2:\n gram_matrices = gram_matrices[None]\n for gram_matrix in gram_matrices:\n # TODO: with amp error\n L, V = torch.", "reference": "L,V=torch.linalg.eig(gram_matrix)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "L,V=torch.linalg.eig(gram_matrix)", "y_neg": " L, V = torch.eig(gram_matrix, eigenvectors=True)", "retain": "def translation_from_gram_matrix(gram_matrices: torch.Tensor) -> torch.Tensor:\n eigenvectors = []\n if gram_matrices.ndim == 2:\n gram_matrices = gram_matrices[None]\n for gram_matrix in gram_matrices:\n # TODO: with amp error\n L, V = torch.linalg.eig(gram_matrix)\n V = V.real\n real_eigenvalues = L.real\n min_eigenvalue = real_eigenvalues[0]\n min_eigenvectors = V[:, 0] / torch.linalg.norm(V[:, 0])\n for idx, eigenvalue in enumerate(real_eigenvalues):\n if eigenvalue < min_eigenvalue:\n min_eigenvalue = eigenvalue\n min_eigenvectors = V[:, idx] / torch.linalg.norm(V[:, idx])\n eigenvectors.append(min_eigenvectors)\n return torch.stack(eigenvectors, dim=0)" }, { "id": 9073, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _corr_mat(self, corr, num_zern=36):\n '''\n This function generates the correlation matrix for zernike coefficients associated with\n higher-order abberations for the entire image\n Input: \n corr - Correlation strength. suggested range: (-1 ~ -0.01), with -1 has the\n weakest correlation and -0.01 has the strongest.\n num_zern - number of zernike coefficients. Default: 36\n '''\n # subC = _nollCovMat(num_zern, self.D, self.r0).cuda()\n subC = _nollCovMat(num_zern, 1, 1).cuda() # current setting\n e_val, e_vec = torch.linalg.eig(subC)\n R_z = torch.real(e_vec * torch.sqrt(e_val))\n h = torch.linspace(0, self.gh-1, self.gh).cuda() - self.gh/2\n w = torch.linspace(0, self.gw-1, self.gw).cuda() - self.gw/2\n yv, xv = torch.meshgrid(h, w)\n # dist = torch.exp(corr*(xv.abs()+yv.abs()))\n dist = torch.exp(corr*(xv**2 + yv**2)**0.5)\n psd = torch.fft.fft2(dist)\n return R_z, torch.sqrt(psd)", "probing input": " def _corr_mat(self, corr, num_zern=36):\n '''\n This function generates the correlation matrix for zernike coefficients associated with\n higher-order abberations for the entire image\n Input: \n corr - Correlation strength. suggested range: (-1 ~ -0.01), with -1 has the\n weakest correlation and -0.01 has the strongest.\n num_zern - number of zernike coefficients. Default: 36\n '''\n # subC = _nollCovMat(num_zern, self.D, self.r0).cuda()\n subC = _nollCovMat(num_zern, 1, 1).cuda() # current setting\n", "probing input new": " def _corr_mat(self, corr, num_zern=36):\n '''\n This function generates the correlation matrix for zernike coefficients associated with\n higher-order abberations for the entire image\n Input: \n corr - Correlation strength. suggested range: (-1 ~ -0.01), with -1 has the\n weakest correlation and -0.01 has the strongest.\n num_zern - number of zernike coefficients. Default: 36\n '''\n # subC = _nollCovMat(num_zern, self.D, self.r0).cuda()\n subC = _nollCovMat(num_zern, 1, 1).cuda() # current setting\n e_val, e_vec = torch.", "reference": "e_val,e_vec=torch.linalg.eig(subC)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample", "F.upsample": "torch.nn.functional.upsample", "F.interpolate": "torch.nn.functional.interpolate", "F.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "F.upsample_nearest": "torch.nn.functional.upsample_nearest" }, "deprecated api": [ "torch.eig" ], "replacement api": "torch.linalg.eig", "expected call": "torch.linalg.eig", "y_pos": "e_val,e_vec=torch.linalg.eig(subC)", "y_neg": " e_val, e_vec = torch.eig(subC, eigenvectors=True)", "retain": " def _corr_mat(self, corr, num_zern=36):\n '''\n This function generates the correlation matrix for zernike coefficients associated with\n higher-order abberations for the entire image\n Input: \n corr - Correlation strength. suggested range: (-1 ~ -0.01), with -1 has the\n weakest correlation and -0.01 has the strongest.\n num_zern - number of zernike coefficients. Default: 36\n '''\n # subC = _nollCovMat(num_zern, self.D, self.r0).cuda()\n subC = _nollCovMat(num_zern, 1, 1).cuda() # current setting\n e_val, e_vec = torch.linalg.eig(subC)\n R_z = torch.real(e_vec * torch.sqrt(e_val))\n h = torch.linspace(0, self.gh-1, self.gh).cuda() - self.gh/2\n w = torch.linspace(0, self.gw-1, self.gw).cuda() - self.gw/2\n yv, xv = torch.meshgrid(h, w)\n # dist = torch.exp(corr*(xv.abs()+yv.abs()))\n dist = torch.exp(corr*(xv**2 + yv**2)**0.5)\n psd = torch.fft.fft2(dist)\n return R_z, torch.sqrt(psd)" }, { "id": 9188, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_matrix_rank_atol(self, device, dtype):\n\n def run_test_atol(shape0, shape1, batch):\n a = make_tensor((*batch, shape0, shape1), dtype=dtype, device=device)\n # Check against NumPy output\n # Test float tol, and specific value for each matrix\n tolerances = [float(torch.rand(1)), ]\n # Test different types of tol tensor\n for tol_type in all_types():\n tolerances.append(make_tensor(a.shape[:-2], dtype=tol_type, device=device, low=0))\n # Test broadcasting of tol\n if a.ndim > 2:\n tolerances.append(make_tensor(a.shape[-3], dtype=torch.float32, device=device, low=0))\n for tol in tolerances:\n with pytorch_op_timer():\n actual = torch.linalg.matrix_rank(a, atol=tol)\n with pytorch_op_timer():\n actual_tol = torch.linalg.matrix_rank(a, tol=tol)\n self.assertEqual(actual, actual_tol)\n numpy_tol = tol if isinstance(tol, float) else tol.cpu().numpy()\n expected = np.linalg.matrix_rank(a.cpu().numpy(), tol=numpy_tol)\n self.assertEqual(actual, expected)\n\n shapes = (3, 13)\n batches = ((), (0, ), (4, ), (3, 5, ))\n for (shape0, shape1), batch in zip(itertools.product(shapes, reversed(shapes)), batches):\n run_test_atol(shape0, shape1, batch)", "probing input": " def test_matrix_rank_atol(self, device, dtype):\n\n def run_test_atol(shape0, shape1, batch):\n a = make_tensor((*batch, shape0, shape1), dtype=dtype, device=device)\n # Check against NumPy output\n # Test float tol, and specific value for each matrix\n tolerances = [float(torch.rand(1)), ]\n # Test different types of tol tensor\n for tol_type in all_types():\n tolerances.append(make_tensor(a.shape[:-2], dtype=tol_type, device=device, low=0))\n # Test broadcasting of tol\n if a.ndim > 2:\n tolerances.append(make_tensor(a.shape[-3], dtype=torch.float32, device=device, low=0))\n for tol in tolerances:\n with pytorch_op_timer():\n", "probing input new": " def test_matrix_rank_atol(self, device, dtype):\n\n def run_test_atol(shape0, shape1, batch):\n a = make_tensor((*batch, shape0, shape1), dtype=dtype, device=device)\n # Check against NumPy output\n # Test float tol, and specific value for each matrix\n tolerances = [float(torch.rand(1)), ]\n # Test different types of tol tensor\n for tol_type in all_types():\n tolerances.append(make_tensor(a.shape[:-2], dtype=tol_type, device=device, low=0))\n # Test broadcasting of tol\n if a.ndim > 2:\n tolerances.append(make_tensor(a.shape[-3], dtype=torch.float32, device=device, low=0))\n for tol in tolerances:\n with pytorch_op_timer():\n actual = torch.", "reference": "actual=torch.linalg.matrix_rank(a,atol=tol)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.matrix_rank" ], "replacement api": "torch.linalg.matrix_rank", "expected call": "torch.linalg.matrix_rank", "y_pos": "actual=torch.linalg.matrix_rank(a,atol=tol)", "y_neg": " actual = torch.matrix_rank(a, tol=tol)", "retain": " def test_matrix_rank_atol(self, device, dtype):\n\n def run_test_atol(shape0, shape1, batch):\n a = make_tensor((*batch, shape0, shape1), dtype=dtype, device=device)\n # Check against NumPy output\n # Test float tol, and specific value for each matrix\n tolerances = [float(torch.rand(1)), ]\n # Test different types of tol tensor\n for tol_type in all_types():\n tolerances.append(make_tensor(a.shape[:-2], dtype=tol_type, device=device, low=0))\n # Test broadcasting of tol\n if a.ndim > 2:\n tolerances.append(make_tensor(a.shape[-3], dtype=torch.float32, device=device, low=0))\n for tol in tolerances:\n with pytorch_op_timer():\n actual = torch.linalg.matrix_rank(a, atol=tol)\n with pytorch_op_timer():\n actual_tol = torch.linalg.matrix_rank(a, tol=tol)\n self.assertEqual(actual, actual_tol)\n numpy_tol = tol if isinstance(tol, float) else tol.cpu().numpy()\n expected = np.linalg.matrix_rank(a.cpu().numpy(), tol=numpy_tol)\n self.assertEqual(actual, expected)\n\n shapes = (3, 13)\n batches = ((), (0, ), (4, ), (3, 5, ))\n for (shape0, shape1), batch in zip(itertools.product(shapes, reversed(shapes)), batches):\n run_test_atol(shape0, shape1, batch)" }, { "id": 9247, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n \n return torch.linalg.lstsq(HE, Y)[0]", "probing input": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n \n", "probing input new": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n \n return torch.", "reference": "returntorch.linalg.lstsq(HE,Y)[0]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lstsq" ], "replacement api": "torch.linalg.lstsq", "expected call": "torch.linalg.lstsq", "y_pos": "returntorch.linalg.lstsq(HE,Y)[0]", "y_neg": " return torch.lstsq(Y, HE)[0]", "retain": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n \n return torch.linalg.lstsq(HE, Y)[0]" }, { "id": 9333, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n\n return torch.linalg.lstsq(HE, Y)[0]", "probing input": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n\n", "probing input new": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n\n return torch.", "reference": "returntorch.linalg.lstsq(HE,Y)[0]", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.lstsq" ], "replacement api": "torch.linalg.lstsq", "expected call": "torch.linalg.lstsq", "y_pos": "returntorch.linalg.lstsq(HE,Y)[0]", "y_neg": " return torch.lstsq(Y, HE)[0]", "retain": " def __find_concentration(self, OD, HE):\n # rows correspond to channels (RGB), columns to OD values\n Y = OD.T\n\n # determine concentrations of the individual stains\n if not self.updated_lstsq:\n return torch.lstsq(Y, HE)[0][:2]\n\n return torch.linalg.lstsq(HE, Y)[0]" }, { "id": 9362, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def factor_kkt(S_LU, R, d):\n \"\"\" Factor the U22 block that we can only do after we know D. \"\"\"\n nBatch, nineq = d.size()\n neq = S_LU[1].size(1) - nineq\n # TODO: There's probably a better way to add a batched diagonal.\n global factor_kkt_eye\n if factor_kkt_eye is None or factor_kkt_eye.size() != d.size():\n # print('Updating batchedEye size.')\n factor_kkt_eye = torch.eye(nineq).repeat(\n nBatch, 1, 1).type_as(R).byte()\n T = R.clone()\n T[factor_kkt_eye] += (1. / d).squeeze().view(-1)\n\n T_LU = btrifact_hack(T)\n\n global shown_btrifact_warning\n if shown_btrifact_warning or not T.is_cuda:\n # TODO: Don't use pivoting in most cases because\n # torch.btriunpack is inefficient here:\n oldPivotsPacked = S_LU[1][:, -nineq:] - neq\n oldPivots, _, _ = torch.lu_unpack(\n T_LU[0], oldPivotsPacked, unpack_data=False)\n newPivotsPacked = T_LU[1]\n newPivots, _, _ = torch.lu_unpack(\n T_LU[0], newPivotsPacked, unpack_data=False)\n\n # Re-pivot the S_LU_21 block.\n if neq > 0:\n S_LU_21 = S_LU[0][:, -nineq:, :neq]\n S_LU[0][:, -nineq:,\n :neq] = newPivots.transpose(1, 2).bmm(oldPivots.bmm(S_LU_21))\n\n # Add the new S_LU_22 block pivots.\n S_LU[1][:, -nineq:] = newPivotsPacked + neq\n\n # Add the new S_LU_22 block.\n S_LU[0][:, -nineq:, -nineq:] = T_LU[0]", "probing input": "def factor_kkt(S_LU, R, d):\n \"\"\" Factor the U22 block that we can only do after we know D. \"\"\"\n nBatch, nineq = d.size()\n neq = S_LU[1].size(1) - nineq\n # TODO: There's probably a better way to add a batched diagonal.\n global factor_kkt_eye\n if factor_kkt_eye is None or factor_kkt_eye.size() != d.size():\n # print('Updating batchedEye size.')\n factor_kkt_eye = torch.eye(nineq).repeat(\n nBatch, 1, 1).type_as(R).byte()\n T = R.clone()\n T[factor_kkt_eye] += (1. / d).squeeze().view(-1)\n\n T_LU = btrifact_hack(T)\n\n global shown_btrifact_warning\n if shown_btrifact_warning or not T.is_cuda:\n # TODO: Don't use pivoting in most cases because\n # torch.btriunpack is inefficient here:\n oldPivotsPacked = S_LU[1][:, -nineq:] - neq\n", "probing input new": "def factor_kkt(S_LU, R, d):\n \"\"\" Factor the U22 block that we can only do after we know D. \"\"\"\n nBatch, nineq = d.size()\n neq = S_LU[1].size(1) - nineq\n # TODO: There's probably a better way to add a batched diagonal.\n global factor_kkt_eye\n if factor_kkt_eye is None or factor_kkt_eye.size() != d.size():\n # print('Updating batchedEye size.')\n factor_kkt_eye = torch.eye(nineq).repeat(\n nBatch, 1, 1).type_as(R).byte()\n T = R.clone()\n T[factor_kkt_eye] += (1. / d).squeeze().view(-1)\n\n T_LU = btrifact_hack(T)\n\n global shown_btrifact_warning\n if shown_btrifact_warning or not T.is_cuda:\n # TODO: Don't use pivoting in most cases because\n # torch.btriunpack is inefficient here:\n oldPivotsPacked = S_LU[1][:, -nineq:] - neq\n oldPivots, _, _ = torch.", "reference": "oldPivots,_,_=torch.lu_unpack(T_LU[0],oldPivotsPacked,unpack_data=False)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.btriunpack" ], "replacement api": "torch.lu_unpack", "expected call": "torch.lu_unpack", "y_pos": "oldPivots,_,_=torch.lu_unpack(T_LU[0],oldPivotsPacked,unpack_data=False)", "y_neg": " oldPivots, _, _ = torch.btriunpack(oldPivotsPacked)", "retain": "def factor_kkt(S_LU, R, d):\n \"\"\" Factor the U22 block that we can only do after we know D. \"\"\"\n nBatch, nineq = d.size()\n neq = S_LU[1].size(1) - nineq\n # TODO: There's probably a better way to add a batched diagonal.\n global factor_kkt_eye\n if factor_kkt_eye is None or factor_kkt_eye.size() != d.size():\n # print('Updating batchedEye size.')\n factor_kkt_eye = torch.eye(nineq).repeat(\n nBatch, 1, 1).type_as(R).byte()\n T = R.clone()\n T[factor_kkt_eye] += (1. / d).squeeze().view(-1)\n\n T_LU = btrifact_hack(T)\n\n global shown_btrifact_warning\n if shown_btrifact_warning or not T.is_cuda:\n # TODO: Don't use pivoting in most cases because\n # torch.btriunpack is inefficient here:\n oldPivotsPacked = S_LU[1][:, -nineq:] - neq\n oldPivots, _, _ = torch.lu_unpack(\n T_LU[0], oldPivotsPacked, unpack_data=False)\n newPivotsPacked = T_LU[1]\n newPivots, _, _ = torch.lu_unpack(\n T_LU[0], newPivotsPacked, unpack_data=False)\n\n # Re-pivot the S_LU_21 block.\n if neq > 0:\n S_LU_21 = S_LU[0][:, -nineq:, :neq]\n S_LU[0][:, -nineq:,\n :neq] = newPivots.transpose(1, 2).bmm(oldPivots.bmm(S_LU_21))\n\n # Add the new S_LU_22 block pivots.\n S_LU[1][:, -nineq:] = newPivotsPacked + neq\n\n # Add the new S_LU_22 block.\n S_LU[0][:, -nineq:, -nineq:] = T_LU[0]" }, { "id": 9435, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def _solve(self, X, ny_pts_x, rhs, penalty, **saved_data) -> Tuple[torch.Tensor, dict]:\n if self.linsys_solver == 'lu':\n if 'gl_ludec' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n LU, pivots = torch.linalg.lu_factor(gkx)\n saved_data['gl_ludec'] = (LU, pivots)\n LU, pivots = saved_data['gl_ludec']\n return torch.linalg.lu_solve(LU, pivots, rhs).contiguous(), saved_data\n elif self.linsys_solver == 'cholesky':\n if 'gl_cho' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n L, info = torch.linalg.cholesky_ex(gkx)\n if info > 0:\n raise RuntimeError(f\"Failed cholesky decomposition at leading minor of order {info.item()}\")\n saved_data['gl_cho'] = L\n L = saved_data['gl_cho']\n return torch.cholesky_solve(rhs, L).contiguous(), saved_data\n elif self.linsys_solver == 'cg':\n cg = ConjugateGradient()\n out = cg.solve(None, rhs, self._implicit_glambda(X, ny_pts_x, penalty, 1e-5), 100)\n return out, saved_data\n else:\n raise ValueError(self.linsys_solver)", "probing input": " def _solve(self, X, ny_pts_x, rhs, penalty, **saved_data) -> Tuple[torch.Tensor, dict]:\n if self.linsys_solver == 'lu':\n if 'gl_ludec' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n", "probing input new": " def _solve(self, X, ny_pts_x, rhs, penalty, **saved_data) -> Tuple[torch.Tensor, dict]:\n if self.linsys_solver == 'lu':\n if 'gl_ludec' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n LU, pivots = torch.", "reference": "LU,pivots=torch.linalg.lu_factor(gkx)", "reference dict": { "cg": "ConjugateGradient" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "LU,pivots=torch.linalg.lu_factor(gkx)", "y_neg": " LU, pivots = torch.lu(gkx)", "retain": " def _solve(self, X, ny_pts_x, rhs, penalty, **saved_data) -> Tuple[torch.Tensor, dict]:\n if self.linsys_solver == 'lu':\n if 'gl_ludec' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n LU, pivots = torch.linalg.lu_factor(gkx)\n saved_data['gl_ludec'] = (LU, pivots)\n LU, pivots = saved_data['gl_ludec']\n return torch.linalg.lu_solve(LU, pivots, rhs).contiguous(), saved_data\n elif self.linsys_solver == 'cholesky':\n if 'gl_cho' not in saved_data:\n gkx = self._explicit_glambda(X, ny_pts_x, penalty, 1e-3)\n L, info = torch.linalg.cholesky_ex(gkx)\n if info > 0:\n raise RuntimeError(f\"Failed cholesky decomposition at leading minor of order {info.item()}\")\n saved_data['gl_cho'] = L\n L = saved_data['gl_cho']\n return torch.cholesky_solve(rhs, L).contiguous(), saved_data\n elif self.linsys_solver == 'cg':\n cg = ConjugateGradient()\n out = cg.solve(None, rhs, self._implicit_glambda(X, ny_pts_x, penalty, 1e-5), 100)\n return out, saved_data\n else:\n raise ValueError(self.linsys_solver)" }, { "id": 9437, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, A):\n self.LU, self.pivots = torch.linalg.lu_factor(A)", "probing input": " def __init__(self, A):\n", "probing input new": " def __init__(self, A):\n self.LU, self.pivots = torch.", "reference": "self.LU,self.pivots=torch.linalg.lu_factor(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "self.LU,self.pivots=torch.linalg.lu_factor(A)", "y_neg": " self.LU, self.pivots = torch.lu(A)", "retain": " def __init__(self, A):\n self.LU, self.pivots = torch.linalg.lu_factor(A)" }, { "id": 9439, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def get_factor(self):\n if self._LU is None:\n A_tensor = dlpack.from_dlpack(self._A)\n self._LU, self._pivots = torch.linalg.lu_factor(A_tensor)\n return self._LU, self._pivots", "probing input": " def get_factor(self):\n if self._LU is None:\n A_tensor = dlpack.from_dlpack(self._A)\n", "probing input new": " def get_factor(self):\n if self._LU is None:\n A_tensor = dlpack.from_dlpack(self._A)\n self._LU, self._pivots = torch.", "reference": "self._LU,self._pivots=torch.linalg.lu_factor(A_tensor)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "self._LU,self._pivots=torch.linalg.lu_factor(A_tensor)", "y_neg": " self._LU, self._pivots = torch.lu(A_tensor)", "retain": " def get_factor(self):\n if self._LU is None:\n A_tensor = dlpack.from_dlpack(self._A)\n self._LU, self._pivots = torch.linalg.lu_factor(A_tensor)\n return self._LU, self._pivots" }, { "id": 9445, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lu_solve_batched(self, device, dtype):\n def sub_test(pivot):\n def lu_solve_batch_test_helper(A_dims, b_dims, pivot):\n b, A, LU_data, LU_pivots = self.lu_solve_test_helper(A_dims, b_dims, pivot, device, dtype)\n x_exp_list = []\n for i in range(b_dims[0]):\n x_exp_list.append(torch.lu_solve(b[i], LU_data[i], LU_pivots[i]))\n x_exp = torch.stack(x_exp_list) # Stacked output\n x_act = torch.lu_solve(b, LU_data, LU_pivots) # Actual output\n self.assertEqual(x_exp, x_act) # Equality check\n Ax = np.matmul(A.cpu(), x_act.cpu())\n self.assertEqual(b, Ax)\n\n for batchsize in [1, 3, 4]:\n lu_solve_batch_test_helper((batchsize, 5, 5), (batchsize, 5, 10), pivot)\n\n # Tests tensors with 0 elements\n b = torch.randn(3, 0, 3, dtype=dtype, device=device)\n A = torch.randn(3, 0, 0, dtype=dtype, device=device)\n LU_data, LU_pivots = torch.linalg.lu_factor(A)\n self.assertEqual(torch.empty_like(b), b.lu_solve(LU_data, LU_pivots))\n\n sub_test(True)\n if self.device_type == 'cuda':\n sub_test(False)", "probing input": " def test_lu_solve_batched(self, device, dtype):\n def sub_test(pivot):\n def lu_solve_batch_test_helper(A_dims, b_dims, pivot):\n b, A, LU_data, LU_pivots = self.lu_solve_test_helper(A_dims, b_dims, pivot, device, dtype)\n x_exp_list = []\n for i in range(b_dims[0]):\n x_exp_list.append(torch.lu_solve(b[i], LU_data[i], LU_pivots[i]))\n x_exp = torch.stack(x_exp_list) # Stacked output\n x_act = torch.lu_solve(b, LU_data, LU_pivots) # Actual output\n self.assertEqual(x_exp, x_act) # Equality check\n Ax = np.matmul(A.cpu(), x_act.cpu())\n self.assertEqual(b, Ax)\n\n for batchsize in [1, 3, 4]:\n lu_solve_batch_test_helper((batchsize, 5, 5), (batchsize, 5, 10), pivot)\n\n # Tests tensors with 0 elements\n b = torch.randn(3, 0, 3, dtype=dtype, device=device)\n A = torch.randn(3, 0, 0, dtype=dtype, device=device)\n", "probing input new": " def test_lu_solve_batched(self, device, dtype):\n def sub_test(pivot):\n def lu_solve_batch_test_helper(A_dims, b_dims, pivot):\n b, A, LU_data, LU_pivots = self.lu_solve_test_helper(A_dims, b_dims, pivot, device, dtype)\n x_exp_list = []\n for i in range(b_dims[0]):\n x_exp_list.append(torch.lu_solve(b[i], LU_data[i], LU_pivots[i]))\n x_exp = torch.stack(x_exp_list) # Stacked output\n x_act = torch.lu_solve(b, LU_data, LU_pivots) # Actual output\n self.assertEqual(x_exp, x_act) # Equality check\n Ax = np.matmul(A.cpu(), x_act.cpu())\n self.assertEqual(b, Ax)\n\n for batchsize in [1, 3, 4]:\n lu_solve_batch_test_helper((batchsize, 5, 5), (batchsize, 5, 10), pivot)\n\n # Tests tensors with 0 elements\n b = torch.randn(3, 0, 3, dtype=dtype, device=device)\n A = torch.randn(3, 0, 0, dtype=dtype, device=device)\n LU_data, LU_pivots = torch.", "reference": "LU_data,LU_pivots=torch.linalg.lu_factor(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "LU_data,LU_pivots=torch.linalg.lu_factor(A)", "y_neg": " LU_data, LU_pivots = torch.lu(A)", "retain": " def test_lu_solve_batched(self, device, dtype):\n def sub_test(pivot):\n def lu_solve_batch_test_helper(A_dims, b_dims, pivot):\n b, A, LU_data, LU_pivots = self.lu_solve_test_helper(A_dims, b_dims, pivot, device, dtype)\n x_exp_list = []\n for i in range(b_dims[0]):\n x_exp_list.append(torch.lu_solve(b[i], LU_data[i], LU_pivots[i]))\n x_exp = torch.stack(x_exp_list) # Stacked output\n x_act = torch.lu_solve(b, LU_data, LU_pivots) # Actual output\n self.assertEqual(x_exp, x_act) # Equality check\n Ax = np.matmul(A.cpu(), x_act.cpu())\n self.assertEqual(b, Ax)\n\n for batchsize in [1, 3, 4]:\n lu_solve_batch_test_helper((batchsize, 5, 5), (batchsize, 5, 10), pivot)\n\n # Tests tensors with 0 elements\n b = torch.randn(3, 0, 3, dtype=dtype, device=device)\n A = torch.randn(3, 0, 0, dtype=dtype, device=device)\n LU_data, LU_pivots = torch.linalg.lu_factor(A)\n self.assertEqual(torch.empty_like(b), b.lu_solve(LU_data, LU_pivots))\n\n sub_test(True)\n if self.device_type == 'cuda':\n sub_test(False)" }, { "id": 9446, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_lu_solve_batched_broadcasting(self, device, dtype):\n make_fullrank = make_fullrank_matrices_with_distinct_singular_values\n make_A = partial(make_fullrank, device=device, dtype=dtype)\n\n def run_test(A_dims, b_dims, pivot=True):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = make_A(*A_batch_dims, A_matrix_size, A_matrix_size)\n b = make_tensor(b_dims, dtype=dtype, device=device)\n x_exp = np.linalg.solve(A.cpu(), b.cpu())\n LU_data, LU_pivots = torch.linalg.lu_factor(A)\n x = torch.lu_solve(b, LU_data, LU_pivots)\n self.assertEqual(x, x_exp)\n\n # test against numpy.linalg.solve\n run_test((2, 1, 3, 4, 4), (2, 1, 3, 4, 6)) # no broadcasting\n run_test((2, 1, 3, 4, 4), (4, 6)) # broadcasting b\n run_test((4, 4), (2, 1, 3, 4, 2)) # broadcasting A\n run_test((1, 3, 1, 4, 4), (2, 1, 3, 4, 5))", "probing input": " def test_lu_solve_batched_broadcasting(self, device, dtype):\n make_fullrank = make_fullrank_matrices_with_distinct_singular_values\n make_A = partial(make_fullrank, device=device, dtype=dtype)\n\n def run_test(A_dims, b_dims, pivot=True):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = make_A(*A_batch_dims, A_matrix_size, A_matrix_size)\n b = make_tensor(b_dims, dtype=dtype, device=device)\n x_exp = np.linalg.solve(A.cpu(), b.cpu())\n", "probing input new": " def test_lu_solve_batched_broadcasting(self, device, dtype):\n make_fullrank = make_fullrank_matrices_with_distinct_singular_values\n make_A = partial(make_fullrank, device=device, dtype=dtype)\n\n def run_test(A_dims, b_dims, pivot=True):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = make_A(*A_batch_dims, A_matrix_size, A_matrix_size)\n b = make_tensor(b_dims, dtype=dtype, device=device)\n x_exp = np.linalg.solve(A.cpu(), b.cpu())\n LU_data, LU_pivots = torch.", "reference": "LU_data,LU_pivots=torch.linalg.lu_factor(A)", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "LU_data,LU_pivots=torch.linalg.lu_factor(A)", "y_neg": " LU_data, LU_pivots = torch.lu(A.to(device), pivot=pivot)", "retain": " def test_lu_solve_batched_broadcasting(self, device, dtype):\n make_fullrank = make_fullrank_matrices_with_distinct_singular_values\n make_A = partial(make_fullrank, device=device, dtype=dtype)\n\n def run_test(A_dims, b_dims, pivot=True):\n A_matrix_size = A_dims[-1]\n A_batch_dims = A_dims[:-2]\n A = make_A(*A_batch_dims, A_matrix_size, A_matrix_size)\n b = make_tensor(b_dims, dtype=dtype, device=device)\n x_exp = np.linalg.solve(A.cpu(), b.cpu())\n LU_data, LU_pivots = torch.linalg.lu_factor(A)\n x = torch.lu_solve(b, LU_data, LU_pivots)\n self.assertEqual(x, x_exp)\n\n # test against numpy.linalg.solve\n run_test((2, 1, 3, 4, 4), (2, 1, 3, 4, 6)) # no broadcasting\n run_test((2, 1, 3, 4, 4), (4, 6)) # broadcasting b\n run_test((4, 4), (2, 1, 3, 4, 2)) # broadcasting A\n run_test((1, 3, 1, 4, 4), (2, 1, 3, 4, 5))" }, { "id": 9447, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, X, Y):\n \"\"\"\n Args:\n X: (..., N, N)\n Y: (..., N, K)\n \"\"\"\n LU, piv = torch.linalg.lu_factor(X.transpose(-1, -2) + torch.eye(X.shape[-2], device=X.device) * self.l)\n self.M = nn.Parameter(torch.lu_solve(Y, LU, piv).transpose(-1, -2))", "probing input": " def fit(self, X, Y):\n \"\"\"\n Args:\n X: (..., N, N)\n Y: (..., N, K)\n \"\"\"\n", "probing input new": " def fit(self, X, Y):\n \"\"\"\n Args:\n X: (..., N, N)\n Y: (..., N, K)\n \"\"\"\n LU, piv = torch.", "reference": "LU,piv=torch.linalg.lu_factor(X.transpose(-1,-2)+torch.eye(X.shape[-2],device=X.device)*self.l)", "reference dict": { "self.M": "nn.Parameter" }, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq", "nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "nn.functional.interpolate": "torch.nn.functional.interpolate", "nn.utils.weight_norm": "torch.nn.utils.weight_norm", "nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "nn.functional.upsample": "torch.nn.functional.upsample" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "LU,piv=torch.linalg.lu_factor(X.transpose(-1,-2)+torch.eye(X.shape[-2],device=X.device)*self.l)", "y_neg": " LU, piv = torch.lu(X)", "retain": " def fit(self, X, Y):\n \"\"\"\n Args:\n X: (..., N, N)\n Y: (..., N, K)\n \"\"\"\n LU, piv = torch.linalg.lu_factor(X.transpose(-1, -2) + torch.eye(X.shape[-2], device=X.device) * self.l)\n self.M = nn.Parameter(torch.lu_solve(Y, LU, piv).transpose(-1, -2))" }, { "id": 9448, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": " def calculate_uncertainty_from_J(self, jacobian_matrix: torch.tensor):\n \"\"\"\n Use Jacobian matrix to appraxmate Hessian matrix, then use the \n diagnose of the inverse of Hessian matrix to calculate parameter \n fitting uncertainty.\n\n Parameters\n ----------\n jacobian_matrix\n The corresponding jacobian matrix.\n\n Returns\n -------\n uncertainty\n The uncertainty calculated from Jacobian matrix.\n \"\"\" \n new_J, filtered_eyed_W = self.reconstruct(jacobian_matrix)\n jTj = torch.bmm(torch.bmm(new_J, filtered_eyed_W), \n new_J.transpose(1, 2)) \n LU, pivots = torch.linalg.lu_factor(jTj.detach())\n \n jTj_inv = torch.linalg.lu_solve(\n LU, pivots, \n torch.eye(len(self.dataset.Profiles.variableParam))\n .to(self.dataset.device)\n .repeat(len(self.index), 1, 1)) \n \n uncertainty = torch.pow(torch.diagonal(jTj_inv, dim1=-2, dim2=-1), 0.5)\n\n return uncertainty", "probing input": " def calculate_uncertainty_from_J(self, jacobian_matrix: torch.tensor):\n \"\"\"\n Use Jacobian matrix to appraxmate Hessian matrix, then use the \n diagnose of the inverse of Hessian matrix to calculate parameter \n fitting uncertainty.\n\n Parameters\n ----------\n jacobian_matrix\n The corresponding jacobian matrix.\n\n Returns\n -------\n uncertainty\n The uncertainty calculated from Jacobian matrix.\n \"\"\" \n new_J, filtered_eyed_W = self.reconstruct(jacobian_matrix)\n jTj = torch.bmm(torch.bmm(new_J, filtered_eyed_W), \n new_J.transpose(1, 2)) \n", "probing input new": " def calculate_uncertainty_from_J(self, jacobian_matrix: torch.tensor):\n \"\"\"\n Use Jacobian matrix to appraxmate Hessian matrix, then use the \n diagnose of the inverse of Hessian matrix to calculate parameter \n fitting uncertainty.\n\n Parameters\n ----------\n jacobian_matrix\n The corresponding jacobian matrix.\n\n Returns\n -------\n uncertainty\n The uncertainty calculated from Jacobian matrix.\n \"\"\" \n new_J, filtered_eyed_W = self.reconstruct(jacobian_matrix)\n jTj = torch.bmm(torch.bmm(new_J, filtered_eyed_W), \n new_J.transpose(1, 2)) \n LU, pivots = torch.", "reference": "LU,pivots=torch.linalg.lu_factor(jTj.detach())", "reference dict": {}, "alias dict": { "torch.potri": "torch.potri", "torch.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "torch.potrs": "torch.potrs", "torch.qr": "torch.qr", "torch.lu_solve": "torch.lu_solve", "torch.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "torch.symeig": "torch.symeig", "torch.func.functional_call": "torch.func.functional_call", "torch.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "torch.solve": "torch.solve", "torch.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "torch.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "torch.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "torch.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "torch.lu_unpack": "torch.lu_unpack", "torch.btrisolve": "torch.btrisolve", "torch.linalg.lu_factor": "torch.linalg.lu_factor", "torch.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "torch.linalg.matrix_rank": "torch.linalg.matrix_rank", "torch.norm": "torch.norm", "torch.cholesky_solve": "torch.cholesky_solve", "torch.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "torch.testing.assert_allclose": "torch.testing.assert_allclose", "torch.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "torch.gels": "torch.gels", "torch.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "torch.chain_matmul": "torch.chain_matmul", "torch.lu": "torch.lu", "torch.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "torch.pstrf": "torch.pstrf", "torch.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "torch.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "torch.linalg.eigh": "torch.linalg.eigh", "torch.btrifact": "torch.btrifact", "torch.linalg.lu_solve": "torch.linalg.lu_solve", "torch.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "torch.linalg.multi_dot": "torch.linalg.multi_dot", "torch.gesv": "torch.gesv", "torch.btrifact_with_info": "torch.btrifact_with_info", "torch.linalg.solve": "torch.linalg.solve", "torch.linalg.eig": "torch.linalg.eig", "torch.linalg.cholesky": "torch.linalg.cholesky", "torch.trtrs": "torch.trtrs", "torch.linalg.solve_triangular": "torch.linalg.solve_triangular", "torch.matrix_rank": "torch.matrix_rank", "torch.triangular_solve": "torch.triangular_solve", "torch.linalg.qr": "torch.linalg.qr", "torch.svd": "torch.svd", "torch.lstsq": "torch.lstsq", "torch.nn.functional.interpolate": "torch.nn.functional.interpolate", "torch.potrf": "torch.potrf", "torch.linalg.svd": "torch.linalg.svd", "torch.btriunpack": "torch.btriunpack", "torch.eig": "torch.eig", "torch.cholesky_inverse": "torch.cholesky_inverse", "torch.testing.assert_close": "torch.testing.assert_close", "torch.cholesky": "torch.cholesky", "torch.nn.functional.upsample": "torch.nn.functional.upsample", "torch.linalg.norm": "torch.linalg.norm", "torch.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "torch.linalg.lu_factor", "y_pos": "LU,pivots=torch.linalg.lu_factor(jTj.detach())", "y_neg": " LU, pivots = torch.lu(jTj)", "retain": " def calculate_uncertainty_from_J(self, jacobian_matrix: torch.tensor):\n \"\"\"\n Use Jacobian matrix to appraxmate Hessian matrix, then use the \n diagnose of the inverse of Hessian matrix to calculate parameter \n fitting uncertainty.\n\n Parameters\n ----------\n jacobian_matrix\n The corresponding jacobian matrix.\n\n Returns\n -------\n uncertainty\n The uncertainty calculated from Jacobian matrix.\n \"\"\" \n new_J, filtered_eyed_W = self.reconstruct(jacobian_matrix)\n jTj = torch.bmm(torch.bmm(new_J, filtered_eyed_W), \n new_J.transpose(1, 2)) \n LU, pivots = torch.linalg.lu_factor(jTj.detach())\n \n jTj_inv = torch.linalg.lu_solve(\n LU, pivots, \n torch.eye(len(self.dataset.Profiles.variableParam))\n .to(self.dataset.device)\n .repeat(len(self.index), 1, 1)) \n \n uncertainty = torch.pow(torch.diagonal(jTj_inv, dim1=-2, dim2=-1), 0.5)\n\n return uncertainty" }, { "id": 9450, "library": "pytorch", "category": "up-to-dated", "source": "sourcegraph", "function": "def _LU(M):\n \"\"\"\n Perform an LU decomposition and returns L, U and a permutation vector P. \n\n Args:\n M (torch.tensor): [description]\n\n Returns:\n tuple[torch.tensor,torch.tensor,torch.tensor]: L, U, P\n \"\"\"\n LU,P = tn.linalg.lu_factor(M)\n P,L,U = tn.lu_unpack(LU,P) # P transpose or not transpose?\n P = P@tn.reshape(tn.arange(P.shape[1],dtype=P.dtype,device=P.device),[-1,1])\n # P = tn.reshape(tn.arange(P.shape[1],dtype=P.dtype,device=P.device),[1,-1]) @ P\n \n return L, U, tn.squeeze(P).to(tn.int64)", "probing input": "def _LU(M):\n \"\"\"\n Perform an LU decomposition and returns L, U and a permutation vector P. \n\n Args:\n M (torch.tensor): [description]\n\n Returns:\n tuple[torch.tensor,torch.tensor,torch.tensor]: L, U, P\n \"\"\"\n", "probing input new": "def _LU(M):\n \"\"\"\n Perform an LU decomposition and returns L, U and a permutation vector P. \n\n Args:\n M (torch.tensor): [description]\n\n Returns:\n tuple[torch.tensor,torch.tensor,torch.tensor]: L, U, P\n \"\"\"\n LU,P = tn.", "reference": "LU,P=tn.linalg.lu_factor(M)", "reference dict": {}, "alias dict": { "tn.potri": "torch.potri", "tn.nn.functional.upsample_nearest": "torch.nn.functional.upsample_nearest", "tn.potrs": "torch.potrs", "tn.qr": "torch.qr", "tn.lu_solve": "torch.lu_solve", "tn.ao.nn.quantized.functional.upsample_bilinear": "torch.ao.nn.quantized.functional.upsample_bilinear", "tn.symeig": "torch.symeig", "tn.func.functional_call": "torch.func.functional_call", "tn.nn.quantized.functional.upsample": "torch.nn.quantized.functional.upsample", "tn.solve": "torch.solve", "tn.nn.modules.module.register_module_backward_hook": "torch.nn.modules.module.register_module_backward_hook", "tn.nn.utils.stateless.functional_call": "torch.nn.utils.stateless.functional_call", "tn.nn.quantized.functional.interpolate": "torch.nn.quantized.functional.interpolate", "tn.ao.nn.quantized.functional.upsample": "torch.ao.nn.quantized.functional.upsample", "tn.lu_unpack": "torch.lu_unpack", "tn.btrisolve": "torch.btrisolve", "tn.linalg.lu_factor": "torch.linalg.lu_factor", "tn.ao.nn.quantized.functional.interpolate": "torch.ao.nn.quantized.functional.interpolate", "tn.linalg.matrix_rank": "torch.linalg.matrix_rank", "tn.norm": "torch.norm", "tn.cholesky_solve": "torch.cholesky_solve", "tn.nn.utils.weight_norm": "torch.nn.utils.weight_norm", "tn.testing.assert_allclose": "torch.testing.assert_allclose", "tn.nn.functional.upsample_bilinear": "torch.nn.functional.upsample_bilinear", "tn.gels": "torch.gels", "tn.nn.quantized.functional.upsample_bilinear": "torch.nn.quantized.functional.upsample_bilinear", "tn.chain_matmul": "torch.chain_matmul", "tn.lu": "torch.lu", "tn.nn.modules.module.register_module_full_backward_hook": "torch.nn.modules.module.register_module_full_backward_hook", "tn.pstrf": "torch.pstrf", "tn.nn.quantized.functional.upsample_nearest": "torch.nn.quantized.functional.upsample_nearest", "tn.ao.nn.quantized.functional.upsample_nearest": "torch.ao.nn.quantized.functional.upsample_nearest", "tn.linalg.eigh": "torch.linalg.eigh", "tn.btrifact": "torch.btrifact", "tn.linalg.lu_solve": "torch.linalg.lu_solve", "tn.nn.utils.parametrizations.weight_norm": "torch.nn.utils.parametrizations.weight_norm", "tn.linalg.multi_dot": "torch.linalg.multi_dot", "tn.gesv": "torch.gesv", "tn.btrifact_with_info": "torch.btrifact_with_info", "tn.linalg.solve": "torch.linalg.solve", "tn.linalg.eig": "torch.linalg.eig", "tn.linalg.cholesky": "torch.linalg.cholesky", "tn.trtrs": "torch.trtrs", "tn.linalg.solve_triangular": "torch.linalg.solve_triangular", "tn.matrix_rank": "torch.matrix_rank", "tn.triangular_solve": "torch.triangular_solve", "tn.linalg.qr": "torch.linalg.qr", "tn.svd": "torch.svd", "tn.lstsq": "torch.lstsq", "tn.nn.functional.interpolate": "torch.nn.functional.interpolate", "tn.potrf": "torch.potrf", "tn.linalg.svd": "torch.linalg.svd", "tn.btriunpack": "torch.btriunpack", "tn.eig": "torch.eig", "tn.cholesky_inverse": "torch.cholesky_inverse", "tn.testing.assert_close": "torch.testing.assert_close", "tn.cholesky": "torch.cholesky", "tn.nn.functional.upsample": "torch.nn.functional.upsample", "tn.linalg.norm": "torch.linalg.norm", "tn.linalg.lstsq": "torch.linalg.lstsq" }, "deprecated api": [ "torch.lu" ], "replacement api": "torch.linalg.lu_factor", "expected call": "tn.linalg.lu_factor", "y_pos": "LU,P=tn.linalg.lu_factor(M)", "y_neg": " LU,P = tn.lu(M)", "retain": "def _LU(M):\n \"\"\"\n Perform an LU decomposition and returns L, U and a permutation vector P. \n\n Args:\n M (torch.tensor): [description]\n\n Returns:\n tuple[torch.tensor,torch.tensor,torch.tensor]: L, U, P\n \"\"\"\n LU,P = tn.linalg.lu_factor(M)\n P,L,U = tn.lu_unpack(LU,P) # P transpose or not transpose?\n P = P@tn.reshape(tn.arange(P.shape[1],dtype=P.dtype,device=P.device),[-1,1])\n # P = tn.reshape(tn.arange(P.shape[1],dtype=P.dtype,device=P.device),[1,-1]) @ P\n \n return L, U, tn.squeeze(P).to(tn.int64)" }, { "id": 9685, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_activation_confidence(track_path, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a track. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n track_path : Path\n Path object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n \"\"\"\n H = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.windows.hann(win_len + 2)[1:-1]\n\n audio, rate = librosa.load(track_path, sr=44100, mono=True)\n H.append(track_energy(audio.T, win_len, win))\n\n # list to numpy array\n H = np.array(H)\n\n # normalization (to overall energy and # of sources)\n E0 = np.sum(H, axis=0)\n \n H /= np.max(E0)\n # binary thresholding for low overall energy events\n H[:, E0 < amplitude_threshold] = 0.0\n\n # LP filter\n b, a = scipy.signal.butter(2, lpf_cutoff, 'low')\n H = scipy.signal.filtfilt(b, a, H, axis=1)\n\n # logistic function to semi-binarize the output; confidence value\n C = 1.0 - (1.0 / (1.0 + np.exp(np.dot(var_lambda, (H - theta)))))\n\n # add time column\n time = librosa.core.frames_to_time(\n np.arange(C.shape[1]), sr=rate, hop_length=win_len // 2\n )\n\n # stack time column to matrix\n C_out = np.vstack((time, C))\n return C_out.T", "probing input": "def compute_activation_confidence(track_path, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a track. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n track_path : Path\n Path object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n \"\"\"\n H = []\n\n # MATLAB equivalent to @hanning(win_len)\n", "probing input new": "def compute_activation_confidence(track_path, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a track. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n track_path : Path\n Path object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n \"\"\"\n H = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.", "reference": "win=scipy.signal.windows.hann(win_len+2)[1:-1]", "reference dict": { "umx_data_path": "Path" }, "alias dict": { "scipy.signal.hanning": "scipy.signal.hanning", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.signal.windows.hann": "scipy.signal.windows.hann" }, "deprecated api": [ "scipy.signal.hanning" ], "replacement api": "scipy.signal.windows.hann", "expected call": "scipy.signal.windows.hann", "y_pos": "win=scipy.signal.windows.hann(win_len+2)[1:-1]", "y_neg": " win = scipy.signal.hanning(win_len)", "retain": "def compute_activation_confidence(track_path, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a track. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n track_path : Path\n Path object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n \"\"\"\n H = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.windows.hann(win_len + 2)[1:-1]\n\n audio, rate = librosa.load(track_path, sr=44100, mono=True)\n H.append(track_energy(audio.T, win_len, win))\n\n # list to numpy array\n H = np.array(H)\n\n # normalization (to overall energy and # of sources)\n E0 = np.sum(H, axis=0)\n \n H /= np.max(E0)\n # binary thresholding for low overall energy events\n H[:, E0 < amplitude_threshold] = 0.0\n\n # LP filter\n b, a = scipy.signal.butter(2, lpf_cutoff, 'low')\n H = scipy.signal.filtfilt(b, a, H, axis=1)\n\n # logistic function to semi-binarize the output; confidence value\n C = 1.0 - (1.0 / (1.0 + np.exp(np.dot(var_lambda, (H - theta)))))\n\n # add time column\n time = librosa.core.frames_to_time(\n np.arange(C.shape[1]), sr=rate, hop_length=win_len // 2\n )\n\n # stack time column to matrix\n C_out = np.vstack((time, C))\n return C_out.T" }, { "id": 9708, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_activation_confidence(mtrack, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a multitrack. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n mtrack : MultiTrack\n Multitrack object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n stem_index_list : list\n List of stem indices in the order they appear in C\n\n \"\"\"\n H = []\n stem_index_list = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.windows.hann(win_len + 2)[1:-1]\n\n for stem_idx, track in mtrack.stems.items():\n audio, rate = librosa.load(track.audio_path, sr=44100, mono=True)\n H.append(track_energy(audio.T, win_len, win))\n stem_index_list.append(stem_idx)\n\n # list to numpy array\n H = np.array(H)\n\n # normalization (to overall energy and # of sources)\n E0 = np.sum(H, axis=0)\n \n H = len(mtrack.stems) * H / np.max(E0)\n # binary thresholding for low overall energy events\n H[:, E0 < amplitude_threshold] = 0.0\n\n # LP filter\n b, a = scipy.signal.butter(2, lpf_cutoff, 'low')\n H = scipy.signal.filtfilt(b, a, H, axis=1)\n\n # logistic function to semi-binarize the output; confidence value\n C = 1.0 - (1.0 / (1.0 + np.exp(np.dot(var_lambda, (H - theta)))))\n\n # add time column\n time = librosa.core.frames_to_time(\n np.arange(C.shape[1]), sr=rate, hop_length=win_len // 2\n )\n\n # stack time column to matrix\n C_out = np.vstack((time, C))\n return C_out.T, stem_index_list", "probing input": "def compute_activation_confidence(mtrack, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a multitrack. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n mtrack : MultiTrack\n Multitrack object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n stem_index_list : list\n List of stem indices in the order they appear in C\n\n \"\"\"\n H = []\n stem_index_list = []\n\n # MATLAB equivalent to @hanning(win_len)\n", "probing input new": "def compute_activation_confidence(mtrack, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a multitrack. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n mtrack : MultiTrack\n Multitrack object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n stem_index_list : list\n List of stem indices in the order they appear in C\n\n \"\"\"\n H = []\n stem_index_list = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.", "reference": "win=scipy.signal.windows.hann(win_len+2)[1:-1]", "reference dict": {}, "alias dict": { "scipy.signal.hanning": "scipy.signal.hanning", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.signal.windows.hann": "scipy.signal.windows.hann" }, "deprecated api": [ "scipy.signal.hanning" ], "replacement api": "scipy.signal.windows.hann", "expected call": "scipy.signal.windows.hann", "y_pos": "win=scipy.signal.windows.hann(win_len+2)[1:-1]", "y_neg": " win = scipy.signal.hanning(win_len)", "retain": "def compute_activation_confidence(mtrack, win_len=4096, lpf_cutoff=0.075,\n theta=0.15, var_lambda=20.0,\n amplitude_threshold=0.01):\n \"\"\"Create the activation confidence annotation for a multitrack. The final\n activation matrix is computed as:\n `C[i, t] = 1 - (1 / (1 + e**(var_lambda * (H[i, t] - theta))))`\n where H[i, t] is the energy of stem `i` at time `t`\n\n Parameters\n ----------\n mtrack : MultiTrack\n Multitrack object\n win_len : int, default=4096\n Number of samples in each window\n lpf_cutoff : float, default=0.075\n Lowpass frequency cutoff fraction\n theta : float\n Controls the threshold of activation.\n var_labmda : float\n Controls the slope of the threshold function.\n amplitude_threshold : float\n Energies below this value are set to 0.0\n\n Returns\n -------\n C : np.array\n Array of activation confidence values shape (n_conf, n_stems)\n stem_index_list : list\n List of stem indices in the order they appear in C\n\n \"\"\"\n H = []\n stem_index_list = []\n\n # MATLAB equivalent to @hanning(win_len)\n win = scipy.signal.windows.hann(win_len + 2)[1:-1]\n\n for stem_idx, track in mtrack.stems.items():\n audio, rate = librosa.load(track.audio_path, sr=44100, mono=True)\n H.append(track_energy(audio.T, win_len, win))\n stem_index_list.append(stem_idx)\n\n # list to numpy array\n H = np.array(H)\n\n # normalization (to overall energy and # of sources)\n E0 = np.sum(H, axis=0)\n \n H = len(mtrack.stems) * H / np.max(E0)\n # binary thresholding for low overall energy events\n H[:, E0 < amplitude_threshold] = 0.0\n\n # LP filter\n b, a = scipy.signal.butter(2, lpf_cutoff, 'low')\n H = scipy.signal.filtfilt(b, a, H, axis=1)\n\n # logistic function to semi-binarize the output; confidence value\n C = 1.0 - (1.0 / (1.0 + np.exp(np.dot(var_lambda, (H - theta)))))\n\n # add time column\n time = librosa.core.frames_to_time(\n np.arange(C.shape[1]), sr=rate, hop_length=win_len // 2\n )\n\n # stack time column to matrix\n C_out = np.vstack((time, C))\n return C_out.T, stem_index_list" }, { "id": 10410, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute(self, dataset: xr.Dataset) -> xr.DataArray:\n u = dataset[self.u_name]\n v = dataset[self.v_name]\n divergence = _divergence(u, v)\n pascals_per_hpa = 100\n pressure = pascals_per_hpa * dataset.coords['level']\n axis = divergence.dims.index('level')\n # TODO(shoyer): consider masking out vertical wind in locations below the\n # surface of the Earth (geopotential < geopotential_at_surface).\n vertical_wind = scipy.integrate.cumulative_trapezoid(\n -divergence.values, x=pressure, axis=axis, initial=0\n )\n return divergence.copy(data=vertical_wind)", "probing input": " def compute(self, dataset: xr.Dataset) -> xr.DataArray:\n u = dataset[self.u_name]\n v = dataset[self.v_name]\n divergence = _divergence(u, v)\n pascals_per_hpa = 100\n pressure = pascals_per_hpa * dataset.coords['level']\n axis = divergence.dims.index('level')\n # TODO(shoyer): consider masking out vertical wind in locations below the\n # surface of the Earth (geopotential < geopotential_at_surface).\n", "probing input new": " def compute(self, dataset: xr.Dataset) -> xr.DataArray:\n u = dataset[self.u_name]\n v = dataset[self.v_name]\n divergence = _divergence(u, v)\n pascals_per_hpa = 100\n pressure = pascals_per_hpa * dataset.coords['level']\n axis = divergence.dims.index('level')\n # TODO(shoyer): consider masking out vertical wind in locations below the\n # surface of the Earth (geopotential < geopotential_at_surface).\n vertical_wind = scipy.integrate.", "reference": "vertical_wind=scipy.integrate.cumulative_trapezoid(-divergence.values,x=pressure,axis=axis,initial=0)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "vertical_wind=scipy.integrate.cumulative_trapezoid(-divergence.values,x=pressure,axis=axis,initial=0)", "y_neg": " vertical_wind = scipy.integrate.cumtrapz(u, x=pressure, axis=axis)", "retain": " def compute(self, dataset: xr.Dataset) -> xr.DataArray:\n u = dataset[self.u_name]\n v = dataset[self.v_name]\n divergence = _divergence(u, v)\n pascals_per_hpa = 100\n pressure = pascals_per_hpa * dataset.coords['level']\n axis = divergence.dims.index('level')\n # TODO(shoyer): consider masking out vertical wind in locations below the\n # surface of the Earth (geopotential < geopotential_at_surface).\n vertical_wind = scipy.integrate.cumulative_trapezoid(\n -divergence.values, x=pressure, axis=axis, initial=0\n )\n return divergence.copy(data=vertical_wind)" }, { "id": 10413, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def dalpha_dr(self):\n r\"\"\"\n Equation 39\n inherits correct :math:`\\sigma_\\alpha` from `d2alpha_drdtheta`\n integrate over theta\n\n Returns\n -------\n dalpha_dr : Array\n Derivative of alpha w.r.t :math:`r`\n \"\"\"\n initial_units = self.d2alpha_drdtheta.units\n\n # cumulative_trapezoid strips units, integration adds no unit\n dalpha_dr = integrate.cumulative_trapezoid(\n self.d2alpha_drdtheta.m, self.regulartheta, initial=0.0\n )\n\n f = interp1d(self.regulartheta, dalpha_dr)\n\n # set dalpha/dr(r,theta=0.0)=0.0, assumed by codes, add unit back\n return (dalpha_dr - f(0.0)) * initial_units", "probing input": " def dalpha_dr(self):\n r\"\"\"\n Equation 39\n inherits correct :math:`\\sigma_\\alpha` from `d2alpha_drdtheta`\n integrate over theta\n\n Returns\n -------\n dalpha_dr : Array\n Derivative of alpha w.r.t :math:`r`\n \"\"\"\n initial_units = self.d2alpha_drdtheta.units\n\n # cumulative_trapezoid strips units, integration adds no unit\n", "probing input new": " def dalpha_dr(self):\n r\"\"\"\n Equation 39\n inherits correct :math:`\\sigma_\\alpha` from `d2alpha_drdtheta`\n integrate over theta\n\n Returns\n -------\n dalpha_dr : Array\n Derivative of alpha w.r.t :math:`r`\n \"\"\"\n initial_units = self.d2alpha_drdtheta.units\n\n # cumulative_trapezoid strips units, integration adds no unit\n dalpha_dr = integrate.", "reference": "dalpha_dr=integrate.cumulative_trapezoid(self.d2alpha_drdtheta.m,self.regulartheta,initial=0.0)", "reference dict": {}, "alias dict": { "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "integrate.cumulative_trapezoid", "y_pos": "dalpha_dr=integrate.cumulative_trapezoid(self.d2alpha_drdtheta.m,self.regulartheta,initial=0.0)", "y_neg": " dalpha_dr = integrate.cumtrapz(self.d2alpha_drdtheta, dx=1, initial=0)", "retain": " def dalpha_dr(self):\n r\"\"\"\n Equation 39\n inherits correct :math:`\\sigma_\\alpha` from `d2alpha_drdtheta`\n integrate over theta\n\n Returns\n -------\n dalpha_dr : Array\n Derivative of alpha w.r.t :math:`r`\n \"\"\"\n initial_units = self.d2alpha_drdtheta.units\n\n # cumulative_trapezoid strips units, integration adds no unit\n dalpha_dr = integrate.cumulative_trapezoid(\n self.d2alpha_drdtheta.m, self.regulartheta, initial=0.0\n )\n\n f = interp1d(self.regulartheta, dalpha_dr)\n\n # set dalpha/dr(r,theta=0.0)=0.0, assumed by codes, add unit back\n return (dalpha_dr - f(0.0)) * initial_units" }, { "id": 10415, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def dynamic_pressure(T, S):\n for i in range(10):\n S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n for i in range(10, len(T)):\n S[i] = 34\n T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.cumulative_trapezoid(density_rhs, z_rhs, initial=0)\n # print(\"pcumulative\", pcumulative)\n # print(\"len pcumulative\", len(pcumulative))\n\n return pcumulative", "probing input": "def dynamic_pressure(T, S):\n for i in range(10):\n S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n for i in range(10, len(T)):\n S[i] = 34\n T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n", "probing input new": "def dynamic_pressure(T, S):\n for i in range(10):\n S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n for i in range(10, len(T)):\n S[i] = 34\n T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.", "reference": "pcumulative=scipy.integrate.cumulative_trapezoid(density_rhs,z_rhs,initial=0)", "reference dict": { "parser": "argparse.ArgumentParser", "ip_factor": "Constant", "mesh": "Mesh", "y, z": "SpatialCoordinate", "V": "VectorFunctionSpace", "W": "FunctionSpace", "M": "MixedFunctionSpace", "U": "FunctionSpace", "Q": "FunctionSpace", "K": "FunctionSpace", "S": "FunctionSpace", "m": "Function", "u": "Function", "rho": "Function", "temp": "Function", "sal": "Function", "melt": "Function", "Q_mixed": "Function", "Q_ice": "Function", "Q_latent": "Function", "Q_s": "Function", "Tb": "Function", "Sb": "Function", "full_pressure": "Function", "frazil": "Function", "frazil_flux": "Function", "mom_eq": "MomentumEquation", "cty_eq": "ContinuityEquation", "u_eq": "ScalarVelocity2halfDEquation", "temp_eq": "ScalarAdvectionDiffusionEquation", "sal_eq": "ScalarAdvectionDiffusionEquation", "frazil_eq": "FrazilAdvectionDiffusionEquation", "T_ref": "Constant", "S_ref": "Constant", "beta_temp": "Constant", "beta_sal": "Constant", "g": "Constant", "f": "Constant", "absorption_factor": "Constant", "FRV": "FrazilRisingVelocity", "frazil_mp": "FrazilMeltParam", "ip_alpha": "Constant", "mp": "ThreeEqMeltRateParam", "top_boundary_mp": "pd.DataFrame", "n": "FacetNormal", "rhs_nodes": "VertexOnlyMesh", "DG0_vom": "FunctionSpace", "temp_vom": "Function", "sal_vom": "Function", "W_vector": "VectorFunctionSpace", "stress_open_boundary_dynamic": "Function", "S_restorefield": "Function", "T_restorefield": "Function", "velocity_depth_profile500m": "pd.DataFrame", "velocity_depth_profile1km": "pd.DataFrame", "velocity_depth_profile2km": "pd.DataFrame", "velocity_depth_profile4km": "pd.DataFrame", "velocity_depth_profile6km": "pd.DataFrame", "vp_timestepper": "PressureProjectionTimeIntegrator", "u_timestepper": "DIRK33", "temp_timestepper": "DIRK33", "sal_timestepper": "DIRK33", "frazil_timestepper": "DIRK33", "v_file": "File", "p_file": "File", "u_file": "File", "t_file": "File", "s_file": "File", "rho_file": "File", "frazil_file": "File", "Q_ice_file": "File", "Q_mixed_file": "File", "Qs_file": "File", "m_file": "File", "full_pressure_file": "File", "frazil_flux_file": "File", "sop_file": "File", "limiter": "VertexBasedP1DGLimiter" }, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "pcumulative=scipy.integrate.cumulative_trapezoid(density_rhs,z_rhs,initial=0)", "y_neg": " pcumulative = scipy.integrate.cumtrapz(z_rhs, density_rhs, initial=0)", "retain": "def dynamic_pressure(T, S):\n for i in range(10):\n S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n for i in range(10, len(T)):\n S[i] = 34\n T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.cumulative_trapezoid(density_rhs, z_rhs, initial=0)\n # print(\"pcumulative\", pcumulative)\n # print(\"len pcumulative\", len(pcumulative))\n\n return pcumulative" }, { "id": 10416, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def integrate_cumtrapz(data, dx, **kwargs):\n \"\"\"\n Performs first order integration of data using the trapezoidal rule.\n\n :param data: Data array to integrate.\n :param dx: Sample spacing usually in seconds.\n \"\"\"\n # Integrate. Set first value to zero to avoid changing the total\n # length of the array.\n return scipy.integrate.cumulative_trapezoid(data, dx=dx, initial=0)", "probing input": "def integrate_cumtrapz(data, dx, **kwargs):\n \"\"\"\n Performs first order integration of data using the trapezoidal rule.\n\n :param data: Data array to integrate.\n :param dx: Sample spacing usually in seconds.\n \"\"\"\n # Integrate. Set first value to zero to avoid changing the total\n # length of the array.\n", "probing input new": "def integrate_cumtrapz(data, dx, **kwargs):\n \"\"\"\n Performs first order integration of data using the trapezoidal rule.\n\n :param data: Data array to integrate.\n :param dx: Sample spacing usually in seconds.\n \"\"\"\n # Integrate. Set first value to zero to avoid changing the total\n # length of the array.\n return scipy.integrate.", "reference": "returnscipy.integrate.cumulative_trapezoid(data,dx=dx,initial=0)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "returnscipy.integrate.cumulative_trapezoid(data,dx=dx,initial=0)", "y_neg": " return scipy.integrate.cumtrapz(data, dx, **kwargs)", "retain": "def integrate_cumtrapz(data, dx, **kwargs):\n \"\"\"\n Performs first order integration of data using the trapezoidal rule.\n\n :param data: Data array to integrate.\n :param dx: Sample spacing usually in seconds.\n \"\"\"\n # Integrate. Set first value to zero to avoid changing the total\n # length of the array.\n return scipy.integrate.cumulative_trapezoid(data, dx=dx, initial=0)" }, { "id": 10422, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def cumulative_mass(self, r: np.ndarray) -> np.ndarray:\n \"\"\" Compute the enclosed mass at each radius \"\"\"\n # check if the array r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n cmass = integrate.cumulative_trapezoid(\n 4 * np.pi * r**2 * self.density(r), dx=dr)\n else:\n cmass = integrate.cumulative_trapezoid(\n 4 * np.pi * r**2 * self.density(r), r)\n cmass = np.append(cmass, cmass[-1])\n return cmass", "probing input": " def cumulative_mass(self, r: np.ndarray) -> np.ndarray:\n \"\"\" Compute the enclosed mass at each radius \"\"\"\n # check if the array r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n", "probing input new": " def cumulative_mass(self, r: np.ndarray) -> np.ndarray:\n \"\"\" Compute the enclosed mass at each radius \"\"\"\n # check if the array r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n cmass = integrate.", "reference": "cmass=integrate.cumulative_trapezoid(4*np.pi*r**2*self.density(r),dx=dr)", "reference dict": {}, "alias dict": { "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "integrate.cumulative_trapezoid", "y_pos": "cmass=integrate.cumulative_trapezoid(4*np.pi*r**2*self.density(r),dx=dr)", "y_neg": " cmass = integrate.cumtrapz(r**2 * np.pi * dr, r, axis=0)", "retain": " def cumulative_mass(self, r: np.ndarray) -> np.ndarray:\n \"\"\" Compute the enclosed mass at each radius \"\"\"\n # check if the array r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n cmass = integrate.cumulative_trapezoid(\n 4 * np.pi * r**2 * self.density(r), dx=dr)\n else:\n cmass = integrate.cumulative_trapezoid(\n 4 * np.pi * r**2 * self.density(r), r)\n cmass = np.append(cmass, cmass[-1])\n return cmass" }, { "id": 10423, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "alpha_desired[800::,0] = np.linspace(np.pi/8, -np.pi, 200)\n\n\nfreq = np.median(freq)\n\nvx_desired = (a0 * freq * np.cos(alpha_desired)).reshape(1,-1).flatten()\nvy_desired = (a0 * freq * np.sin(alpha_desired)).reshape(1,-1).flatten()\n\npx_desired = integrate.cumulative_trapezoid(vx_desired, dx=dt, initial=0)", "probing input": "alpha_desired[800::,0] = np.linspace(np.pi/8, -np.pi, 200)\n\n\nfreq = np.median(freq)\n\nvx_desired = (a0 * freq * np.cos(alpha_desired)).reshape(1,-1).flatten()\nvy_desired = (a0 * freq * np.sin(alpha_desired)).reshape(1,-1).flatten()\n\n", "probing input new": "alpha_desired[800::,0] = np.linspace(np.pi/8, -np.pi, 200)\n\n\nfreq = np.median(freq)\n\nvx_desired = (a0 * freq * np.cos(alpha_desired)).reshape(1,-1).flatten()\nvy_desired = (a0 * freq * np.sin(alpha_desired)).reshape(1,-1).flatten()\n\npx_desired = integrate.", "reference": "px_desired=integrate.cumulative_trapezoid(vx_desired,dx=dt,initial=0)", "reference dict": {}, "alias dict": { "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "integrate.cumulative_trapezoid", "y_pos": "px_desired=integrate.cumulative_trapezoid(vx_desired,dx=dt,initial=0)", "y_neg": "px_desired = integrate.cumtrapz(vx_desired, alpha_desired, axis=0)", "retain": "alpha_desired[800::,0] = np.linspace(np.pi/8, -np.pi, 200)\n\n\nfreq = np.median(freq)\n\nvx_desired = (a0 * freq * np.cos(alpha_desired)).reshape(1,-1).flatten()\nvy_desired = (a0 * freq * np.sin(alpha_desired)).reshape(1,-1).flatten()\n\npx_desired = integrate.cumulative_trapezoid(vx_desired, dx=dt, initial=0)" }, { "id": 10424, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def dynamic_pressure(T, S):\n\n# because flow is out the domain with positive slope dont do any modification of sal/temp.\n\n # for i in range(10):\n# S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n# for i in range(10, len(T)): \n# S[i] = 34\n# T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.cumulative_trapezoid(density_rhs, z_rhs, initial=0)\n # print(\"pcumulative\", pcumulative)\n # print(\"len pcumulative\", len(pcumulative))\n\n return pcumulative", "probing input": "def dynamic_pressure(T, S):\n\n# because flow is out the domain with positive slope dont do any modification of sal/temp.\n\n # for i in range(10):\n# S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n# for i in range(10, len(T)): \n# S[i] = 34\n# T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n", "probing input new": "def dynamic_pressure(T, S):\n\n# because flow is out the domain with positive slope dont do any modification of sal/temp.\n\n # for i in range(10):\n# S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n# for i in range(10, len(T)): \n# S[i] = 34\n# T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.", "reference": "pcumulative=scipy.integrate.cumulative_trapezoid(density_rhs,z_rhs,initial=0)", "reference dict": { "parser": "argparse.ArgumentParser", "ip_factor": "Constant", "mesh": "Mesh", "y, z": "SpatialCoordinate", "V": "VectorFunctionSpace", "W": "FunctionSpace", "M": "MixedFunctionSpace", "U": "FunctionSpace", "Q": "FunctionSpace", "K": "FunctionSpace", "S": "FunctionSpace", "P1": "FunctionSpace", "m": "Function", "rho": "Function", "temp": "Function", "sal": "Function", "melt": "Function", "Q_mixed": "Function", "Q_ice": "Function", "Q_latent": "Function", "Q_s": "Function", "Tb": "Function", "Sb": "Function", "full_pressure": "Function", "p_b": "Function", "c": "Control", "mom_eq": "MomentumEquation", "cty_eq": "ContinuityEquation", "temp_eq": "ScalarAdvectionDiffusionEquation", "sal_eq": "ScalarAdvectionDiffusionEquation", "balance_pressure_eq": "BalancePressureEquation", "T_ref": "Constant", "S_ref": "Constant", "beta_temp": "Constant", "beta_sal": "Constant", "g": "Constant", "absorption_factor": "Constant", "kappa_h": "Constant", "kappa_v": "Constant", "TP1": "TensorFunctionSpace", "ip_alpha": "Constant", "mp": "ThreeEqMeltRateParam", "top_boundary_mp": "pd.DataFrame", "n": "FacetNormal", "rhs_nodes": "VertexOnlyMesh", "DG0_vom": "FunctionSpace", "temp_vom": "Function", "sal_vom": "Function", "W_vector": "VectorFunctionSpace", "stress_open_boundary_dynamic": "Function", "velocity_depth_profile500m": "pd.DataFrame", "velocity_depth_profile1km": "pd.DataFrame", "velocity_depth_profile2km": "pd.DataFrame", "velocity_depth_profile4km": "pd.DataFrame", "velocity_depth_profile6km": "pd.DataFrame", "z_profile_nodes": "VertexOnlyMesh", "DG0_vom_profile": "FunctionSpace", "temp_vom_profile": "Function", "sal_vom_profile": "Function", "adjoint_profile7550m": "pd.DataFrame", "melt_node": "VertexOnlyMesh", "DG0_vom_meltnode": "FunctionSpace", "melt_vom_node": "Function", "adjoint_melt7550m": "pd.DataFrame", "temp_vom_profile_target": "Function", "sal_vom_profile_target": "Function", "vp_timestepper": "CrankNicolsonSaddlePointTimeIntegrator", "temp_timestepper": "DIRK33", "sal_timestepper": "DIRK33", "p_b_solver": "BalancePressureSolver", "v_file": "File", "p_file": "File", "t_file": "File", "s_file": "File", "rho_file": "File", "Q_ice_file": "File", "Q_mixed_file": "File", "Qs_file": "File", "m_file": "File", "full_pressure_file": "File", "p_b_file": "File", "adj_s_file": "File", "adj_t_file": "File", "adj_visc_file": "File", "adj_diff_t_file": "File", "adj_diff_s_file": "File", "converter": "RieszL2BoundaryRepresentation", "adj_diff_t_file_conv": "File", "adj_diff_s_file_conv": "File", "scale": "Constant", "T_restorefield_vis": "Function", "S_restorefield_vis": "Function", "Trestore_vis_optfile": "File", "Srestore_vis_optfile": "File", "rf": "ReducedFunctional" }, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "pcumulative=scipy.integrate.cumulative_trapezoid(density_rhs,z_rhs,initial=0)", "y_neg": " pcumulative = scipy.integrate.cumtrapz(z_rhs, density_rhs, initial=0)", "retain": "def dynamic_pressure(T, S):\n\n# because flow is out the domain with positive slope dont do any modification of sal/temp.\n\n # for i in range(10):\n# S[i] -= 0.1*(10-i)*2e-4\n# S[:10] -= 0.00016 # try making the top of the domain a bit fresher as a hack to get faster flow at the rhs...\n# for i in range(10, len(T)): \n# S[i] = 34\n# T[i] = -0.5\n \n density_rhs = -g.values()[0] *(-beta_temp.values()[0] * (T-T_ref.values()[0]) + beta_sal.values()[0] * (S - S_ref.values()[0]))\n # print(density_rhs)\n\n\n\n# print(\"len z\", len(z_rhs))\n# print(\"len density\", len(density_rhs))\n pcumulative = scipy.integrate.cumulative_trapezoid(density_rhs, z_rhs, initial=0)\n # print(\"pcumulative\", pcumulative)\n # print(\"len pcumulative\", len(pcumulative))\n\n return pcumulative" }, { "id": 10426, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_cumulative_trapz(self, seed, initial):\n \"\"\"Test that cumulative_trapezoid matches the scipy implementation.\"\"\"\n rng_state = jax.random.PRNGKey(seed)\n del seed # Make sure seed isn't accidentally re-used\n\n rng_use_dim, rng_use_y, rng_use_x, _ = jax.random.split(\n rng_state, 4\n )\n dim = int(jax.random.randint(rng_use_dim, (1,), 1, 100)[0])\n y = jax.random.normal(rng_use_y, (dim,))\n del rng_use_y # Make sure rng_use_y isn't accidentally re-used\n x = jax.random.normal(rng_use_x, (dim,))\n del rng_use_x # Make sure rng_use_x isn't accidentally re-used\n\n cumulative = math_utils.cumulative_trapezoid(x, y, initial=initial)\n\n ref = scipy.integrate.cumulative_trapezoid(y, x, initial=initial)\n\n np.testing.assert_allclose(cumulative, ref)", "probing input": " def test_cumulative_trapz(self, seed, initial):\n \"\"\"Test that cumulative_trapezoid matches the scipy implementation.\"\"\"\n rng_state = jax.random.PRNGKey(seed)\n del seed # Make sure seed isn't accidentally re-used\n\n rng_use_dim, rng_use_y, rng_use_x, _ = jax.random.split(\n rng_state, 4\n )\n dim = int(jax.random.randint(rng_use_dim, (1,), 1, 100)[0])\n y = jax.random.normal(rng_use_y, (dim,))\n del rng_use_y # Make sure rng_use_y isn't accidentally re-used\n x = jax.random.normal(rng_use_x, (dim,))\n del rng_use_x # Make sure rng_use_x isn't accidentally re-used\n\n cumulative = math_utils.cumulative_trapezoid(x, y, initial=initial)\n\n", "probing input new": " def test_cumulative_trapz(self, seed, initial):\n \"\"\"Test that cumulative_trapezoid matches the scipy implementation.\"\"\"\n rng_state = jax.random.PRNGKey(seed)\n del seed # Make sure seed isn't accidentally re-used\n\n rng_use_dim, rng_use_y, rng_use_x, _ = jax.random.split(\n rng_state, 4\n )\n dim = int(jax.random.randint(rng_use_dim, (1,), 1, 100)[0])\n y = jax.random.normal(rng_use_y, (dim,))\n del rng_use_y # Make sure rng_use_y isn't accidentally re-used\n x = jax.random.normal(rng_use_x, (dim,))\n del rng_use_x # Make sure rng_use_x isn't accidentally re-used\n\n cumulative = math_utils.cumulative_trapezoid(x, y, initial=initial)\n\n ref = scipy.integrate.", "reference": "ref=scipy.integrate.cumulative_trapezoid(y,x,initial=initial)", "reference dict": { "rng_state": "jax.random.PRNGKey" }, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "ref=scipy.integrate.cumulative_trapezoid(y,x,initial=initial)", "y_neg": " ref = scipy.integrate.cumtrapz(x, y, initial=initial)", "retain": " def test_cumulative_trapz(self, seed, initial):\n \"\"\"Test that cumulative_trapezoid matches the scipy implementation.\"\"\"\n rng_state = jax.random.PRNGKey(seed)\n del seed # Make sure seed isn't accidentally re-used\n\n rng_use_dim, rng_use_y, rng_use_x, _ = jax.random.split(\n rng_state, 4\n )\n dim = int(jax.random.randint(rng_use_dim, (1,), 1, 100)[0])\n y = jax.random.normal(rng_use_y, (dim,))\n del rng_use_y # Make sure rng_use_y isn't accidentally re-used\n x = jax.random.normal(rng_use_x, (dim,))\n del rng_use_x # Make sure rng_use_x isn't accidentally re-used\n\n cumulative = math_utils.cumulative_trapezoid(x, y, initial=initial)\n\n ref = scipy.integrate.cumulative_trapezoid(y, x, initial=initial)\n\n np.testing.assert_allclose(cumulative, ref)" }, { "id": 10429, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def plot_running_integral(\n self,\n start=0,\n stop=0,\n step=1,\n initial=0,\n xlabel=\"Time (ps)\",\n ylabel=\"Running Integral of the VACF (Å^2 / ps)\",\n ):\n \"\"\"\n Returns a plot of the running integral of the\n velocity autocorrelation function (VACF) via ``Matplotlib``.\n In this case, the running integral is the integral of the VACF\n divided by the dimensionality. Analysis must be run prior to plotting.\n\n Parameters\n ----------\n start : Optional[int]\n The first frame of ``self.results.timeseries``\n used for the plot.\n stop : Optional[int]\n The frame of ``self.results.timeseries`` to stop at\n for the plot, non-inclusive.\n step : Optional[int]\n Number of frames to skip between each plotted frame.\n initial : Optional[float]\n Inserted value at the beginning of the integrated result array.\n Defaults to 0.\n xlabel : Optional[str]\n The x-axis label text. Defaults to \"Time (ps)\".\n ylabel : Optional[str]\n The y-axis label text.\n Defaults to \"Running Integral of the VACF (Å^2 / ps)\".\n\n Returns\n -------\n :class:`matplotlib.lines.Line2D`\n A :class:`matplotlib.lines.Line2D` instance with\n the desired VACF plotting information.\n \"\"\"\n if not self._run_called:\n raise RuntimeError(\"Analysis must be run prior to plotting\")\n\n stop = self.n_frames if stop == 0 else stop\n\n running_integral = (\n integrate.cumulative_trapezoid(\n self.results.timeseries[start:stop:step],\n self.times[start:stop:step],\n initial=initial,\n )\n / self.dim_fac\n )\n\n fig, ax_running_integral = plt.subplots()\n ax_running_integral.set_xlabel(xlabel)\n ax_running_integral.set_ylabel(ylabel)\n return ax_running_integral.plot(\n self.times[start:stop:step],\n running_integral,\n )", "probing input": " def plot_running_integral(\n self,\n start=0,\n stop=0,\n step=1,\n initial=0,\n xlabel=\"Time (ps)\",\n ylabel=\"Running Integral of the VACF (Å^2 / ps)\",\n ):\n \"\"\"\n Returns a plot of the running integral of the\n velocity autocorrelation function (VACF) via ``Matplotlib``.\n In this case, the running integral is the integral of the VACF\n divided by the dimensionality. Analysis must be run prior to plotting.\n\n Parameters\n ----------\n start : Optional[int]\n The first frame of ``self.results.timeseries``\n used for the plot.\n stop : Optional[int]\n The frame of ``self.results.timeseries`` to stop at\n for the plot, non-inclusive.\n step : Optional[int]\n Number of frames to skip between each plotted frame.\n initial : Optional[float]\n Inserted value at the beginning of the integrated result array.\n Defaults to 0.\n xlabel : Optional[str]\n The x-axis label text. Defaults to \"Time (ps)\".\n ylabel : Optional[str]\n The y-axis label text.\n Defaults to \"Running Integral of the VACF (Å^2 / ps)\".\n\n Returns\n -------\n :class:`matplotlib.lines.Line2D`\n A :class:`matplotlib.lines.Line2D` instance with\n the desired VACF plotting information.\n \"\"\"\n if not self._run_called:\n raise RuntimeError(\"Analysis must be run prior to plotting\")\n\n stop = self.n_frames if stop == 0 else stop\n\n running_integral = (\n", "probing input new": " def plot_running_integral(\n self,\n start=0,\n stop=0,\n step=1,\n initial=0,\n xlabel=\"Time (ps)\",\n ylabel=\"Running Integral of the VACF (Å^2 / ps)\",\n ):\n \"\"\"\n Returns a plot of the running integral of the\n velocity autocorrelation function (VACF) via ``Matplotlib``.\n In this case, the running integral is the integral of the VACF\n divided by the dimensionality. Analysis must be run prior to plotting.\n\n Parameters\n ----------\n start : Optional[int]\n The first frame of ``self.results.timeseries``\n used for the plot.\n stop : Optional[int]\n The frame of ``self.results.timeseries`` to stop at\n for the plot, non-inclusive.\n step : Optional[int]\n Number of frames to skip between each plotted frame.\n initial : Optional[float]\n Inserted value at the beginning of the integrated result array.\n Defaults to 0.\n xlabel : Optional[str]\n The x-axis label text. Defaults to \"Time (ps)\".\n ylabel : Optional[str]\n The y-axis label text.\n Defaults to \"Running Integral of the VACF (Å^2 / ps)\".\n\n Returns\n -------\n :class:`matplotlib.lines.Line2D`\n A :class:`matplotlib.lines.Line2D` instance with\n the desired VACF plotting information.\n \"\"\"\n if not self._run_called:\n raise RuntimeError(\"Analysis must be run prior to plotting\")\n\n stop = self.n_frames if stop == 0 else stop\n\n running_integral = (\n integrate.", "reference": "integrate.cumulative_trapezoid(self.results.timeseries[start:stop:step],self.times[start:stop:step],initial=initial,)", "reference dict": {}, "alias dict": { "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "integrate.cumulative_trapezoid", "y_pos": "integrate.cumulative_trapezoid(self.results.timeseries[start:stop:step],self.times[start:stop:step],initial=initial,)", "y_neg": " integrate.cumtrapz(self.results.vacf, self.results.timeseries, initial=initial) / self.dim", "retain": " def plot_running_integral(\n self,\n start=0,\n stop=0,\n step=1,\n initial=0,\n xlabel=\"Time (ps)\",\n ylabel=\"Running Integral of the VACF (Å^2 / ps)\",\n ):\n \"\"\"\n Returns a plot of the running integral of the\n velocity autocorrelation function (VACF) via ``Matplotlib``.\n In this case, the running integral is the integral of the VACF\n divided by the dimensionality. Analysis must be run prior to plotting.\n\n Parameters\n ----------\n start : Optional[int]\n The first frame of ``self.results.timeseries``\n used for the plot.\n stop : Optional[int]\n The frame of ``self.results.timeseries`` to stop at\n for the plot, non-inclusive.\n step : Optional[int]\n Number of frames to skip between each plotted frame.\n initial : Optional[float]\n Inserted value at the beginning of the integrated result array.\n Defaults to 0.\n xlabel : Optional[str]\n The x-axis label text. Defaults to \"Time (ps)\".\n ylabel : Optional[str]\n The y-axis label text.\n Defaults to \"Running Integral of the VACF (Å^2 / ps)\".\n\n Returns\n -------\n :class:`matplotlib.lines.Line2D`\n A :class:`matplotlib.lines.Line2D` instance with\n the desired VACF plotting information.\n \"\"\"\n if not self._run_called:\n raise RuntimeError(\"Analysis must be run prior to plotting\")\n\n stop = self.n_frames if stop == 0 else stop\n\n running_integral = (\n integrate.cumulative_trapezoid(\n self.results.timeseries[start:stop:step],\n self.times[start:stop:step],\n initial=initial,\n )\n / self.dim_fac\n )\n\n fig, ax_running_integral = plt.subplots()\n ax_running_integral.set_xlabel(xlabel)\n ax_running_integral.set_ylabel(ylabel)\n return ax_running_integral.plot(\n self.times[start:stop:step],\n running_integral,\n )" }, { "id": 10432, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def energy_radiated(self) -> np.ndarray:\n \"\"\"Energy radiated, :math:`E`.\n\n https://arxiv.org/pdf/0707.4654.pdf\n eq 3.8\n\n Returns:\n numpy.ndarray: cumulative :math:`E` radiated\n\n \"\"\"\n energy_dot = self.dEnergy_dt_radiated\n energy_radiated = scipy.integrate.cumulative_trapezoid(energy_dot, self.time, initial=0)\n return energy_radiated", "probing input": " def energy_radiated(self) -> np.ndarray:\n \"\"\"Energy radiated, :math:`E`.\n\n https://arxiv.org/pdf/0707.4654.pdf\n eq 3.8\n\n Returns:\n numpy.ndarray: cumulative :math:`E` radiated\n\n \"\"\"\n energy_dot = self.dEnergy_dt_radiated\n", "probing input new": " def energy_radiated(self) -> np.ndarray:\n \"\"\"Energy radiated, :math:`E`.\n\n https://arxiv.org/pdf/0707.4654.pdf\n eq 3.8\n\n Returns:\n numpy.ndarray: cumulative :math:`E` radiated\n\n \"\"\"\n energy_dot = self.dEnergy_dt_radiated\n energy_radiated = scipy.integrate.", "reference": "energy_radiated=scipy.integrate.cumulative_trapezoid(energy_dot,self.time,initial=0)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "energy_radiated=scipy.integrate.cumulative_trapezoid(energy_dot,self.time,initial=0)", "y_neg": " energy_radiated = scipy.integrate.cumtrapz(energy_dot, self.time, initial=0)", "retain": " def energy_radiated(self) -> np.ndarray:\n \"\"\"Energy radiated, :math:`E`.\n\n https://arxiv.org/pdf/0707.4654.pdf\n eq 3.8\n\n Returns:\n numpy.ndarray: cumulative :math:`E` radiated\n\n \"\"\"\n energy_dot = self.dEnergy_dt_radiated\n energy_radiated = scipy.integrate.cumulative_trapezoid(energy_dot, self.time, initial=0)\n return energy_radiated" }, { "id": 10433, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def linear_momentum_radiated(self) -> np.ndarray:\n \"\"\"Linear momentum radiated as gravitational waves\n\n https://arxiv.org/pdf/0707.4654.pdf\n eqs 3.14, 3.15\n\n Returns:\n numpy.ndarray: linear momentum radiated\n\n \"\"\"\n Pdot = self.dP_dt_radiated\n linear_momentum_radiated = scipy.integrate.cumulative_trapezoid(Pdot, self.time, initial=0, axis=0)\n return linear_momentum_radiated", "probing input": " def linear_momentum_radiated(self) -> np.ndarray:\n \"\"\"Linear momentum radiated as gravitational waves\n\n https://arxiv.org/pdf/0707.4654.pdf\n eqs 3.14, 3.15\n\n Returns:\n numpy.ndarray: linear momentum radiated\n\n \"\"\"\n Pdot = self.dP_dt_radiated\n", "probing input new": " def linear_momentum_radiated(self) -> np.ndarray:\n \"\"\"Linear momentum radiated as gravitational waves\n\n https://arxiv.org/pdf/0707.4654.pdf\n eqs 3.14, 3.15\n\n Returns:\n numpy.ndarray: linear momentum radiated\n\n \"\"\"\n Pdot = self.dP_dt_radiated\n linear_momentum_radiated = scipy.integrate.", "reference": "linear_momentum_radiated=scipy.integrate.cumulative_trapezoid(Pdot,self.time,initial=0,axis=0)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "linear_momentum_radiated=scipy.integrate.cumulative_trapezoid(Pdot,self.time,initial=0,axis=0)", "y_neg": " linear_momentum_radiated = scipy.integrate.cumtrapz(Pdot, self.time, initial=0)", "retain": " def linear_momentum_radiated(self) -> np.ndarray:\n \"\"\"Linear momentum radiated as gravitational waves\n\n https://arxiv.org/pdf/0707.4654.pdf\n eqs 3.14, 3.15\n\n Returns:\n numpy.ndarray: linear momentum radiated\n\n \"\"\"\n Pdot = self.dP_dt_radiated\n linear_momentum_radiated = scipy.integrate.cumulative_trapezoid(Pdot, self.time, initial=0, axis=0)\n return linear_momentum_radiated" }, { "id": 10439, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def inverse_transform(self, X: FDataGrid, y: None = None) -> FDataGrid:\n r\"\"\"\n Compute the inverse SRSF transform.\n\n Given the srsf and the initial value the original function can be\n obtained as :footcite:`srivastava+klassen_2016_functionala`:\n\n .. math::\n f(t) = f(a) + \\int_{a}^t q(t)|q(t)|dt\n\n where :math:`q(t)=SRSF(f(t))`.\n\n If it is applied this inverse transformation without fitting the\n estimator it is assumed that :math:`f(a)=0`.\n\n Args:\n X: SRSF to be transformed.\n y: Present for API conventions.\n\n Returns:\n Functions in the original space.\n\n Raises:\n ValueError: If functions are multidimensional.\n \"\"\"\n check_fdata_dimensions(\n X,\n dim_domain=1,\n dim_codomain=1,\n )\n\n stored_initial_value = getattr(self, 'initial_value_', None)\n\n if self.initial_value is None and stored_initial_value is None:\n raise AttributeError(\n \"When initial_value=None is expected a \"\n \"previous transformation of the data to \"\n \"store the initial values to apply in the \"\n \"inverse transformation. Also it is possible \"\n \"to fix these values setting the attribute\"\n \"initial value without a previous \"\n \"transformation.\",\n )\n\n if self.output_points is None:\n output_points = X.grid_points[0]\n else:\n output_points = np.asarray(self.output_points)\n\n data_matrix = X(output_points)\n\n data_matrix *= np.abs(data_matrix)\n\n f_data_matrix = scipy.integrate.cumulative_trapezoid(\n data_matrix,\n x=output_points,\n axis=1,\n initial=0,\n )\n\n # If the transformer was fitted, sum the initial value\n if self.initial_value is None:\n f_data_matrix += self.initial_value_\n else:\n f_data_matrix += self.initial_value\n\n return X.copy(data_matrix=f_data_matrix, grid_points=output_points)", "probing input": " def inverse_transform(self, X: FDataGrid, y: None = None) -> FDataGrid:\n r\"\"\"\n Compute the inverse SRSF transform.\n\n Given the srsf and the initial value the original function can be\n obtained as :footcite:`srivastava+klassen_2016_functionala`:\n\n .. math::\n f(t) = f(a) + \\int_{a}^t q(t)|q(t)|dt\n\n where :math:`q(t)=SRSF(f(t))`.\n\n If it is applied this inverse transformation without fitting the\n estimator it is assumed that :math:`f(a)=0`.\n\n Args:\n X: SRSF to be transformed.\n y: Present for API conventions.\n\n Returns:\n Functions in the original space.\n\n Raises:\n ValueError: If functions are multidimensional.\n \"\"\"\n check_fdata_dimensions(\n X,\n dim_domain=1,\n dim_codomain=1,\n )\n\n stored_initial_value = getattr(self, 'initial_value_', None)\n\n if self.initial_value is None and stored_initial_value is None:\n raise AttributeError(\n \"When initial_value=None is expected a \"\n \"previous transformation of the data to \"\n \"store the initial values to apply in the \"\n \"inverse transformation. Also it is possible \"\n \"to fix these values setting the attribute\"\n \"initial value without a previous \"\n \"transformation.\",\n )\n\n if self.output_points is None:\n output_points = X.grid_points[0]\n else:\n output_points = np.asarray(self.output_points)\n\n data_matrix = X(output_points)\n\n data_matrix *= np.abs(data_matrix)\n\n", "probing input new": " def inverse_transform(self, X: FDataGrid, y: None = None) -> FDataGrid:\n r\"\"\"\n Compute the inverse SRSF transform.\n\n Given the srsf and the initial value the original function can be\n obtained as :footcite:`srivastava+klassen_2016_functionala`:\n\n .. math::\n f(t) = f(a) + \\int_{a}^t q(t)|q(t)|dt\n\n where :math:`q(t)=SRSF(f(t))`.\n\n If it is applied this inverse transformation without fitting the\n estimator it is assumed that :math:`f(a)=0`.\n\n Args:\n X: SRSF to be transformed.\n y: Present for API conventions.\n\n Returns:\n Functions in the original space.\n\n Raises:\n ValueError: If functions are multidimensional.\n \"\"\"\n check_fdata_dimensions(\n X,\n dim_domain=1,\n dim_codomain=1,\n )\n\n stored_initial_value = getattr(self, 'initial_value_', None)\n\n if self.initial_value is None and stored_initial_value is None:\n raise AttributeError(\n \"When initial_value=None is expected a \"\n \"previous transformation of the data to \"\n \"store the initial values to apply in the \"\n \"inverse transformation. Also it is possible \"\n \"to fix these values setting the attribute\"\n \"initial value without a previous \"\n \"transformation.\",\n )\n\n if self.output_points is None:\n output_points = X.grid_points[0]\n else:\n output_points = np.asarray(self.output_points)\n\n data_matrix = X(output_points)\n\n data_matrix *= np.abs(data_matrix)\n\n f_data_matrix = scipy.integrate.", "reference": "f_data_matrix=scipy.integrate.cumulative_trapezoid(data_matrix,x=output_points,axis=1,initial=0,)", "reference dict": { "data_matrix": "X" }, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "f_data_matrix=scipy.integrate.cumulative_trapezoid(data_matrix,x=output_points,axis=1,initial=0,)", "y_neg": " f_data_matrix = scipy.integrate.cumtrapz(", "retain": " def inverse_transform(self, X: FDataGrid, y: None = None) -> FDataGrid:\n r\"\"\"\n Compute the inverse SRSF transform.\n\n Given the srsf and the initial value the original function can be\n obtained as :footcite:`srivastava+klassen_2016_functionala`:\n\n .. math::\n f(t) = f(a) + \\int_{a}^t q(t)|q(t)|dt\n\n where :math:`q(t)=SRSF(f(t))`.\n\n If it is applied this inverse transformation without fitting the\n estimator it is assumed that :math:`f(a)=0`.\n\n Args:\n X: SRSF to be transformed.\n y: Present for API conventions.\n\n Returns:\n Functions in the original space.\n\n Raises:\n ValueError: If functions are multidimensional.\n \"\"\"\n check_fdata_dimensions(\n X,\n dim_domain=1,\n dim_codomain=1,\n )\n\n stored_initial_value = getattr(self, 'initial_value_', None)\n\n if self.initial_value is None and stored_initial_value is None:\n raise AttributeError(\n \"When initial_value=None is expected a \"\n \"previous transformation of the data to \"\n \"store the initial values to apply in the \"\n \"inverse transformation. Also it is possible \"\n \"to fix these values setting the attribute\"\n \"initial value without a previous \"\n \"transformation.\",\n )\n\n if self.output_points is None:\n output_points = X.grid_points[0]\n else:\n output_points = np.asarray(self.output_points)\n\n data_matrix = X(output_points)\n\n data_matrix *= np.abs(data_matrix)\n\n f_data_matrix = scipy.integrate.cumulative_trapezoid(\n data_matrix,\n x=output_points,\n axis=1,\n initial=0,\n )\n\n # If the transformer was fitted, sum the initial value\n if self.initial_value is None:\n f_data_matrix += self.initial_value_\n else:\n f_data_matrix += self.initial_value\n\n return X.copy(data_matrix=f_data_matrix, grid_points=output_points)" }, { "id": 10440, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def compute_A2_nonlocal(Q, microstructure):\n\n margin = 4 # this number must be higher for small grains, because\n # the FT of gamma is wider, so is the integrand of ReF. It means that using the long range version\n # is not recommanded for small grains\n # this value should be adaptive\n\n maxq = margin * Q\n\n k = 12 # number of samples. This should be adaptive depending on the size/wavelength\n n = 2**k\n nQ = n // margin\n q = np.linspace(0, maxq, n + 1)\n\n assert q[nQ] == Q\n\n # start with the imaginary part - Eq (70)\n y = 2 * q * microstructure.ft_autocorrelation_function(2 * q)\n\n # integrate from 0 to 2Q (for Q in 0 to qmax)\n # take the real part to avoid warnings... but this remains to be explored\n primitive = scipy.integrate.cumulative_trapezoid(y.real, 2 * q.real, initial=0)\n\n ImF = - 1 / (2 * (2 * np.pi)**1.5) * q * primitive\n\n # continue with the real part. Eq (71) is much more difficult to compute than the imaginary part\n # because of the principal value, but Torquato 2021, suppmat gives a hint with Eq S111.\n # here: M = maxq\n\n with np.errstate(invalid='ignore'):\n y1 = ImF / ((Q + q) * q)\n y1[0] = 0 # remove the singularity in 0\n\n y2 = (ImF - ImF[nQ]) / (Q**2 - q**2)\n\n y2[nQ] = (y2[nQ - 1] + y2[nQ + 1]) / 2 # remove the singularity in Q\n\n y = y1 + y2\n\n asymptotic_integral = (ImF[nQ] - Q / maxq * ImF[-1]) * np.log(np.abs((maxq + Q) / (maxq - Q)))\n\n ReF = - 2 / np.pi * Q * scipy.integrate.romb(y.real, maxq / n) - 1 / np.pi * asymptotic_integral\n\n gamma_3_2 = 0.5 * np.sqrt(np.pi)\n A2 = - (2 * np.pi) / (2**1.5 * gamma_3_2) * (ReF + 1j * ImF[nQ]) # the factor is from eq 67\n\n # check ImF(Q)\n # q = np.linspace(0, 2 * Q, n + 1)\n # y = q * microstructure.ft_autocorrelation_funscipyction(q)\n # ImFQ_direct = - 1 / (2 * (2 * np.pi)**1.5) * Q * scipy.integrate.romb(y, 2 * Q / n)\n # print(ImF[nQ], ImFQ_direct)\n\n return A2", "probing input": "def compute_A2_nonlocal(Q, microstructure):\n\n margin = 4 # this number must be higher for small grains, because\n # the FT of gamma is wider, so is the integrand of ReF. It means that using the long range version\n # is not recommanded for small grains\n # this value should be adaptive\n\n maxq = margin * Q\n\n k = 12 # number of samples. This should be adaptive depending on the size/wavelength\n n = 2**k\n nQ = n // margin\n q = np.linspace(0, maxq, n + 1)\n\n assert q[nQ] == Q\n\n # start with the imaginary part - Eq (70)\n y = 2 * q * microstructure.ft_autocorrelation_function(2 * q)\n\n # integrate from 0 to 2Q (for Q in 0 to qmax)\n # take the real part to avoid warnings... but this remains to be explored\n", "probing input new": "def compute_A2_nonlocal(Q, microstructure):\n\n margin = 4 # this number must be higher for small grains, because\n # the FT of gamma is wider, so is the integrand of ReF. It means that using the long range version\n # is not recommanded for small grains\n # this value should be adaptive\n\n maxq = margin * Q\n\n k = 12 # number of samples. This should be adaptive depending on the size/wavelength\n n = 2**k\n nQ = n // margin\n q = np.linspace(0, maxq, n + 1)\n\n assert q[nQ] == Q\n\n # start with the imaginary part - Eq (70)\n y = 2 * q * microstructure.ft_autocorrelation_function(2 * q)\n\n # integrate from 0 to 2Q (for Q in 0 to qmax)\n # take the real part to avoid warnings... but this remains to be explored\n primitive = scipy.integrate.", "reference": "primitive=scipy.integrate.cumulative_trapezoid(y.real,2*q.real,initial=0)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "scipy.integrate.cumulative_trapezoid", "y_pos": "primitive=scipy.integrate.cumulative_trapezoid(y.real,2*q.real,initial=0)", "y_neg": " primitive = scipy.integrate.cumtrapz(y, q, initial=0)", "retain": "def compute_A2_nonlocal(Q, microstructure):\n\n margin = 4 # this number must be higher for small grains, because\n # the FT of gamma is wider, so is the integrand of ReF. It means that using the long range version\n # is not recommanded for small grains\n # this value should be adaptive\n\n maxq = margin * Q\n\n k = 12 # number of samples. This should be adaptive depending on the size/wavelength\n n = 2**k\n nQ = n // margin\n q = np.linspace(0, maxq, n + 1)\n\n assert q[nQ] == Q\n\n # start with the imaginary part - Eq (70)\n y = 2 * q * microstructure.ft_autocorrelation_function(2 * q)\n\n # integrate from 0 to 2Q (for Q in 0 to qmax)\n # take the real part to avoid warnings... but this remains to be explored\n primitive = scipy.integrate.cumulative_trapezoid(y.real, 2 * q.real, initial=0)\n\n ImF = - 1 / (2 * (2 * np.pi)**1.5) * q * primitive\n\n # continue with the real part. Eq (71) is much more difficult to compute than the imaginary part\n # because of the principal value, but Torquato 2021, suppmat gives a hint with Eq S111.\n # here: M = maxq\n\n with np.errstate(invalid='ignore'):\n y1 = ImF / ((Q + q) * q)\n y1[0] = 0 # remove the singularity in 0\n\n y2 = (ImF - ImF[nQ]) / (Q**2 - q**2)\n\n y2[nQ] = (y2[nQ - 1] + y2[nQ + 1]) / 2 # remove the singularity in Q\n\n y = y1 + y2\n\n asymptotic_integral = (ImF[nQ] - Q / maxq * ImF[-1]) * np.log(np.abs((maxq + Q) / (maxq - Q)))\n\n ReF = - 2 / np.pi * Q * scipy.integrate.romb(y.real, maxq / n) - 1 / np.pi * asymptotic_integral\n\n gamma_3_2 = 0.5 * np.sqrt(np.pi)\n A2 = - (2 * np.pi) / (2**1.5 * gamma_3_2) * (ReF + 1j * ImF[nQ]) # the factor is from eq 67\n\n # check ImF(Q)\n # q = np.linspace(0, 2 * Q, n + 1)\n # y = q * microstructure.ft_autocorrelation_funscipyction(q)\n # ImFQ_direct = - 1 / (2 * (2 * np.pi)**1.5) * Q * scipy.integrate.romb(y, 2 * Q / n)\n # print(ImF[nQ], ImFQ_direct)\n\n return A2" }, { "id": 10443, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def calc_sigma2_nu(r, cmass, nu, g):\n \"\"\" Calculate the 3D Jeans integration:\n .. math::\n sigma2(r0) nu(r0) g(r_0) = int_r0^\\infty G M(r) nu(r) g(r) / r^2 dr\n\n where:\n - G is the gravitational constant\n - M(r) is the enclosed radius at radius r in Msun\n - nu(r) is the 3D light profile\n - g(r) is the anistropy integral\n\n Parameters\n ----------\n r: array of N float\n The 3D radius in kpc\n cmass: array of N float\n The cumulative mass in Msun\n nu: array of N float\n The 3D light profile\n g: array of N float\n The anistropy integral\n \"\"\"\n G = const.G.to_value(u.kpc**3 / u.Msun / u.s**2)\n inte = cmass * G * nu * g / r**2\n\n # check if r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n return integrate.cumulative_trapezoid(\n inte[::-1], x=r[::-1], initial=0)[::-1] / g\n else:\n return integrate.cumulative_trapezoid(\n inte[::-1], dx=dr, initial=0)[::-1] / g", "probing input": "def calc_sigma2_nu(r, cmass, nu, g):\n \"\"\" Calculate the 3D Jeans integration:\n .. math::\n sigma2(r0) nu(r0) g(r_0) = int_r0^\\infty G M(r) nu(r) g(r) / r^2 dr\n\n where:\n - G is the gravitational constant\n - M(r) is the enclosed radius at radius r in Msun\n - nu(r) is the 3D light profile\n - g(r) is the anistropy integral\n\n Parameters\n ----------\n r: array of N float\n The 3D radius in kpc\n cmass: array of N float\n The cumulative mass in Msun\n nu: array of N float\n The 3D light profile\n g: array of N float\n The anistropy integral\n \"\"\"\n G = const.G.to_value(u.kpc**3 / u.Msun / u.s**2)\n inte = cmass * G * nu * g / r**2\n\n # check if r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n", "probing input new": "def calc_sigma2_nu(r, cmass, nu, g):\n \"\"\" Calculate the 3D Jeans integration:\n .. math::\n sigma2(r0) nu(r0) g(r_0) = int_r0^\\infty G M(r) nu(r) g(r) / r^2 dr\n\n where:\n - G is the gravitational constant\n - M(r) is the enclosed radius at radius r in Msun\n - nu(r) is the 3D light profile\n - g(r) is the anistropy integral\n\n Parameters\n ----------\n r: array of N float\n The 3D radius in kpc\n cmass: array of N float\n The cumulative mass in Msun\n nu: array of N float\n The 3D light profile\n g: array of N float\n The anistropy integral\n \"\"\"\n G = const.G.to_value(u.kpc**3 / u.Msun / u.s**2)\n inte = cmass * G * nu * g / r**2\n\n # check if r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n return integrate.", "reference": "returnintegrate.cumulative_trapezoid(inte[::-1],x=r[::-1],initial=0)[::-1]/g", "reference dict": {}, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn", "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.cumtrapz" ], "replacement api": "scipy.integrate.cumulative_trapezoid", "expected call": "integrate.cumulative_trapezoid", "y_pos": "returnintegrate.cumulative_trapezoid(inte[::-1],x=r[::-1],initial=0)[::-1]/g", "y_neg": " return integrate.cumtrapz(inte, r, axis=0)", "retain": "def calc_sigma2_nu(r, cmass, nu, g):\n \"\"\" Calculate the 3D Jeans integration:\n .. math::\n sigma2(r0) nu(r0) g(r_0) = int_r0^\\infty G M(r) nu(r) g(r) / r^2 dr\n\n where:\n - G is the gravitational constant\n - M(r) is the enclosed radius at radius r in Msun\n - nu(r) is the 3D light profile\n - g(r) is the anistropy integral\n\n Parameters\n ----------\n r: array of N float\n The 3D radius in kpc\n cmass: array of N float\n The cumulative mass in Msun\n nu: array of N float\n The 3D light profile\n g: array of N float\n The anistropy integral\n \"\"\"\n G = const.G.to_value(u.kpc**3 / u.Msun / u.s**2)\n inte = cmass * G * nu * g / r**2\n\n # check if r is equally spaced\n dr = r[1] - r[0]\n if np.any(np.abs(np.diff(r) - dr) > 1e-6):\n return integrate.cumulative_trapezoid(\n inte[::-1], x=r[::-1], initial=0)[::-1] / g\n else:\n return integrate.cumulative_trapezoid(\n inte[::-1], dx=dr, initial=0)[::-1] / g" }, { "id": 10575, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(\n self,\n data: FDataGrid,\n label: str,\n integration_weights: Optional[np.ndarray], # type: ignore[type-arg]\n regularization: Optional[L2Regularization[Any]],\n ) -> None:\n \"\"\"Initialize the data of a grid block.\"\"\"\n self.label = label\n\n self.mean = data.mean()\n self.data = data - self.mean\n self.data_matrix = data.data_matrix[..., 0]\n\n # Arrange the integration weights in a diagonal matrix\n # By default, use Simpson's rule\n if integration_weights is None:\n identity = np.identity(self.data_matrix.shape[1])\n integration_weights = scipy.integrate.simpson(\n identity,\n x=self.data.grid_points[0],\n )\n self.integration_weights = np.diag(integration_weights)\n\n # Compute the regularization matrix\n # By default, all zeros (no regularization)\n regularization_matrix = None\n if regularization is not None:\n regularization_matrix = compute_penalty_matrix(\n basis_iterable=(\n _GridBasis(grid_points=self.data.grid_points),\n ),\n regularization_parameter=1,\n regularization=regularization,\n )\n if regularization_matrix is None:\n regularization_matrix = np.zeros(\n (self.data_matrix.shape[1], self.data_matrix.shape[1]),\n )\n\n self.regularization_matrix = regularization_matrix\n self.G_data_weights = self.integration_weights\n self.G_weights = self.integration_weights", "probing input": " def __init__(\n self,\n data: FDataGrid,\n label: str,\n integration_weights: Optional[np.ndarray], # type: ignore[type-arg]\n regularization: Optional[L2Regularization[Any]],\n ) -> None:\n \"\"\"Initialize the data of a grid block.\"\"\"\n self.label = label\n\n self.mean = data.mean()\n self.data = data - self.mean\n self.data_matrix = data.data_matrix[..., 0]\n\n # Arrange the integration weights in a diagonal matrix\n # By default, use Simpson's rule\n if integration_weights is None:\n identity = np.identity(self.data_matrix.shape[1])\n", "probing input new": " def __init__(\n self,\n data: FDataGrid,\n label: str,\n integration_weights: Optional[np.ndarray], # type: ignore[type-arg]\n regularization: Optional[L2Regularization[Any]],\n ) -> None:\n \"\"\"Initialize the data of a grid block.\"\"\"\n self.label = label\n\n self.mean = data.mean()\n self.data = data - self.mean\n self.data_matrix = data.data_matrix[..., 0]\n\n # Arrange the integration weights in a diagonal matrix\n # By default, use Simpson's rule\n if integration_weights is None:\n identity = np.identity(self.data_matrix.shape[1])\n integration_weights = scipy.integrate.", "reference": "integration_weights=scipy.integrate.simpson(identity,x=self.data.grid_points[0],)", "reference dict": { "BlockType": "TypeVar", "InputTypeX": "TypeVar", "InputTypeY": "TypeVar" }, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "integration_weights=scipy.integrate.simpson(identity,x=self.data.grid_points[0],)", "y_neg": " integration_weights = scipy.integrate.simps(identity, axis=0)", "retain": " def __init__(\n self,\n data: FDataGrid,\n label: str,\n integration_weights: Optional[np.ndarray], # type: ignore[type-arg]\n regularization: Optional[L2Regularization[Any]],\n ) -> None:\n \"\"\"Initialize the data of a grid block.\"\"\"\n self.label = label\n\n self.mean = data.mean()\n self.data = data - self.mean\n self.data_matrix = data.data_matrix[..., 0]\n\n # Arrange the integration weights in a diagonal matrix\n # By default, use Simpson's rule\n if integration_weights is None:\n identity = np.identity(self.data_matrix.shape[1])\n integration_weights = scipy.integrate.simpson(\n identity,\n x=self.data.grid_points[0],\n )\n self.integration_weights = np.diag(integration_weights)\n\n # Compute the regularization matrix\n # By default, all zeros (no regularization)\n regularization_matrix = None\n if regularization is not None:\n regularization_matrix = compute_penalty_matrix(\n basis_iterable=(\n _GridBasis(grid_points=self.data.grid_points),\n ),\n regularization_parameter=1,\n regularization=regularization,\n )\n if regularization_matrix is None:\n regularization_matrix = np.zeros(\n (self.data_matrix.shape[1], self.data_matrix.shape[1]),\n )\n\n self.regularization_matrix = regularization_matrix\n self.G_data_weights = self.integration_weights\n self.G_weights = self.integration_weights" }, { "id": 10576, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_basis_vs_grid(self) -> None:\n \"\"\"Test that the results are the same in basis and grid.\"\"\"\n X, y = fetch_tecator(\n return_X_y=True,\n )\n\n original_grid_points = X.grid_points[0]\n # Express the data in a FDataBasis\n X = X.to_basis(BSplineBasis(n_basis=20))\n\n # Fit the model\n fplsr = FPLSRegression[FData, NDArrayFloat](n_components=5)\n fplsr.fit(X, y)\n basis_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n # Go back to grid\n new_grid_points = np.linspace(\n original_grid_points[0],\n original_grid_points[-1],\n 1000,\n )\n X = X.to_grid(grid_points=new_grid_points)\n\n # Get the weights for the Simpson's rule\n identity = np.eye(len(X.grid_points[0]))\n ss_weights = scipy.integrate.simpson(identity, x=X.grid_points[0])\n\n # Fit the model with weights\n fplsr = FPLSRegression(\n n_components=5,\n _integration_weights_X=ss_weights,\n )\n fplsr.fit(X, y)\n\n grid_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n np.testing.assert_allclose(\n basis_components,\n grid_components,\n rtol=3e-3,\n )", "probing input": " def test_basis_vs_grid(self) -> None:\n \"\"\"Test that the results are the same in basis and grid.\"\"\"\n X, y = fetch_tecator(\n return_X_y=True,\n )\n\n original_grid_points = X.grid_points[0]\n # Express the data in a FDataBasis\n X = X.to_basis(BSplineBasis(n_basis=20))\n\n # Fit the model\n fplsr = FPLSRegression[FData, NDArrayFloat](n_components=5)\n fplsr.fit(X, y)\n basis_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n # Go back to grid\n new_grid_points = np.linspace(\n original_grid_points[0],\n original_grid_points[-1],\n 1000,\n )\n X = X.to_grid(grid_points=new_grid_points)\n\n # Get the weights for the Simpson's rule\n identity = np.eye(len(X.grid_points[0]))\n", "probing input new": " def test_basis_vs_grid(self) -> None:\n \"\"\"Test that the results are the same in basis and grid.\"\"\"\n X, y = fetch_tecator(\n return_X_y=True,\n )\n\n original_grid_points = X.grid_points[0]\n # Express the data in a FDataBasis\n X = X.to_basis(BSplineBasis(n_basis=20))\n\n # Fit the model\n fplsr = FPLSRegression[FData, NDArrayFloat](n_components=5)\n fplsr.fit(X, y)\n basis_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n # Go back to grid\n new_grid_points = np.linspace(\n original_grid_points[0],\n original_grid_points[-1],\n 1000,\n )\n X = X.to_grid(grid_points=new_grid_points)\n\n # Get the weights for the Simpson's rule\n identity = np.eye(len(X.grid_points[0]))\n ss_weights = scipy.integrate.", "reference": "ss_weights=scipy.integrate.simpson(identity,x=X.grid_points[0])", "reference dict": { "fplsr": "FPLSRegression" }, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "ss_weights=scipy.integrate.simpson(identity,x=X.grid_points[0])", "y_neg": " ss_weights = scipy.integrate.simps(identity, new_grid_points)", "retain": " def test_basis_vs_grid(self) -> None:\n \"\"\"Test that the results are the same in basis and grid.\"\"\"\n X, y = fetch_tecator(\n return_X_y=True,\n )\n\n original_grid_points = X.grid_points[0]\n # Express the data in a FDataBasis\n X = X.to_basis(BSplineBasis(n_basis=20))\n\n # Fit the model\n fplsr = FPLSRegression[FData, NDArrayFloat](n_components=5)\n fplsr.fit(X, y)\n basis_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n # Go back to grid\n new_grid_points = np.linspace(\n original_grid_points[0],\n original_grid_points[-1],\n 1000,\n )\n X = X.to_grid(grid_points=new_grid_points)\n\n # Get the weights for the Simpson's rule\n identity = np.eye(len(X.grid_points[0]))\n ss_weights = scipy.integrate.simpson(identity, x=X.grid_points[0])\n\n # Fit the model with weights\n fplsr = FPLSRegression(\n n_components=5,\n _integration_weights_X=ss_weights,\n )\n fplsr.fit(X, y)\n\n grid_components = fplsr.fpls_.x_rotations_(original_grid_points)\n\n np.testing.assert_allclose(\n basis_components,\n grid_components,\n rtol=3e-3,\n )" }, { "id": 10578, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def organ_analysis(organ, polyline, closest_nodes, stem_vector_mean=None):\n if len(polyline) <= 1:\n return None\n\n organ.info['pm_position_tip'] = tuple(polyline[-1])\n organ.info['pm_position_base'] = tuple(polyline[0])\n organ.info['pm_z_tip'] = polyline[-1][2]\n organ.info['pm_z_base'] = polyline[0][2]\n\n length = compute_length_organ(polyline)\n organ.info['pm_length'] = length\n normalized_curvilinear_abscissa = compute_curvilinear_abscissa(\n polyline, length)\n curvilinear_abscissa = compute_curvilinear_abscissa(polyline, 1)\n # Compute width\n width = compute_width_organ(closest_nodes)\n\n organ.info['pm_width_max'] = max(width)\n organ.info['pm_width_mean'] = sum(width) / float(len(width))\n organ.info['pm_surface'] = scipy.integrate.simpson(\n y= width, x=curvilinear_abscissa)\n\n fitted_width = compute_fitted_width(width, normalized_curvilinear_abscissa)\n organ.info['pm_fitted_width_max'] = max(fitted_width)\n organ.info['pm_fitted_width_mean'] = (sum(fitted_width) / float(len(\n fitted_width)))\n organ.info['pm_fitted_surface'] = scipy.integrate.simpson(\n y=fitted_width, x=curvilinear_abscissa)\n # Compute azimuth\n azimuth_angle, vector_mean = compute_azimuth_angle(polyline)\n organ.info['pm_vector_mean'] = vector_mean\n organ.info['pm_azimuth_angle'] = azimuth_angle\n\n inclination_angle = compute_inclination_angle(polyline)\n organ.info['pm_inclination_angle'] = inclination_angle\n\n if stem_vector_mean is not None and len(polyline) >= 4:\n insertion_angle, vector = compute_insertion_angle(\n polyline, stem_vector_mean)\n\n organ.info['pm_insertion_angle_vector'] = vector\n organ.info['pm_insertion_angle'] = insertion_angle\n\n return organ", "probing input": "def organ_analysis(organ, polyline, closest_nodes, stem_vector_mean=None):\n if len(polyline) <= 1:\n return None\n\n organ.info['pm_position_tip'] = tuple(polyline[-1])\n organ.info['pm_position_base'] = tuple(polyline[0])\n organ.info['pm_z_tip'] = polyline[-1][2]\n organ.info['pm_z_base'] = polyline[0][2]\n\n length = compute_length_organ(polyline)\n organ.info['pm_length'] = length\n normalized_curvilinear_abscissa = compute_curvilinear_abscissa(\n polyline, length)\n curvilinear_abscissa = compute_curvilinear_abscissa(polyline, 1)\n # Compute width\n width = compute_width_organ(closest_nodes)\n\n organ.info['pm_width_max'] = max(width)\n organ.info['pm_width_mean'] = sum(width) / float(len(width))\n", "probing input new": "def organ_analysis(organ, polyline, closest_nodes, stem_vector_mean=None):\n if len(polyline) <= 1:\n return None\n\n organ.info['pm_position_tip'] = tuple(polyline[-1])\n organ.info['pm_position_base'] = tuple(polyline[0])\n organ.info['pm_z_tip'] = polyline[-1][2]\n organ.info['pm_z_base'] = polyline[0][2]\n\n length = compute_length_organ(polyline)\n organ.info['pm_length'] = length\n normalized_curvilinear_abscissa = compute_curvilinear_abscissa(\n polyline, length)\n curvilinear_abscissa = compute_curvilinear_abscissa(polyline, 1)\n # Compute width\n width = compute_width_organ(closest_nodes)\n\n organ.info['pm_width_max'] = max(width)\n organ.info['pm_width_mean'] = sum(width) / float(len(width))\n organ.info['pm_surface'] = scipy.integrate.", "reference": "organ.info['pm_surface']=scipy.integrate.simpson(y=width,x=curvilinear_abscissa)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "organ.info['pm_surface']=scipy.integrate.simpson(y=width,x=curvilinear_abscissa)", "y_neg": " organ.info['pm_surface'] = scipy.integrate.simps(width, curvilinear_abscissa)", "retain": "def organ_analysis(organ, polyline, closest_nodes, stem_vector_mean=None):\n if len(polyline) <= 1:\n return None\n\n organ.info['pm_position_tip'] = tuple(polyline[-1])\n organ.info['pm_position_base'] = tuple(polyline[0])\n organ.info['pm_z_tip'] = polyline[-1][2]\n organ.info['pm_z_base'] = polyline[0][2]\n\n length = compute_length_organ(polyline)\n organ.info['pm_length'] = length\n normalized_curvilinear_abscissa = compute_curvilinear_abscissa(\n polyline, length)\n curvilinear_abscissa = compute_curvilinear_abscissa(polyline, 1)\n # Compute width\n width = compute_width_organ(closest_nodes)\n\n organ.info['pm_width_max'] = max(width)\n organ.info['pm_width_mean'] = sum(width) / float(len(width))\n organ.info['pm_surface'] = scipy.integrate.simpson(\n y= width, x=curvilinear_abscissa)\n\n fitted_width = compute_fitted_width(width, normalized_curvilinear_abscissa)\n organ.info['pm_fitted_width_max'] = max(fitted_width)\n organ.info['pm_fitted_width_mean'] = (sum(fitted_width) / float(len(\n fitted_width)))\n organ.info['pm_fitted_surface'] = scipy.integrate.simpson(\n y=fitted_width, x=curvilinear_abscissa)\n # Compute azimuth\n azimuth_angle, vector_mean = compute_azimuth_angle(polyline)\n organ.info['pm_vector_mean'] = vector_mean\n organ.info['pm_azimuth_angle'] = azimuth_angle\n\n inclination_angle = compute_inclination_angle(polyline)\n organ.info['pm_inclination_angle'] = inclination_angle\n\n if stem_vector_mean is not None and len(polyline) >= 4:\n insertion_angle, vector = compute_insertion_angle(\n polyline, stem_vector_mean)\n\n organ.info['pm_insertion_angle_vector'] = vector\n organ.info['pm_insertion_angle'] = insertion_angle\n\n return organ" }, { "id": 10579, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def gridbasis_penalty_matrix_optimized(\n linear_operator: LinearDifferentialOperator,\n basis: _GridBasis,\n) -> NDArrayFloat:\n \"\"\"\n Optimized version for GridBasis.\n\n It evaluates the operator in the grid points.\n \"\"\"\n n_points = basis.grid_points[0].shape[0]\n findiff_accuracy = 2\n\n evaluated_basis, domain_limits = _optimized_operator_evaluation_in_grid(\n linear_operator,\n basis.grid_points[0],\n findiff_accuracy=findiff_accuracy,\n )\n\n # If the operator does not have constant weights, the\n # optimized evaluation is not implemented.\n if evaluated_basis is NotImplemented:\n return NotImplemented\n\n # The support of the result of applying the linear operator\n # is a small subset of the grid points. We calculate the\n # maximum number of points to the left and right of the\n # point where the linear operator is applied that can be\n # different from zero.\n\n max_domain_width = np.max(\n np.abs(domain_limits[:, 0] - domain_limits[:, 1]),\n )\n\n # Precompute the simpson quadrature for the entire domain.\n # This is done to avoid computing it for each subinterval of integration.\n quadrature = scipy.integrate.simpson(\n np.identity(n_points),\n x=basis.grid_points[0],\n )\n\n product_matrix = np.zeros((basis.n_basis, basis.n_basis))\n for i in range(n_points):\n # Maximum index of another function with not-disjoint support\n max_no_disjoint_index = min(n_points, i + 2 * max_domain_width)\n\n for j in range(i, max_no_disjoint_index):\n if domain_limits[i, 1] < domain_limits[j, 0]:\n continue\n\n left_lim = min(\n domain_limits[i, 0],\n domain_limits[j, 0],\n )\n right_lim = max(\n domain_limits[i, 1],\n domain_limits[j, 1],\n )\n\n # The right limit of the interval is excluded when slicing\n right_lim += 1\n\n # Limit both the multiplication and the integration to\n # the interval where the functions are not 0.\n operator_product = (\n evaluated_basis[i, left_lim:right_lim]\n * evaluated_basis[j, left_lim:right_lim]\n )\n sub_quadrature = quadrature[left_lim:right_lim]\n\n product_matrix[i, j] = np.dot(operator_product, sub_quadrature)\n product_matrix[j, i] = product_matrix[i, j]\n\n return product_matrix", "probing input": "def gridbasis_penalty_matrix_optimized(\n linear_operator: LinearDifferentialOperator,\n basis: _GridBasis,\n) -> NDArrayFloat:\n \"\"\"\n Optimized version for GridBasis.\n\n It evaluates the operator in the grid points.\n \"\"\"\n n_points = basis.grid_points[0].shape[0]\n findiff_accuracy = 2\n\n evaluated_basis, domain_limits = _optimized_operator_evaluation_in_grid(\n linear_operator,\n basis.grid_points[0],\n findiff_accuracy=findiff_accuracy,\n )\n\n # If the operator does not have constant weights, the\n # optimized evaluation is not implemented.\n if evaluated_basis is NotImplemented:\n return NotImplemented\n\n # The support of the result of applying the linear operator\n # is a small subset of the grid points. We calculate the\n # maximum number of points to the left and right of the\n # point where the linear operator is applied that can be\n # different from zero.\n\n max_domain_width = np.max(\n np.abs(domain_limits[:, 0] - domain_limits[:, 1]),\n )\n\n # Precompute the simpson quadrature for the entire domain.\n # This is done to avoid computing it for each subinterval of integration.\n", "probing input new": "def gridbasis_penalty_matrix_optimized(\n linear_operator: LinearDifferentialOperator,\n basis: _GridBasis,\n) -> NDArrayFloat:\n \"\"\"\n Optimized version for GridBasis.\n\n It evaluates the operator in the grid points.\n \"\"\"\n n_points = basis.grid_points[0].shape[0]\n findiff_accuracy = 2\n\n evaluated_basis, domain_limits = _optimized_operator_evaluation_in_grid(\n linear_operator,\n basis.grid_points[0],\n findiff_accuracy=findiff_accuracy,\n )\n\n # If the operator does not have constant weights, the\n # optimized evaluation is not implemented.\n if evaluated_basis is NotImplemented:\n return NotImplemented\n\n # The support of the result of applying the linear operator\n # is a small subset of the grid points. We calculate the\n # maximum number of points to the left and right of the\n # point where the linear operator is applied that can be\n # different from zero.\n\n max_domain_width = np.max(\n np.abs(domain_limits[:, 0] - domain_limits[:, 1]),\n )\n\n # Precompute the simpson quadrature for the entire domain.\n # This is done to avoid computing it for each subinterval of integration.\n quadrature = scipy.integrate.", "reference": "quadrature=scipy.integrate.simpson(np.identity(n_points),x=basis.grid_points[0],)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "quadrature=scipy.integrate.simpson(np.identity(n_points),x=basis.grid_points[0],)", "y_neg": " quadrature = scipy.integrate.simps(evaluated_basis, domain_limits[:, 0], domain_limits[:, 1])", "retain": "def gridbasis_penalty_matrix_optimized(\n linear_operator: LinearDifferentialOperator,\n basis: _GridBasis,\n) -> NDArrayFloat:\n \"\"\"\n Optimized version for GridBasis.\n\n It evaluates the operator in the grid points.\n \"\"\"\n n_points = basis.grid_points[0].shape[0]\n findiff_accuracy = 2\n\n evaluated_basis, domain_limits = _optimized_operator_evaluation_in_grid(\n linear_operator,\n basis.grid_points[0],\n findiff_accuracy=findiff_accuracy,\n )\n\n # If the operator does not have constant weights, the\n # optimized evaluation is not implemented.\n if evaluated_basis is NotImplemented:\n return NotImplemented\n\n # The support of the result of applying the linear operator\n # is a small subset of the grid points. We calculate the\n # maximum number of points to the left and right of the\n # point where the linear operator is applied that can be\n # different from zero.\n\n max_domain_width = np.max(\n np.abs(domain_limits[:, 0] - domain_limits[:, 1]),\n )\n\n # Precompute the simpson quadrature for the entire domain.\n # This is done to avoid computing it for each subinterval of integration.\n quadrature = scipy.integrate.simpson(\n np.identity(n_points),\n x=basis.grid_points[0],\n )\n\n product_matrix = np.zeros((basis.n_basis, basis.n_basis))\n for i in range(n_points):\n # Maximum index of another function with not-disjoint support\n max_no_disjoint_index = min(n_points, i + 2 * max_domain_width)\n\n for j in range(i, max_no_disjoint_index):\n if domain_limits[i, 1] < domain_limits[j, 0]:\n continue\n\n left_lim = min(\n domain_limits[i, 0],\n domain_limits[j, 0],\n )\n right_lim = max(\n domain_limits[i, 1],\n domain_limits[j, 1],\n )\n\n # The right limit of the interval is excluded when slicing\n right_lim += 1\n\n # Limit both the multiplication and the integration to\n # the interval where the functions are not 0.\n operator_product = (\n evaluated_basis[i, left_lim:right_lim]\n * evaluated_basis[j, left_lim:right_lim]\n )\n sub_quadrature = quadrature[left_lim:right_lim]\n\n product_matrix[i, j] = np.dot(operator_product, sub_quadrature)\n product_matrix[j, i] = product_matrix[i, j]\n\n return product_matrix" }, { "id": 10583, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def _pairwise_fem_inner_product(\n basis_fd: FData,\n fd: FData,\n y_val: float,\n grid: NDArrayFloat,\n) -> NDArrayFloat:\n\n eval_grid_fem = np.concatenate(\n (\n grid[:, None],\n np.full(\n shape=(len(grid), 1),\n fill_value=y_val,\n ),\n ),\n axis=1,\n )\n\n eval_fem = basis_fd(eval_grid_fem)\n eval_fd = fd(grid)\n\n prod = eval_fem * eval_fd\n integral = scipy.integrate.simpson(prod, x=grid, axis=1)\n return np.sum(integral, axis=-1)", "probing input": "def _pairwise_fem_inner_product(\n basis_fd: FData,\n fd: FData,\n y_val: float,\n grid: NDArrayFloat,\n) -> NDArrayFloat:\n\n eval_grid_fem = np.concatenate(\n (\n grid[:, None],\n np.full(\n shape=(len(grid), 1),\n fill_value=y_val,\n ),\n ),\n axis=1,\n )\n\n eval_fem = basis_fd(eval_grid_fem)\n eval_fd = fd(grid)\n\n prod = eval_fem * eval_fd\n", "probing input new": "def _pairwise_fem_inner_product(\n basis_fd: FData,\n fd: FData,\n y_val: float,\n grid: NDArrayFloat,\n) -> NDArrayFloat:\n\n eval_grid_fem = np.concatenate(\n (\n grid[:, None],\n np.full(\n shape=(len(grid), 1),\n fill_value=y_val,\n ),\n ),\n axis=1,\n )\n\n eval_fem = basis_fd(eval_grid_fem)\n eval_fd = fd(grid)\n\n prod = eval_fem * eval_fd\n integral = scipy.integrate.", "reference": "integral=scipy.integrate.simpson(prod,x=grid,axis=1)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "integral=scipy.integrate.simpson(prod,x=grid,axis=1)", "y_neg": " integral = scipy.integrate.simps(prod, grid)", "retain": "def _pairwise_fem_inner_product(\n basis_fd: FData,\n fd: FData,\n y_val: float,\n grid: NDArrayFloat,\n) -> NDArrayFloat:\n\n eval_grid_fem = np.concatenate(\n (\n grid[:, None],\n np.full(\n shape=(len(grid), 1),\n fill_value=y_val,\n ),\n ),\n axis=1,\n )\n\n eval_fem = basis_fd(eval_grid_fem)\n eval_fd = fd(grid)\n\n prod = eval_fem * eval_fd\n integral = scipy.integrate.simpson(prod, x=grid, axis=1)\n return np.sum(integral, axis=-1)" }, { "id": 10585, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def broadband_albedo(\n wavelength: ArrayOrScalar,\n totflux: ArrayOrScalar,\n dir_frac: ArrayOrScalar,\n SSA: ArrayOrScalar,\n **kwargs,\n):\n \"\"\"compute the broadband albedo of a snowpack specified by the profiles of SSA and density using TARTES. Refer to\n the :py:func:`albedo` function for a detailed description of the parameters.\n\n To compute the totflux and dir_frac for a simple atmosphere, see :py:func:`atmospheric_incident_spectrum` function\n provided in this package.\n\n :param wavelength: wavelength (m)\n :type wavelength: array\n :param totflux: spectrum of incident direct+diffuse radiation at the surface\n :param dir_frac: spectrum of fraction of the direct radiation\n :param SSA: surface specific area (m^2/kg) for each layer\n :type SSA: array\n :param **kwagrs: all the other optional parametres of the :py:func:`albedo` function\n\n :returns: broadband albedo\n \"\"\"\n\n kwargs[\"return_dir_diff\"] = True\n dir_frac = np.atleast_1d(dir_frac)\n totflux = np.atleast_1d(totflux)\n\n albedo_dir, albedo_diff = albedo(wavelength, SSA, dir_frac=dir_frac, **kwargs)\n\n broadband_albedo = scipy.integrate.simpson(\n totflux * (dir_frac * albedo_dir + (1.0 - dir_frac) * albedo_diff), x=wavelength\n ) / scipy.integrate.simpson(totflux, x=wavelength)\n\n return broadband_albedo", "probing input": "def broadband_albedo(\n wavelength: ArrayOrScalar,\n totflux: ArrayOrScalar,\n dir_frac: ArrayOrScalar,\n SSA: ArrayOrScalar,\n **kwargs,\n):\n \"\"\"compute the broadband albedo of a snowpack specified by the profiles of SSA and density using TARTES. Refer to\n the :py:func:`albedo` function for a detailed description of the parameters.\n\n To compute the totflux and dir_frac for a simple atmosphere, see :py:func:`atmospheric_incident_spectrum` function\n provided in this package.\n\n :param wavelength: wavelength (m)\n :type wavelength: array\n :param totflux: spectrum of incident direct+diffuse radiation at the surface\n :param dir_frac: spectrum of fraction of the direct radiation\n :param SSA: surface specific area (m^2/kg) for each layer\n :type SSA: array\n :param **kwagrs: all the other optional parametres of the :py:func:`albedo` function\n\n :returns: broadband albedo\n \"\"\"\n\n kwargs[\"return_dir_diff\"] = True\n dir_frac = np.atleast_1d(dir_frac)\n totflux = np.atleast_1d(totflux)\n\n albedo_dir, albedo_diff = albedo(wavelength, SSA, dir_frac=dir_frac, **kwargs)\n\n", "probing input new": "def broadband_albedo(\n wavelength: ArrayOrScalar,\n totflux: ArrayOrScalar,\n dir_frac: ArrayOrScalar,\n SSA: ArrayOrScalar,\n **kwargs,\n):\n \"\"\"compute the broadband albedo of a snowpack specified by the profiles of SSA and density using TARTES. Refer to\n the :py:func:`albedo` function for a detailed description of the parameters.\n\n To compute the totflux and dir_frac for a simple atmosphere, see :py:func:`atmospheric_incident_spectrum` function\n provided in this package.\n\n :param wavelength: wavelength (m)\n :type wavelength: array\n :param totflux: spectrum of incident direct+diffuse radiation at the surface\n :param dir_frac: spectrum of fraction of the direct radiation\n :param SSA: surface specific area (m^2/kg) for each layer\n :type SSA: array\n :param **kwagrs: all the other optional parametres of the :py:func:`albedo` function\n\n :returns: broadband albedo\n \"\"\"\n\n kwargs[\"return_dir_diff\"] = True\n dir_frac = np.atleast_1d(dir_frac)\n totflux = np.atleast_1d(totflux)\n\n albedo_dir, albedo_diff = albedo(wavelength, SSA, dir_frac=dir_frac, **kwargs)\n\n broadband_albedo = scipy.integrate.", "reference": "broadband_albedo=scipy.integrate.simpson(totflux*(dir_frac*albedo_dir+(1.0-dir_frac)*albedo_diff),x=wavelength)/scipy.integrate.simpson(totflux,x=wavelength)", "reference dict": {}, "alias dict": { "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "broadband_albedo=scipy.integrate.simpson(totflux*(dir_frac*albedo_dir+(1.0-dir_frac)*albedo_diff),x=wavelength)/scipy.integrate.simpson(totflux,x=wavelength)", "y_neg": " broadband_albedo = scipy.integrate.simps(albedo_dir, x=wavelength)", "retain": "def broadband_albedo(\n wavelength: ArrayOrScalar,\n totflux: ArrayOrScalar,\n dir_frac: ArrayOrScalar,\n SSA: ArrayOrScalar,\n **kwargs,\n):\n \"\"\"compute the broadband albedo of a snowpack specified by the profiles of SSA and density using TARTES. Refer to\n the :py:func:`albedo` function for a detailed description of the parameters.\n\n To compute the totflux and dir_frac for a simple atmosphere, see :py:func:`atmospheric_incident_spectrum` function\n provided in this package.\n\n :param wavelength: wavelength (m)\n :type wavelength: array\n :param totflux: spectrum of incident direct+diffuse radiation at the surface\n :param dir_frac: spectrum of fraction of the direct radiation\n :param SSA: surface specific area (m^2/kg) for each layer\n :type SSA: array\n :param **kwagrs: all the other optional parametres of the :py:func:`albedo` function\n\n :returns: broadband albedo\n \"\"\"\n\n kwargs[\"return_dir_diff\"] = True\n dir_frac = np.atleast_1d(dir_frac)\n totflux = np.atleast_1d(totflux)\n\n albedo_dir, albedo_diff = albedo(wavelength, SSA, dir_frac=dir_frac, **kwargs)\n\n broadband_albedo = scipy.integrate.simpson(\n totflux * (dir_frac * albedo_dir + (1.0 - dir_frac) * albedo_diff), x=wavelength\n ) / scipy.integrate.simpson(totflux, x=wavelength)\n\n return broadband_albedo" }, { "id": 10590, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def generateSpline(points : np.ndarray, k=3, simpson_subintervals = 12):\n if not (simpson_subintervals%2)==0:\n raise ValueError(\"Must use even number of subintervals for Simpson's method\")\n # points_aug : np.ndarray = points[:-1].copy()\n if np.linalg.norm(points[-1]-points[0], ord=2)>1E-6:\n points_aug = np.concatenate([points, points[None,0]], axis=0)\n else:\n points_aug = points.copy()\n euclidean_distances : np.ndarray = np.zeros_like(points_aug[:,0])\n euclidean_distances[1:] = np.cumsum(np.linalg.norm(points_aug[1:] - points_aug[:-1], ord=2, axis=1))\n splinex = euclidean_distances\n\n fake_spline : scipy.interpolate.BSpline = scipy.interpolate.make_interp_spline(splinex, points_aug, k=k, bc_type=\"periodic\")\n fake_spline_der : scipy.interpolate.BSpline = fake_spline.derivative()\n\n true_distances : np.ndarray = np.zeros_like(splinex)\n for i in range(1, true_distances.shape[0]):\n x0 = splinex[i-1]\n x1 = splinex[i]\n xvec : np.ndarray = np.linspace(x0, x1, simpson_subintervals + 1)\n spline_norms : np.ndarray = np.linalg.norm(fake_spline_der(xvec), ord=2.0, axis=1)\n true_distances[i] = true_distances[i-1] + scipy.integrate.simpson(spline_norms, xvec)\n return true_distances, points_aug, scipy.interpolate.make_interp_spline(true_distances, points_aug, k=k, bc_type=\"periodic\")", "probing input": "def generateSpline(points : np.ndarray, k=3, simpson_subintervals = 12):\n if not (simpson_subintervals%2)==0:\n raise ValueError(\"Must use even number of subintervals for Simpson's method\")\n # points_aug : np.ndarray = points[:-1].copy()\n if np.linalg.norm(points[-1]-points[0], ord=2)>1E-6:\n points_aug = np.concatenate([points, points[None,0]], axis=0)\n else:\n points_aug = points.copy()\n euclidean_distances : np.ndarray = np.zeros_like(points_aug[:,0])\n euclidean_distances[1:] = np.cumsum(np.linalg.norm(points_aug[1:] - points_aug[:-1], ord=2, axis=1))\n splinex = euclidean_distances\n\n fake_spline : scipy.interpolate.BSpline = scipy.interpolate.make_interp_spline(splinex, points_aug, k=k, bc_type=\"periodic\")\n fake_spline_der : scipy.interpolate.BSpline = fake_spline.derivative()\n\n true_distances : np.ndarray = np.zeros_like(splinex)\n for i in range(1, true_distances.shape[0]):\n x0 = splinex[i-1]\n x1 = splinex[i]\n xvec : np.ndarray = np.linspace(x0, x1, simpson_subintervals + 1)\n spline_norms : np.ndarray = np.linalg.norm(fake_spline_der(xvec), ord=2.0, axis=1)\n", "probing input new": "def generateSpline(points : np.ndarray, k=3, simpson_subintervals = 12):\n if not (simpson_subintervals%2)==0:\n raise ValueError(\"Must use even number of subintervals for Simpson's method\")\n # points_aug : np.ndarray = points[:-1].copy()\n if np.linalg.norm(points[-1]-points[0], ord=2)>1E-6:\n points_aug = np.concatenate([points, points[None,0]], axis=0)\n else:\n points_aug = points.copy()\n euclidean_distances : np.ndarray = np.zeros_like(points_aug[:,0])\n euclidean_distances[1:] = np.cumsum(np.linalg.norm(points_aug[1:] - points_aug[:-1], ord=2, axis=1))\n splinex = euclidean_distances\n\n fake_spline : scipy.interpolate.BSpline = scipy.interpolate.make_interp_spline(splinex, points_aug, k=k, bc_type=\"periodic\")\n fake_spline_der : scipy.interpolate.BSpline = fake_spline.derivative()\n\n true_distances : np.ndarray = np.zeros_like(splinex)\n for i in range(1, true_distances.shape[0]):\n x0 = splinex[i-1]\n x1 = splinex[i]\n xvec : np.ndarray = np.linspace(x0, x1, simpson_subintervals + 1)\n spline_norms : np.ndarray = np.linalg.norm(fake_spline_der(xvec), ord=2.0, axis=1)\n true_distances[i] = true_distances[i-1] + scipy.integrate.", "reference": "true_distances[i]=true_distances[i-1]+scipy.integrate.simpson(spline_norms,xvec)", "reference dict": {}, "alias dict": { "Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.linalg.pinv2": "scipy.linalg.pinv2" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "true_distances[i]=true_distances[i-1]+scipy.integrate.simpson(spline_norms,xvec)", "y_neg": " true_distances[i] = true_distances[i-1] + scipy.integrate.simps(spline_norms, xvec)", "retain": "def generateSpline(points : np.ndarray, k=3, simpson_subintervals = 12):\n if not (simpson_subintervals%2)==0:\n raise ValueError(\"Must use even number of subintervals for Simpson's method\")\n # points_aug : np.ndarray = points[:-1].copy()\n if np.linalg.norm(points[-1]-points[0], ord=2)>1E-6:\n points_aug = np.concatenate([points, points[None,0]], axis=0)\n else:\n points_aug = points.copy()\n euclidean_distances : np.ndarray = np.zeros_like(points_aug[:,0])\n euclidean_distances[1:] = np.cumsum(np.linalg.norm(points_aug[1:] - points_aug[:-1], ord=2, axis=1))\n splinex = euclidean_distances\n\n fake_spline : scipy.interpolate.BSpline = scipy.interpolate.make_interp_spline(splinex, points_aug, k=k, bc_type=\"periodic\")\n fake_spline_der : scipy.interpolate.BSpline = fake_spline.derivative()\n\n true_distances : np.ndarray = np.zeros_like(splinex)\n for i in range(1, true_distances.shape[0]):\n x0 = splinex[i-1]\n x1 = splinex[i]\n xvec : np.ndarray = np.linspace(x0, x1, simpson_subintervals + 1)\n spline_norms : np.ndarray = np.linalg.norm(fake_spline_der(xvec), ord=2.0, axis=1)\n true_distances[i] = true_distances[i-1] + scipy.integrate.simpson(spline_norms, xvec)\n return true_distances, points_aug, scipy.interpolate.make_interp_spline(true_distances, points_aug, k=k, bc_type=\"periodic\")" }, { "id": 10591, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": " def integrate(self, start=None, end=None, method='simps'):\n \"\"\"Compute the integrated value between ``start`` and ``end``.\n\n Parameters\n ----------\n start : float, optional\n Lower wavelength bound. If not specified (default),\n ``min(self.wave)`` is used.\n end : float, optional\n Upper wavelength bound. If not specified (default),\n ``max(self.wave)`` is used.\n method : {'simps', 'trapz'}, optional\n Numerical integration method. 'simps' (default) is better for smooth\n data while 'trapz' is better for linear data.\n\n Returns\n -------\n result : float\n Integral as approximated by ``interp_method``\n\n \"\"\"\n if start is None:\n start = np.min(self.wave)\n if end is None:\n end = np.max(self.wave)\n\n indices = np.intersect1d(np.where(self.wave >= start),\n np.where(self.wave <= end))\n wave = self.wave[indices]\n value = self.value[indices]\n\n if method == 'simps':\n result = scipy.integrate.simpson(x=wave, y=value)\n elif method == 'trapz':\n result = np.trapz(value, wave)\n else:\n raise ValueError('Unknown method ', method)\n\n return result", "probing input": " def integrate(self, start=None, end=None, method='simps'):\n \"\"\"Compute the integrated value between ``start`` and ``end``.\n\n Parameters\n ----------\n start : float, optional\n Lower wavelength bound. If not specified (default),\n ``min(self.wave)`` is used.\n end : float, optional\n Upper wavelength bound. If not specified (default),\n ``max(self.wave)`` is used.\n method : {'simps', 'trapz'}, optional\n Numerical integration method. 'simps' (default) is better for smooth\n data while 'trapz' is better for linear data.\n\n Returns\n -------\n result : float\n Integral as approximated by ``interp_method``\n\n \"\"\"\n if start is None:\n start = np.min(self.wave)\n if end is None:\n end = np.max(self.wave)\n\n indices = np.intersect1d(np.where(self.wave >= start),\n np.where(self.wave <= end))\n wave = self.wave[indices]\n value = self.value[indices]\n\n if method == 'simps':\n", "probing input new": " def integrate(self, start=None, end=None, method='simps'):\n \"\"\"Compute the integrated value between ``start`` and ``end``.\n\n Parameters\n ----------\n start : float, optional\n Lower wavelength bound. If not specified (default),\n ``min(self.wave)`` is used.\n end : float, optional\n Upper wavelength bound. If not specified (default),\n ``max(self.wave)`` is used.\n method : {'simps', 'trapz'}, optional\n Numerical integration method. 'simps' (default) is better for smooth\n data while 'trapz' is better for linear data.\n\n Returns\n -------\n result : float\n Integral as approximated by ``interp_method``\n\n \"\"\"\n if start is None:\n start = np.min(self.wave)\n if end is None:\n end = np.max(self.wave)\n\n indices = np.intersect1d(np.where(self.wave >= start),\n np.where(self.wave <= end))\n wave = self.wave[indices]\n value = self.value[indices]\n\n if method == 'simps':\n result = scipy.integrate.", "reference": "result=scipy.integrate.simpson(x=wave,y=value)", "reference dict": {}, "alias dict": { "scipy.datasets.face": "scipy.datasets.face", "scipy.misc.factorial2": "scipy.misc.factorial2", "scipy.integrate.quad": "scipy.integrate.quad", "scipy.stats.betai": "scipy.stats.betai", "scipy.integrate.quadrature": "scipy.integrate.quadrature", "scipy.signal.cubic": "scipy.signal.cubic", "scipy.spatial.transform.Rotation.as_dcm": "scipy.spatial.transform.Rotation.as_dcm", "scipy.integrate.trapz": "scipy.integrate.trapz", "scipy.misc.comb": "scipy.misc.comb", "scipy.linalg.pinv": "scipy.linalg.pinv", "scipy.stats.binned_statistic": "scipy.stats.binned_statistic", "scipy.integrate.simps": "scipy.integrate.simps", "scipy.interpolate.BSpline": "scipy.interpolate.BSpline", "scipy.special.factorial": "scipy.special.factorial", "scipy.spatial.transform.Rotation.match_vectors": "scipy.spatial.transform.Rotation.match_vectors", "scipy.spatial.distance.wminkowski": "scipy.spatial.distance.wminkowski", "scipy.integrate.romberg": "scipy.integrate.romberg", "scipy.signal.quadratic": "scipy.signal.quadratic", "scipy.stats.rvs_ratio_uniforms": "scipy.stats.rvs_ratio_uniforms", "scipy.spatial.distance.minkowski": "scipy.spatial.distance.minkowski", "scipy.stats.itemfreq": "scipy.stats.itemfreq", "scipy.integrate.cumtrapz": "scipy.integrate.cumtrapz", "scipy.misc.factorial": "scipy.misc.factorial", "scipy.datasets.ascent": "scipy.datasets.ascent", "scipy.integrate.simpson": "scipy.integrate.simpson", "scipy.signal.windows.hann": "scipy.signal.windows.hann", "scipy.misc.ascent": "scipy.misc.ascent", "scipy.interpolate.bisplev": "scipy.interpolate.bisplev", "scipy.special.spherical_yn": "scipy.special.spherical_yn", "scipy.integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scipy.linalg.pinv2": "scipy.linalg.pinv2", "scipy.special.comb": "scipy.special.comb", "scipy.misc.face": "scipy.misc.face", "scipy.stats.sampling.RatioUniforms": "scipy.stats.sampling.RatioUniforms", "scipy.stats.chi2.sf": "scipy.stats.chi2.sf", "scipy.stats.chisqprob": "scipy.stats.chisqprob", "scipy.special.seterr": "scipy.special.seterr", "scipy.spatial.transform.Rotation.as_matrix": "scipy.spatial.transform.Rotation.as_matrix", "scipy.special.logsumexp": "scipy.special.logsumexp", "scipy.datasets.electrocardiogram": "scipy.datasets.electrocardiogram", "scipy.signal.hanning": "scipy.signal.hanning", "scipy.integrate.trapezoid": "scipy.integrate.trapezoid", "scipy.special.factorial2": "scipy.special.factorial2", "scipy.spatial.transform.Rotation.align_vectors": "scipy.spatial.transform.Rotation.align_vectors", "scipy.special.betainc": "scipy.special.betainc", "scipy.signal.bspline": "scipy.signal.bspline", "scipy.special.sph_yn": "scipy.special.sph_yn", "scipy.special.errprint": "scipy.special.errprint", "scipy.misc.logsumexp": "scipy.misc.logsumexp", "scipy.misc.electrocardiogram": "scipy.misc.electrocardiogram", "scipy.interpolate.interp2d": "scipy.interpolate.interp2d", "scipy.special.sph_jn": "scipy.special.sph_jn", "scipy.special.spherical_jn": "scipy.special.spherical_jn" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "scipy.integrate.simpson", "y_pos": "result=scipy.integrate.simpson(x=wave,y=value)", "y_neg": " result = scipy.integrate.simps(value, wave)", "retain": " def integrate(self, start=None, end=None, method='simps'):\n \"\"\"Compute the integrated value between ``start`` and ``end``.\n\n Parameters\n ----------\n start : float, optional\n Lower wavelength bound. If not specified (default),\n ``min(self.wave)`` is used.\n end : float, optional\n Upper wavelength bound. If not specified (default),\n ``max(self.wave)`` is used.\n method : {'simps', 'trapz'}, optional\n Numerical integration method. 'simps' (default) is better for smooth\n data while 'trapz' is better for linear data.\n\n Returns\n -------\n result : float\n Integral as approximated by ``interp_method``\n\n \"\"\"\n if start is None:\n start = np.min(self.wave)\n if end is None:\n end = np.max(self.wave)\n\n indices = np.intersect1d(np.where(self.wave >= start),\n np.where(self.wave <= end))\n wave = self.wave[indices]\n value = self.value[indices]\n\n if method == 'simps':\n result = scipy.integrate.simpson(x=wave, y=value)\n elif method == 'trapz':\n result = np.trapz(value, wave)\n else:\n raise ValueError('Unknown method ', method)\n\n return result" }, { "id": 10597, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def simpsons_rule(x, y):\n global nparray_x, nparray_y, result\n nparray_x = np.append(nparray_x, x)\n nparray_y = np.append(nparray_y, y)\n result = integrate.simpson(nparray_y, nparray_x)\n return result", "probing input": "def simpsons_rule(x, y):\n global nparray_x, nparray_y, result\n nparray_x = np.append(nparray_x, x)\n nparray_y = np.append(nparray_y, y)\n", "probing input new": "def simpsons_rule(x, y):\n global nparray_x, nparray_y, result\n nparray_x = np.append(nparray_x, x)\n nparray_y = np.append(nparray_y, y)\n result = integrate.", "reference": "result=integrate.simpson(nparray_y,nparray_x)", "reference dict": {}, "alias dict": { "integrate.quad": "scipy.integrate.quad", "integrate.romberg": "scipy.integrate.romberg", "integrate.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "integrate.quadrature": "scipy.integrate.quadrature", "integrate.trapezoid": "scipy.integrate.trapezoid", "integrate.cumtrapz": "scipy.integrate.cumtrapz", "integrate.trapz": "scipy.integrate.trapz", "integrate.simpson": "scipy.integrate.simpson", "integrate.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.simps" ], "replacement api": "scipy.integrate.simpson", "expected call": "integrate.simpson", "y_pos": "result=integrate.simpson(nparray_y,nparray_x)", "y_neg": " result = integrate.simps(nparray_y, nparray_x)", "retain": "def simpsons_rule(x, y):\n global nparray_x, nparray_y, result\n nparray_x = np.append(nparray_x, x)\n nparray_y = np.append(nparray_y, y)\n result = integrate.simpson(nparray_y, nparray_x)\n return result" }, { "id": 10631, "library": "scipy", "category": "up-to-dated", "source": "sourcegraph", "function": "def integrate_local_pattern(values, ax_val, index):\n \"\"\"Returns the local integral of values along given axis (does not change the axis)\n\n Parameters\n ----------\n values: ndarray\n array to derivate\n ax_val: ndarray\n axis values\n index: int\n index of axis along which to derivate\n Nper: int\n number of periods to replicate\n is_aper: bool\n True if values is anti-periodic along axis\n is_phys: bool\n True if physical quantity (time/angle/z)\n is_freqs: bool\n True if frequency axis\n\n Returns\n -------\n values_integ: ndarray\n local integration of values\n \"\"\"\n\n if ax_val.size > 1:\n # Swap axis to always have integration axis on 1st position\n values = np.swapaxes(values, index, 0)\n\n # Init output arrays\n shape = list(values.shape[1:])\n shape.insert(0, values.shape[0] - 1)\n values_int = np.zeros(shape, dtype=values.dtype)\n ax_int = np.zeros(shape[0])\n\n # Trapezoidal integration on each segment and calculate position of each segment middle\n for ii in range(shape[0]):\n values_int[ii, ...] = scp_int.trapezoid(\n values[ii : ii + 2, ...], x=ax_val[ii : ii + 2], axis=0\n )\n ax_int[ii] = np.mean(ax_val[ii : ii + 2])\n\n # Remove zero length interval\n Ia = np.nonzero(np.diff(ax_val))[0]\n values_int = values_int[Ia, ...]\n ax_int = ax_int[Ia]\n\n values_int = np.swapaxes(values_int, index, 0)\n\n else:\n raise Exception(\"Cannot locally integrate along axis if axis size is 1\")\n\n return values_int, ax_int", "probing input": "def integrate_local_pattern(values, ax_val, index):\n \"\"\"Returns the local integral of values along given axis (does not change the axis)\n\n Parameters\n ----------\n values: ndarray\n array to derivate\n ax_val: ndarray\n axis values\n index: int\n index of axis along which to derivate\n Nper: int\n number of periods to replicate\n is_aper: bool\n True if values is anti-periodic along axis\n is_phys: bool\n True if physical quantity (time/angle/z)\n is_freqs: bool\n True if frequency axis\n\n Returns\n -------\n values_integ: ndarray\n local integration of values\n \"\"\"\n\n if ax_val.size > 1:\n # Swap axis to always have integration axis on 1st position\n values = np.swapaxes(values, index, 0)\n\n # Init output arrays\n shape = list(values.shape[1:])\n shape.insert(0, values.shape[0] - 1)\n values_int = np.zeros(shape, dtype=values.dtype)\n ax_int = np.zeros(shape[0])\n\n # Trapezoidal integration on each segment and calculate position of each segment middle\n for ii in range(shape[0]):\n", "probing input new": "def integrate_local_pattern(values, ax_val, index):\n \"\"\"Returns the local integral of values along given axis (does not change the axis)\n\n Parameters\n ----------\n values: ndarray\n array to derivate\n ax_val: ndarray\n axis values\n index: int\n index of axis along which to derivate\n Nper: int\n number of periods to replicate\n is_aper: bool\n True if values is anti-periodic along axis\n is_phys: bool\n True if physical quantity (time/angle/z)\n is_freqs: bool\n True if frequency axis\n\n Returns\n -------\n values_integ: ndarray\n local integration of values\n \"\"\"\n\n if ax_val.size > 1:\n # Swap axis to always have integration axis on 1st position\n values = np.swapaxes(values, index, 0)\n\n # Init output arrays\n shape = list(values.shape[1:])\n shape.insert(0, values.shape[0] - 1)\n values_int = np.zeros(shape, dtype=values.dtype)\n ax_int = np.zeros(shape[0])\n\n # Trapezoidal integration on each segment and calculate position of each segment middle\n for ii in range(shape[0]):\n values_int[ii, ...] = scp_int.", "reference": "values_int[ii,...]=scp_int.trapezoid(values[ii:ii+2,...],x=ax_val[ii:ii+2],axis=0)", "reference dict": {}, "alias dict": { "scp_int.quad": "scipy.integrate.quad", "scp_int.romberg": "scipy.integrate.romberg", "scp_int.cumulative_trapezoid": "scipy.integrate.cumulative_trapezoid", "scp_int.quadrature": "scipy.integrate.quadrature", "scp_int.trapezoid": "scipy.integrate.trapezoid", "scp_int.cumtrapz": "scipy.integrate.cumtrapz", "scp_int.trapz": "scipy.integrate.trapz", "scp_int.simpson": "scipy.integrate.simpson", "scp_int.simps": "scipy.integrate.simps" }, "deprecated api": [ "scipy.integrate.trapz" ], "replacement api": "scipy.integrate.trapezoid", "expected call": "scp_int.trapezoid", "y_pos": "values_int[ii,...]=scp_int.trapezoid(values[ii:ii+2,...],x=ax_val[ii:ii+2],axis=0)", "y_neg": " values_int[ii, ...] = scp_int.trapz(values[ii, ...], ax_val[ii, ...], axis=0)", "retain": "def integrate_local_pattern(values, ax_val, index):\n \"\"\"Returns the local integral of values along given axis (does not change the axis)\n\n Parameters\n ----------\n values: ndarray\n array to derivate\n ax_val: ndarray\n axis values\n index: int\n index of axis along which to derivate\n Nper: int\n number of periods to replicate\n is_aper: bool\n True if values is anti-periodic along axis\n is_phys: bool\n True if physical quantity (time/angle/z)\n is_freqs: bool\n True if frequency axis\n\n Returns\n -------\n values_integ: ndarray\n local integration of values\n \"\"\"\n\n if ax_val.size > 1:\n # Swap axis to always have integration axis on 1st position\n values = np.swapaxes(values, index, 0)\n\n # Init output arrays\n shape = list(values.shape[1:])\n shape.insert(0, values.shape[0] - 1)\n values_int = np.zeros(shape, dtype=values.dtype)\n ax_int = np.zeros(shape[0])\n\n # Trapezoidal integration on each segment and calculate position of each segment middle\n for ii in range(shape[0]):\n values_int[ii, ...] = scp_int.trapezoid(\n values[ii : ii + 2, ...], x=ax_val[ii : ii + 2], axis=0\n )\n ax_int[ii] = np.mean(ax_val[ii : ii + 2])\n\n # Remove zero length interval\n Ia = np.nonzero(np.diff(ax_val))[0]\n values_int = values_int[Ia, ...]\n ax_int = ax_int[Ia]\n\n values_int = np.swapaxes(values_int, index, 0)\n\n else:\n raise Exception(\"Cannot locally integrate along axis if axis size is 1\")\n\n return values_int, ax_int" }, { "id": 11103, "library": "seaborn", "category": "up-to-dated", "source": "sourcegraph", "function": "def visualize(result, name):\n # (N_samples=5, timesteps=200, types)\n result = np.array(result)\n assert result.shape[2] == 2\n # ax = sns.tsplot(data=result, condition=['OptNet', 'Adam'], linestyle='--')\n\n def trans(series):\n # (N_samples, timesteps)\n x = np.tile(np.arange(series.shape[1]) + 1,\n (series.shape[0], 1)).flatten()\n y = series.flatten()\n return {'x': x, 'y': y}\n ax = sns.lineplot(label='OptNet', **trans(result[:, :, 0]))\n ax = sns.lineplot(label='Adam', ax=ax, **trans(result[:, :, 1]))\n ax.lines[-1].set_linestyle('-')\n ax.legend()\n plt.yscale('log'), plt.xlabel('steps')\n plt.ylabel('loss'), plt.title('MNIST')\n plt.ylim(0.09, 3.0)\n plt.xlim(1, result.shape[1])\n plt.grid(which='both', alpha=0.6, color='black', linewidth=0.1,\n linestyle='-')\n ax.tick_params(which='both', direction='in')\n ax.tick_params(which='major', length=8)\n ax.tick_params(which='minor', length=3)\n ax.xaxis.set_minor_locator(AutoMinorLocator(5))\n\n plt.show()\n plt.savefig(name)\n plt.close()", "probing input": "def visualize(result, name):\n # (N_samples=5, timesteps=200, types)\n result = np.array(result)\n assert result.shape[2] == 2\n # ax = sns.tsplot(data=result, condition=['OptNet', 'Adam'], linestyle='--')\n\n def trans(series):\n # (N_samples, timesteps)\n x = np.tile(np.arange(series.shape[1]) + 1,\n (series.shape[0], 1)).flatten()\n y = series.flatten()\n return {'x': x, 'y': y}\n", "probing input new": "def visualize(result, name):\n # (N_samples=5, timesteps=200, types)\n result = np.array(result)\n assert result.shape[2] == 2\n # ax = sns.tsplot(data=result, condition=['OptNet', 'Adam'], linestyle='--')\n\n def trans(series):\n # (N_samples, timesteps)\n x = np.tile(np.arange(series.shape[1]) + 1,\n (series.shape[0], 1)).flatten()\n y = series.flatten()\n return {'x': x, 'y': y}\n ax = sns.", "reference": "ax=sns.lineplot(label='OptNet',**trans(result[:,:,0]))", "reference dict": { "handler": "StreamHandler" }, "alias dict": { "sns.set_color_palette": "seaborn.set_color_palette", "sns.tsplot": "seaborn.tsplot", "sns.palette_context": "seaborn.palette_context", "sns.utils.despine": "seaborn.utils.despine", "sns.boxenplot": "seaborn.boxenplot", "sns.set_palette": "seaborn.set_palette", "sns.JointGrid.annotate": "seaborn.JointGrid.annotate", "sns.lineplot": "seaborn.lineplot", "sns.JointGrid.plot_joint": "seaborn.JointGrid.plot_joint", "sns.despine": "seaborn.despine", "sns.catplot": "seaborn.catplot", "sns.color_palette": "seaborn.color_palette", "sns.JointGrid": "seaborn.JointGrid", "sns.JointGrid.plot": "seaborn.JointGrid.plot", "sns.lvplot": "seaborn.lvplot", "sns.factorplot": "seaborn.factorplot" }, "deprecated api": [ "seaborn.tsplot" ], "replacement api": "seaborn.lineplot", "expected call": "sns.lineplot", "y_pos": "ax=sns.lineplot(label='OptNet',**trans(result[:,:,0]))", "y_neg": " ax = sns.tsplot(data=[trans(result[:, 0]), trans(result[:, 1])],", "retain": "def visualize(result, name):\n # (N_samples=5, timesteps=200, types)\n result = np.array(result)\n assert result.shape[2] == 2\n # ax = sns.tsplot(data=result, condition=['OptNet', 'Adam'], linestyle='--')\n\n def trans(series):\n # (N_samples, timesteps)\n x = np.tile(np.arange(series.shape[1]) + 1,\n (series.shape[0], 1)).flatten()\n y = series.flatten()\n return {'x': x, 'y': y}\n ax = sns.lineplot(label='OptNet', **trans(result[:, :, 0]))\n ax = sns.lineplot(label='Adam', ax=ax, **trans(result[:, :, 1]))\n ax.lines[-1].set_linestyle('-')\n ax.legend()\n plt.yscale('log'), plt.xlabel('steps')\n plt.ylabel('loss'), plt.title('MNIST')\n plt.ylim(0.09, 3.0)\n plt.xlim(1, result.shape[1])\n plt.grid(which='both', alpha=0.6, color='black', linewidth=0.1,\n linestyle='-')\n ax.tick_params(which='both', direction='in')\n ax.tick_params(which='major', length=8)\n ax.tick_params(which='minor', length=3)\n ax.xaxis.set_minor_locator(AutoMinorLocator(5))\n\n plt.show()\n plt.savefig(name)\n plt.close()" }, { "id": 11380, "library": "seaborn", "category": "up-to-dated", "source": "sourcegraph", "function": " def plot(self, ax, cax, kws):\n \"\"\"Draw the heatmap on the provided Axes.\"\"\"\n # Remove all the Axes spines\n sns.utils.despine(ax=ax, left=True, bottom=True)\n\n # Draw the heatmap\n mesh = ax.pcolormesh(self.plot_data, vmin=self.vmin, vmax=self.vmax,\n cmap=self.cmap, **kws)\n\n # Set the axis limits\n ax.set(xlim=(0, self.data.shape[1]), ylim=(0, self.data.shape[0]))\n\n # Add row and column labels\n ax.set(xticks=self.xticks, yticks=self.yticks)\n xtl = ax.set_xticklabels(self.xticklabels)\n ytl = ax.set_yticklabels(self.yticklabels, rotation=\"vertical\", va='center')\n\n # Possibly rotate them if they overlap\n plt.draw()\n if sns.utils.axis_ticklabels_overlap(xtl):\n plt.setp(xtl, rotation=\"vertical\")\n if sns.utils.axis_ticklabels_overlap(ytl):\n plt.setp(ytl, rotation=\"horizontal\")\n\n # Add the axis labels\n ax.set(xlabel=self.xlabel, ylabel=self.ylabel)\n\n # Annotate the cells with the formatted values\n if self.annot:\n self._annotate_heatmap(ax, mesh)", "probing input": " def plot(self, ax, cax, kws):\n \"\"\"Draw the heatmap on the provided Axes.\"\"\"\n # Remove all the Axes spines\n", "probing input new": " def plot(self, ax, cax, kws):\n \"\"\"Draw the heatmap on the provided Axes.\"\"\"\n # Remove all the Axes spines\n sns.", "reference": "sns.utils.despine(ax=ax,left=True,bottom=True)", "reference dict": {}, "alias dict": { "sns.set_color_palette": "seaborn.set_color_palette", "sns.tsplot": "seaborn.tsplot", "sns.palette_context": "seaborn.palette_context", "sns.utils.despine": "seaborn.utils.despine", "sns.boxenplot": "seaborn.boxenplot", "sns.set_palette": "seaborn.set_palette", "sns.JointGrid.annotate": "seaborn.JointGrid.annotate", "sns.lineplot": "seaborn.lineplot", "sns.JointGrid.plot_joint": "seaborn.JointGrid.plot_joint", "sns.despine": "seaborn.despine", "sns.catplot": "seaborn.catplot", "sns.color_palette": "seaborn.color_palette", "sns.JointGrid": "seaborn.JointGrid", "sns.JointGrid.plot": "seaborn.JointGrid.plot", "sns.lvplot": "seaborn.lvplot", "sns.factorplot": "seaborn.factorplot" }, "deprecated api": [ "seaborn.despine" ], "replacement api": "seaborn.utils.despine", "expected call": "sns.utils.despine", "y_pos": "sns.utils.despine(ax=ax,left=True,bottom=True)", "y_neg": " sns.despine(ax)", "retain": " def plot(self, ax, cax, kws):\n \"\"\"Draw the heatmap on the provided Axes.\"\"\"\n # Remove all the Axes spines\n sns.utils.despine(ax=ax, left=True, bottom=True)\n\n # Draw the heatmap\n mesh = ax.pcolormesh(self.plot_data, vmin=self.vmin, vmax=self.vmax,\n cmap=self.cmap, **kws)\n\n # Set the axis limits\n ax.set(xlim=(0, self.data.shape[1]), ylim=(0, self.data.shape[0]))\n\n # Add row and column labels\n ax.set(xticks=self.xticks, yticks=self.yticks)\n xtl = ax.set_xticklabels(self.xticklabels)\n ytl = ax.set_yticklabels(self.yticklabels, rotation=\"vertical\", va='center')\n\n # Possibly rotate them if they overlap\n plt.draw()\n if sns.utils.axis_ticklabels_overlap(xtl):\n plt.setp(xtl, rotation=\"vertical\")\n if sns.utils.axis_ticklabels_overlap(ytl):\n plt.setp(ytl, rotation=\"horizontal\")\n\n # Add the axis labels\n ax.set(xlabel=self.xlabel, ylabel=self.ylabel)\n\n # Annotate the cells with the formatted values\n if self.annot:\n self._annotate_heatmap(ax, mesh)" }, { "id": 12109, "library": "sklearn", "category": "up-to-dated", "source": "sourcegraph", "function": "def learn_gmm(X, n_comp=5, covar='full'):\n \"\"\"\n Learn a Gaussian mixture model on features X,\n with 5 components and full covariance by default.\n\n Take\n X: data in N x K ndarray where N is no. samples and K is no. features\n n_comp: number of components in mixture model\n covar: covariance type ('full' or 'diag' most useful)\n\n Give\n gmm: a fitted sklearn GMM:\n http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n \"\"\"\n gmm = mixture.GaussianMixture(n_components=5, covariance_type='full')\n gmm.fit(X)\n return gmm", "probing input": "def learn_gmm(X, n_comp=5, covar='full'):\n \"\"\"\n Learn a Gaussian mixture model on features X,\n with 5 components and full covariance by default.\n\n Take\n X: data in N x K ndarray where N is no. samples and K is no. features\n n_comp: number of components in mixture model\n covar: covariance type ('full' or 'diag' most useful)\n\n Give\n gmm: a fitted sklearn GMM:\n http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n \"\"\"\n", "probing input new": "def learn_gmm(X, n_comp=5, covar='full'):\n \"\"\"\n Learn a Gaussian mixture model on features X,\n with 5 components and full covariance by default.\n\n Take\n X: data in N x K ndarray where N is no. samples and K is no. features\n n_comp: number of components in mixture model\n covar: covariance type ('full' or 'diag' most useful)\n\n Give\n gmm: a fitted sklearn GMM:\n http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n \"\"\"\n gmm = mixture.", "reference": "gmm=mixture.GaussianMixture(n_components=5,covariance_type='full')", "reference dict": { "gmm": "mixture.GaussianMixture" }, "alias dict": { "mixture.DPGMM": "sklearn.mixture.DPGMM", "mixture.BayesianGaussianMixture": "sklearn.mixture.BayesianGaussianMixture", "mixture.GMM": "sklearn.mixture.GMM", "mixture.GaussianMixture": "sklearn.mixture.GaussianMixture", "mixture.VBGMM": "sklearn.mixture.VBGMM" }, "deprecated api": [ "sklearn.mixture.GMM" ], "replacement api": "sklearn.mixture.GaussianMixture", "expected call": "mixture.GaussianMixture", "y_pos": "gmm=mixture.GaussianMixture(n_components=5,covariance_type='full')", "y_neg": " gmm = mixture.GMM(n_components=n_comp, covariance_type=covar)", "retain": "def learn_gmm(X, n_comp=5, covar='full'):\n \"\"\"\n Learn a Gaussian mixture model on features X,\n with 5 components and full covariance by default.\n\n Take\n X: data in N x K ndarray where N is no. samples and K is no. features\n n_comp: number of components in mixture model\n covar: covariance type ('full' or 'diag' most useful)\n\n Give\n gmm: a fitted sklearn GMM:\n http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n \"\"\"\n gmm = mixture.GaussianMixture(n_components=5, covariance_type='full')\n gmm.fit(X)\n return gmm" }, { "id": 12378, "library": "sklearn", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, n_mix=32, n_iter=100, covtype=\"full\"):\n self.n_mix = n_mix\n self.n_iter = n_iter\n self.covtype = covtype\n\n self.random_state = np.random.mtrand._rand\n\n # construct GMM parameter\n if self.covtype == \"full\":\n self.param = sklearn.mixture.GaussianMixture(\n n_components=self.n_mix,\n covariance_type=self.covtype,\n max_iter=self.n_iter,\n )\n elif self.covtype == \"block_diag\":\n self.param = BlockDiagonalGaussianMixture(\n n_mix=self.n_mix, n_iter=self.n_iter\n )\n else:\n raise ValueError(\"Covariance type should be full or block_diag\")", "probing input": " def __init__(self, n_mix=32, n_iter=100, covtype=\"full\"):\n self.n_mix = n_mix\n self.n_iter = n_iter\n self.covtype = covtype\n\n self.random_state = np.random.mtrand._rand\n\n # construct GMM parameter\n if self.covtype == \"full\":\n", "probing input new": " def __init__(self, n_mix=32, n_iter=100, covtype=\"full\"):\n self.n_mix = n_mix\n self.n_iter = n_iter\n self.covtype = covtype\n\n self.random_state = np.random.mtrand._rand\n\n # construct GMM parameter\n if self.covtype == \"full\":\n self.param = sklearn.mixture.", "reference": "self.param=sklearn.mixture.GaussianMixture(n_components=self.n_mix,covariance_type=self.covtype,max_iter=self.n_iter,)", "reference dict": { "self.param": "BlockDiagonalGaussianMixture" }, "alias dict": { "sklearn.mixture.DPGMM": "sklearn.mixture.DPGMM", "sklearn.mixture.BayesianGaussianMixture": "sklearn.mixture.BayesianGaussianMixture", "sklearn.mixture.GMM": "sklearn.mixture.GMM", "sklearn.mixture.GaussianMixture": "sklearn.mixture.GaussianMixture", "sklearn.mixture.VBGMM": "sklearn.mixture.VBGMM" }, "deprecated api": [ "sklearn.mixture.GMM" ], "replacement api": "sklearn.mixture.GaussianMixture", "expected call": "sklearn.mixture.GaussianMixture", "y_pos": "self.param=sklearn.mixture.GaussianMixture(n_components=self.n_mix,covariance_type=self.covtype,max_iter=self.n_iter,)", "y_neg": " self.param = sklearn.mixture.GMM(n_components=self.n_mix,", "retain": " def __init__(self, n_mix=32, n_iter=100, covtype=\"full\"):\n self.n_mix = n_mix\n self.n_iter = n_iter\n self.covtype = covtype\n\n self.random_state = np.random.mtrand._rand\n\n # construct GMM parameter\n if self.covtype == \"full\":\n self.param = sklearn.mixture.GaussianMixture(\n n_components=self.n_mix,\n covariance_type=self.covtype,\n max_iter=self.n_iter,\n )\n elif self.covtype == \"block_diag\":\n self.param = BlockDiagonalGaussianMixture(\n n_mix=self.n_mix, n_iter=self.n_iter\n )\n else:\n raise ValueError(\"Covariance type should be full or block_diag\")" }, { "id": 12474, "library": "sklearn", "category": "up-to-dated", "source": "sourcegraph", "function": " def fit(self, data, target):\n data = np.asarray(data)\n target = np.asarray(target).astype(self.dtype)\n# print \"gmmcl fit sh \", data.shape\n un = np.unique(target)\n for label in un:\n # cli = sklearn.mixture.GMM(**self.clspars)\n if label in self.cls:\n cli = self.cls[label]\n else:\n cli = sklearn.mixture.GaussianMixture(**self.clspars)\n dtl = data[target.reshape(-1) == label]\n cli.fit(dtl)\n self.cls[label] = cli\n\n pass", "probing input": " def fit(self, data, target):\n data = np.asarray(data)\n target = np.asarray(target).astype(self.dtype)\n# print \"gmmcl fit sh \", data.shape\n un = np.unique(target)\n for label in un:\n # cli = sklearn.mixture.GMM(**self.clspars)\n if label in self.cls:\n cli = self.cls[label]\n else:\n", "probing input new": " def fit(self, data, target):\n data = np.asarray(data)\n target = np.asarray(target).astype(self.dtype)\n# print \"gmmcl fit sh \", data.shape\n un = np.unique(target)\n for label in un:\n # cli = sklearn.mixture.GMM(**self.clspars)\n if label in self.cls:\n cli = self.cls[label]\n else:\n cli = sklearn.mixture.", "reference": "cli=sklearn.mixture.GaussianMixture(**self.clspars)", "reference dict": { "cli": "sklearn.mixture.GaussianMixture" }, "alias dict": { "sklearn.feature_selection.SelectFromModel": "sklearn.feature_selection.SelectFromModel", "sklearn.mixture.GaussianMixture": "sklearn.mixture.GaussianMixture", "sklearn.datasets.fetch_mldata": "sklearn.datasets.fetch_mldata", "sklearn.linear_model._logistic.logistic_regression_path": "sklearn.linear_model._logistic.logistic_regression_path", "sklearn.utils._safe_indexing": "sklearn.utils._safe_indexing", "sklearn.ensemble.plot_partial_dependence": "sklearn.ensemble.plot_partial_dependence", "sklearn.utils.safe_indexing": "sklearn.utils.safe_indexing", "sklearn.mixture.BayesianGaussianMixture": "sklearn.mixture.BayesianGaussianMixture", "sklearn.feature_extraction.image.extract_patches_2d": "sklearn.feature_extraction.image.extract_patches_2d", "sklearn.datasets.fetch_openml": "sklearn.datasets.fetch_openml", "sklearn.datasets.fetch_lfw_pairs": "sklearn.datasets.fetch_lfw_pairs", "sklearn.metrics.jaccard_score": "sklearn.metrics.jaccard_score", "sklearn.mixture.VBGMM": "sklearn.mixture.VBGMM", "sklearn.inspection.partial_dependence": "sklearn.inspection.partial_dependence", "sklearn.linear_model.RandomizedLogisticRegression": "sklearn.linear_model.RandomizedLogisticRegression", "sklearn.feature_extraction.image.extract_patches": "sklearn.feature_extraction.image.extract_patches", "sklearn.metrics.jaccard_similarity_score": "sklearn.metrics.jaccard_similarity_score", "sklearn.linear_model.logistic_regression_path": "sklearn.linear_model.logistic_regression_path", "sklearn.preprocessing.Imputer": "sklearn.preprocessing.Imputer", "sklearn.inspection.plot_partial_dependence": "sklearn.inspection.plot_partial_dependence", "sklearn.ensemble.partial_dependence": "sklearn.ensemble.partial_dependence", "sklearn.linear_model.RandomizedLasso": "sklearn.linear_model.RandomizedLasso", "sklearn.mixture.DPGMM": "sklearn.mixture.DPGMM", "sklearn.mixture.GMM": "sklearn.mixture.GMM", "sklearn.datasets.load_lfw_pairs": "sklearn.datasets.load_lfw_pairs", "sklearn.impute.SimpleImputer": "sklearn.impute.SimpleImputer" }, "deprecated api": [ "sklearn.mixture.GMM" ], "replacement api": "sklearn.mixture.GaussianMixture", "expected call": "sklearn.mixture.GaussianMixture", "y_pos": "cli=sklearn.mixture.GaussianMixture(**self.clspars)", "y_neg": " cli = sklearn.mixture.GMM(**self.clspars)", "retain": " def fit(self, data, target):\n data = np.asarray(data)\n target = np.asarray(target).astype(self.dtype)\n# print \"gmmcl fit sh \", data.shape\n un = np.unique(target)\n for label in un:\n # cli = sklearn.mixture.GMM(**self.clspars)\n if label in self.cls:\n cli = self.cls[label]\n else:\n cli = sklearn.mixture.GaussianMixture(**self.clspars)\n dtl = data[target.reshape(-1) == label]\n cli.fit(dtl)\n self.cls[label] = cli\n\n pass" }, { "id": 12579, "library": "sklearn", "category": "up-to-dated", "source": "sourcegraph", "function": "def build_single_GMM(k, C, reg_covar):\n\t'''\n\tFit a gaussian mixture model\n\n\tParameters\n\t----------\n\tk : int\n\t\tNumber of components\n\tC : array\n\t\tFeature data\n\treg_covar : float\n\t\tRegularization of the covariance matrix\n\t'''\n\tnp.random.seed()\n\tgmm = smix.GaussianMixture(\n\t\tn_components=k,\n\t\tcovariance_type='full',\n\t\ttol=0.001, # orig 0.001\n\t\treg_covar=reg_covar,\n\t\tmax_iter=10000, # orig 10000\n\t\tn_init=10,\n\t\tinit_params='kmeans',\n\t\tweights_init=None,\n\t\tmeans_init=None,\n\t\tprecisions_init=None,\n\t\trandom_state=None,\n\t\twarm_start=False,\n\t\tverbose=0,\n\t\tverbose_interval=10) # create model\n\treturn gmm.fit(C)", "probing input": "def build_single_GMM(k, C, reg_covar):\n\t'''\n\tFit a gaussian mixture model\n\n\tParameters\n\t----------\n\tk : int\n\t\tNumber of components\n\tC : array\n\t\tFeature data\n\treg_covar : float\n\t\tRegularization of the covariance matrix\n\t'''\n\tnp.random.seed()\n", "probing input new": "def build_single_GMM(k, C, reg_covar):\n\t'''\n\tFit a gaussian mixture model\n\n\tParameters\n\t----------\n\tk : int\n\t\tNumber of components\n\tC : array\n\t\tFeature data\n\treg_covar : float\n\t\tRegularization of the covariance matrix\n\t'''\n\tnp.random.seed()\n\tgmm = smix.", "reference": "gmm=smix.GaussianMixture(n_components=k,covariance_type='full',tol=0.001,reg_covar=reg_covar,max_iter=10000,n_init=10,init_params='kmeans',weights_init=None,means_init=None,precisions_init=None,random_state=None,warm_start=False,verbose=0,verbose_interval=10)", "reference dict": { "gmm": "smix.GaussianMixture" }, "alias dict": { "sp.Imputer": "sklearn.preprocessing.Imputer", "smix.DPGMM": "sklearn.mixture.DPGMM", "smix.BayesianGaussianMixture": "sklearn.mixture.BayesianGaussianMixture", "smix.GMM": "sklearn.mixture.GMM", "smix.GaussianMixture": "sklearn.mixture.GaussianMixture", "smix.VBGMM": "sklearn.mixture.VBGMM" }, "deprecated api": [ "sklearn.mixture.GMM" ], "replacement api": "sklearn.mixture.GaussianMixture", "expected call": "smix.GaussianMixture", "y_pos": "gmm=smix.GaussianMixture(n_components=k,covariance_type='full',tol=0.001,reg_covar=reg_covar,max_iter=10000,n_init=10,init_params='kmeans',weights_init=None,means_init=None,precisions_init=None,random_state=None,warm_start=False,verbose=0,verbose_interval=10)", "y_neg": "\tgmm = smix.GMM(k, C, reg_covar)", "retain": "def build_single_GMM(k, C, reg_covar):\n\t'''\n\tFit a gaussian mixture model\n\n\tParameters\n\t----------\n\tk : int\n\t\tNumber of components\n\tC : array\n\t\tFeature data\n\treg_covar : float\n\t\tRegularization of the covariance matrix\n\t'''\n\tnp.random.seed()\n\tgmm = smix.GaussianMixture(\n\t\tn_components=k,\n\t\tcovariance_type='full',\n\t\ttol=0.001, # orig 0.001\n\t\treg_covar=reg_covar,\n\t\tmax_iter=10000, # orig 10000\n\t\tn_init=10,\n\t\tinit_params='kmeans',\n\t\tweights_init=None,\n\t\tmeans_init=None,\n\t\tprecisions_init=None,\n\t\trandom_state=None,\n\t\twarm_start=False,\n\t\tverbose=0,\n\t\tverbose_interval=10) # create model\n\treturn gmm.fit(C)" }, { "id": 12609, "library": "sklearn", "category": "up-to-dated", "source": "sourcegraph", "function": "def estim_class_model_gmm(features, nb_classes, init='kmeans'):\n \"\"\" from all features estimate Gaussian Mixture Model and assuming\n each cluster is a single class compute probability that each feature\n belongs to each class\n\n :param [[float]] features: list of features per segment\n :param int nb_classes: number of classes\n :param int init: initialisation\n :return [[float]]: probabilities that each feature belongs to each class\n\n >>> np.random.seed(0)\n >>> fts = np.row_stack([np.random.random((50, 3)) - 1,\n ... np.random.random((50, 3)) + 1])\n >>> mm = estim_class_model_gmm(fts, 2)\n >>> mm.predict_proba(fts).shape\n (100, 2)\n \"\"\"\n logging.debug('estimate GMM for all given features %r and %i component', features.shape, nb_classes)\n # http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n gmm = mixture.GaussianMixture(n_components=nb_classes, covariance_type='full', max_iter=99)\n if init == 'kmeans':\n # http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html\n kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++', n_jobs=-1)\n y = kmeans.fit_predict(features)\n gmm.fit(features, y)\n else:\n gmm.fit(features)\n logging.info('compute probability of each feature to all component')\n return gmm", "probing input": "def estim_class_model_gmm(features, nb_classes, init='kmeans'):\n \"\"\" from all features estimate Gaussian Mixture Model and assuming\n each cluster is a single class compute probability that each feature\n belongs to each class\n\n :param [[float]] features: list of features per segment\n :param int nb_classes: number of classes\n :param int init: initialisation\n :return [[float]]: probabilities that each feature belongs to each class\n\n >>> np.random.seed(0)\n >>> fts = np.row_stack([np.random.random((50, 3)) - 1,\n ... np.random.random((50, 3)) + 1])\n >>> mm = estim_class_model_gmm(fts, 2)\n >>> mm.predict_proba(fts).shape\n (100, 2)\n \"\"\"\n logging.debug('estimate GMM for all given features %r and %i component', features.shape, nb_classes)\n # http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n", "probing input new": "def estim_class_model_gmm(features, nb_classes, init='kmeans'):\n \"\"\" from all features estimate Gaussian Mixture Model and assuming\n each cluster is a single class compute probability that each feature\n belongs to each class\n\n :param [[float]] features: list of features per segment\n :param int nb_classes: number of classes\n :param int init: initialisation\n :return [[float]]: probabilities that each feature belongs to each class\n\n >>> np.random.seed(0)\n >>> fts = np.row_stack([np.random.random((50, 3)) - 1,\n ... np.random.random((50, 3)) + 1])\n >>> mm = estim_class_model_gmm(fts, 2)\n >>> mm.predict_proba(fts).shape\n (100, 2)\n \"\"\"\n logging.debug('estimate GMM for all given features %r and %i component', features.shape, nb_classes)\n # http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n gmm = mixture.", "reference": "gmm=mixture.GaussianMixture(n_components=nb_classes,covariance_type='full',max_iter=99)", "reference dict": { "gmm": "mixture.GaussianMixture", "kmeans": "cluster.KMeans" }, "alias dict": { "metrics.jaccard_score": "sklearn.metrics.jaccard_score", "metrics.jaccard_similarity_score": "sklearn.metrics.jaccard_similarity_score", "mixture.DPGMM": "sklearn.mixture.DPGMM", "mixture.BayesianGaussianMixture": "sklearn.mixture.BayesianGaussianMixture", "mixture.GMM": "sklearn.mixture.GMM", "mixture.GaussianMixture": "sklearn.mixture.GaussianMixture", "mixture.VBGMM": "sklearn.mixture.VBGMM", "preprocessing.Imputer": "sklearn.preprocessing.Imputer" }, "deprecated api": [ "sklearn.mixture.GMM" ], "replacement api": "sklearn.mixture.GaussianMixture", "expected call": "mixture.GaussianMixture", "y_pos": "gmm=mixture.GaussianMixture(n_components=nb_classes,covariance_type='full',max_iter=99)", "y_neg": " gmm = mixture.GMM(n_components=nb_classes, init_params=init)", "retain": "def estim_class_model_gmm(features, nb_classes, init='kmeans'):\n \"\"\" from all features estimate Gaussian Mixture Model and assuming\n each cluster is a single class compute probability that each feature\n belongs to each class\n\n :param [[float]] features: list of features per segment\n :param int nb_classes: number of classes\n :param int init: initialisation\n :return [[float]]: probabilities that each feature belongs to each class\n\n >>> np.random.seed(0)\n >>> fts = np.row_stack([np.random.random((50, 3)) - 1,\n ... np.random.random((50, 3)) + 1])\n >>> mm = estim_class_model_gmm(fts, 2)\n >>> mm.predict_proba(fts).shape\n (100, 2)\n \"\"\"\n logging.debug('estimate GMM for all given features %r and %i component', features.shape, nb_classes)\n # http://scikit-learn.org/stable/modules/generated/sklearn.mixture.GMM.html\n gmm = mixture.GaussianMixture(n_components=nb_classes, covariance_type='full', max_iter=99)\n if init == 'kmeans':\n # http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html\n kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++', n_jobs=-1)\n y = kmeans.fit_predict(features)\n gmm.fit(features, y)\n else:\n gmm.fit(features)\n logging.info('compute probability of each feature to all component')\n return gmm" }, { "id": 13901, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def distorted_bounding_box_crop_batch(images,\n bbox=None,\n min_object_covered=0.1,\n aspect_ratio_range=(0.75, 1.33),\n area_range=(0.05, 1.0),\n scope=None):\n \"\"\"Generates cropped_image using one of the bboxes randomly distorted.\n\n See `tf1.image.sample_distorted_bounding_box` for more documentation.\n\n Args:\n image: `Tensor` of image data. [B, H, W, C]\n aspect_ratio_range: An optional list of `float`s. The cropped area of the\n image must have an aspect ratio = width / height within this range.\n area_range: An optional list of `float`s. The cropped area of the image\n must contain a fraction of the supplied image within in this range.\n scope: Optional `str` for name scope.\n Returns:\n (cropped image `Tensor`, distorted bbox `Tensor`).\n \"\"\"\n with tf1.name_scope(scope, 'distorted_bounding_box_crop', [images]):\n shape = tf.shape(images)\n bbox_begin, bbox_size = sample_distorted_bounding_box_batch(\n shape,\n bbox=bbox,\n min_object_covered=min_object_covered,\n aspect_ratio_range=aspect_ratio_range,\n area_range=area_range)\n\n # Compute flow.\n B = shape[0]\n H = shape[1]\n W = shape[2]\n Hf = tf.cast(H, tf.float32)\n Wf = tf.cast(W, tf.float32)\n flow = tf.zeros([B, H, W, 2])\n flow_j = tf.cast(tf.range(H), tf.float32)\n flow_i = tf.cast(tf.range(W), tf.float32)\n\n flow_j = flow_j[None, :] / (Hf - 1) * (bbox_size[:, 0:1] - Hf) # [B, H]\n flow_j += bbox_begin[:, 0:1] # [B, H]\n flow_j = flow_j[:, :, None, None] # [B,H,1,1]\n # print(flow_j.shape)\n # assert False\n flow_j = tf.tile(flow_j, [1, 1, W, 1]) # [B, H, W, 1]\n\n flow_i = flow_i[None, :] / (Wf - 1) * (bbox_size[:, 1:2] - Wf) # [B, W]\n flow_i += bbox_begin[:, 1:2] # [B, W]\n flow_i = flow_i[:, None, :, None] # [B, 1, W, 1]\n flow_i = tf.tile(flow_i, [1, H, 1, 1]) # [B, H, W, 1]\n flow = tf.concat([flow_j, flow_i], axis=-1) # [B, H, W, 2]\n\n images = tfa.image.dense_image_warp(images, -flow)\n bbox = tf.stack([bbox_begin, bbox_size], axis=-1)\n return images", "probing input": "def distorted_bounding_box_crop_batch(images,\n bbox=None,\n min_object_covered=0.1,\n aspect_ratio_range=(0.75, 1.33),\n area_range=(0.05, 1.0),\n scope=None):\n \"\"\"Generates cropped_image using one of the bboxes randomly distorted.\n\n See `tf1.image.sample_distorted_bounding_box` for more documentation.\n\n Args:\n image: `Tensor` of image data. [B, H, W, C]\n aspect_ratio_range: An optional list of `float`s. The cropped area of the\n image must have an aspect ratio = width / height within this range.\n area_range: An optional list of `float`s. The cropped area of the image\n must contain a fraction of the supplied image within in this range.\n scope: Optional `str` for name scope.\n Returns:\n (cropped image `Tensor`, distorted bbox `Tensor`).\n \"\"\"\n with tf1.name_scope(scope, 'distorted_bounding_box_crop', [images]):\n shape = tf.shape(images)\n bbox_begin, bbox_size = sample_distorted_bounding_box_batch(\n shape,\n bbox=bbox,\n min_object_covered=min_object_covered,\n aspect_ratio_range=aspect_ratio_range,\n area_range=area_range)\n\n # Compute flow.\n B = shape[0]\n H = shape[1]\n W = shape[2]\n", "probing input new": "def distorted_bounding_box_crop_batch(images,\n bbox=None,\n min_object_covered=0.1,\n aspect_ratio_range=(0.75, 1.33),\n area_range=(0.05, 1.0),\n scope=None):\n \"\"\"Generates cropped_image using one of the bboxes randomly distorted.\n\n See `tf1.image.sample_distorted_bounding_box` for more documentation.\n\n Args:\n image: `Tensor` of image data. [B, H, W, C]\n aspect_ratio_range: An optional list of `float`s. The cropped area of the\n image must have an aspect ratio = width / height within this range.\n area_range: An optional list of `float`s. The cropped area of the image\n must contain a fraction of the supplied image within in this range.\n scope: Optional `str` for name scope.\n Returns:\n (cropped image `Tensor`, distorted bbox `Tensor`).\n \"\"\"\n with tf1.name_scope(scope, 'distorted_bounding_box_crop', [images]):\n shape = tf.shape(images)\n bbox_begin, bbox_size = sample_distorted_bounding_box_batch(\n shape,\n bbox=bbox,\n min_object_covered=min_object_covered,\n aspect_ratio_range=aspect_ratio_range,\n area_range=area_range)\n\n # Compute flow.\n B = shape[0]\n H = shape[1]\n W = shape[2]\n Hf = tf.", "reference": "Hf=tf.cast(H,tf.float32)", "reference dict": {}, "alias dict": { "tf1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf1.all_variables": "tensorflow.compat.v1.all_variables", "tf1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf1.to_int64": "tensorflow.compat.v1.to_int64", "tf1.to_int32": "tensorflow.compat.v1.to_int32", "tf1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf1.div": "tensorflow.compat.v1.div", "tf1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf1.to_double": "tensorflow.compat.v1.to_double", "tf1.arg_min": "tensorflow.compat.v1.arg_min", "tf1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf1.substr": "tensorflow.compat.v1.substr", "tf1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf1.arg_max": "tensorflow.compat.v1.arg_max", "tf1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf1.Print": "tensorflow.compat.v1.Print", "tf1.to_float": "tensorflow.compat.v1.to_float", "tf1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf1.multinomial": "tensorflow.compat.v1.multinomial", "tf1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "Hf=tf.cast(H,tf.float32)", "y_neg": " Hf = tf.to_float(H)", "retain": "def distorted_bounding_box_crop_batch(images,\n bbox=None,\n min_object_covered=0.1,\n aspect_ratio_range=(0.75, 1.33),\n area_range=(0.05, 1.0),\n scope=None):\n \"\"\"Generates cropped_image using one of the bboxes randomly distorted.\n\n See `tf1.image.sample_distorted_bounding_box` for more documentation.\n\n Args:\n image: `Tensor` of image data. [B, H, W, C]\n aspect_ratio_range: An optional list of `float`s. The cropped area of the\n image must have an aspect ratio = width / height within this range.\n area_range: An optional list of `float`s. The cropped area of the image\n must contain a fraction of the supplied image within in this range.\n scope: Optional `str` for name scope.\n Returns:\n (cropped image `Tensor`, distorted bbox `Tensor`).\n \"\"\"\n with tf1.name_scope(scope, 'distorted_bounding_box_crop', [images]):\n shape = tf.shape(images)\n bbox_begin, bbox_size = sample_distorted_bounding_box_batch(\n shape,\n bbox=bbox,\n min_object_covered=min_object_covered,\n aspect_ratio_range=aspect_ratio_range,\n area_range=area_range)\n\n # Compute flow.\n B = shape[0]\n H = shape[1]\n W = shape[2]\n Hf = tf.cast(H, tf.float32)\n Wf = tf.cast(W, tf.float32)\n flow = tf.zeros([B, H, W, 2])\n flow_j = tf.cast(tf.range(H), tf.float32)\n flow_i = tf.cast(tf.range(W), tf.float32)\n\n flow_j = flow_j[None, :] / (Hf - 1) * (bbox_size[:, 0:1] - Hf) # [B, H]\n flow_j += bbox_begin[:, 0:1] # [B, H]\n flow_j = flow_j[:, :, None, None] # [B,H,1,1]\n # print(flow_j.shape)\n # assert False\n flow_j = tf.tile(flow_j, [1, 1, W, 1]) # [B, H, W, 1]\n\n flow_i = flow_i[None, :] / (Wf - 1) * (bbox_size[:, 1:2] - Wf) # [B, W]\n flow_i += bbox_begin[:, 1:2] # [B, W]\n flow_i = flow_i[:, None, :, None] # [B, 1, W, 1]\n flow_i = tf.tile(flow_i, [1, H, 1, 1]) # [B, H, W, 1]\n flow = tf.concat([flow_j, flow_i], axis=-1) # [B, H, W, 2]\n\n images = tfa.image.dense_image_warp(images, -flow)\n bbox = tf.stack([bbox_begin, bbox_size], axis=-1)\n return images" }, { "id": 14366, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_blur(image, kernel_size, sigma, padding=\"SAME\"):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), tf.float32)\n blur_filter = tf.exp(\n -tf.pow(x, 2.0) / (2.0 * tf.pow(tf.cast(sigma, tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred", "probing input": "def gaussian_blur(image, kernel_size, sigma, padding=\"SAME\"):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n", "probing input new": "def gaussian_blur(image, kernel_size, sigma, padding=\"SAME\"):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.", "reference": "radius=tf.cast(kernel_size/2,tf.int32)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "radius=tf.cast(kernel_size/2,tf.int32)", "y_neg": " radius = tf.to_int32(kernel_size / 2)", "retain": "def gaussian_blur(image, kernel_size, sigma, padding=\"SAME\"):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), tf.float32)\n blur_filter = tf.exp(\n -tf.pow(x, 2.0) / (2.0 * tf.pow(tf.cast(sigma, tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred" }, { "id": 14430, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def mask(config, inputs, mask_prob, proposal_distribution=1.0,\n disallow_from_mask=None, already_masked=None):\n \"\"\"Implementation of dynamic masking. The optional arguments aren't needed for\n BERT/ELECTRA and are from early experiments in \"strategically\" masking out\n tokens instead of uniformly at random.\n\n Args:\n config: configure_pretraining.PretrainingConfig\n inputs: pretrain_data.Inputs containing input input_ids/input_mask\n mask_prob: percent of tokens to mask\n proposal_distribution: for non-uniform masking can be a [B, L] tensor\n of scores for masking each position.\n disallow_from_mask: a boolean tensor of [B, L] of positions that should\n not be masked out\n already_masked: a boolean tensor of [B, N] of already masked-out tokens\n for multiple rounds of masking\n Returns: a pretrain_data.Inputs with masking added\n \"\"\"\n # Get the batch size, sequence length, and max masked-out tokens\n N = config.max_predictions_per_seq\n B, L = get_shape_list(inputs.input_ids)\n\n # Find indices where masking out a token is allowed\n vocab = tokenization.ElectraTokenizer(\n config.vocab_file, do_lower_case=config.do_lower_case).get_vocab()\n candidates_mask = _get_candidates_mask(inputs, vocab, disallow_from_mask)\n\n # Set the number of tokens to mask out per example\n num_tokens = tf.cast(tf.reduce_sum(inputs.input_mask, -1), tf.float32)\n num_to_predict = tf.maximum(1, tf.minimum(\n N, tf.cast(tf.round(num_tokens * mask_prob), tf.int32)))\n masked_lm_weights = tf.cast(tf.sequence_mask(num_to_predict, N), tf.float32)\n if already_masked is not None:\n masked_lm_weights *= (1 - already_masked)\n\n # Get a probability of masking each position in the sequence\n candidate_mask_float = tf.cast(candidates_mask, tf.float32)\n sample_prob = (proposal_distribution * candidate_mask_float)\n sample_prob /= tf.reduce_sum(sample_prob, axis=-1, keepdims=True)\n\n # Sample the positions to mask out\n sample_prob = tf.stop_gradient(sample_prob)\n sample_logits = tf.math.log(sample_prob)\n masked_lm_positions = tf.random.categorical(\n sample_logits, N, dtype=tf.int32)\n masked_lm_positions *= tf.cast(masked_lm_weights, tf.int32)\n\n # Get the ids of the masked-out tokens\n shift = tf.expand_dims(L * tf.range(B), -1)\n flat_positions = tf.reshape(masked_lm_positions + shift, [-1, 1])\n masked_lm_ids = tf.gather_nd(tf.reshape(inputs.input_ids, [-1]),\n flat_positions)\n masked_lm_ids = tf.reshape(masked_lm_ids, [B, -1])\n masked_lm_ids *= tf.cast(masked_lm_weights, tf.int32)\n\n # Update the input ids\n replace_with_mask_positions = masked_lm_positions * tf.cast(\n tf.less(tf.random.uniform([B, N]), 0.85), tf.int32)\n inputs_ids, _ = scatter_update(\n inputs.input_ids, tf.fill([B, N], vocab[\"[MASK]\"]),\n replace_with_mask_positions)\n\n return get_updated_inputs(\n inputs,\n input_ids=tf.stop_gradient(inputs_ids),\n masked_lm_positions=masked_lm_positions,\n masked_lm_ids=masked_lm_ids,\n masked_lm_weights=masked_lm_weights\n )", "probing input": "def mask(config, inputs, mask_prob, proposal_distribution=1.0,\n disallow_from_mask=None, already_masked=None):\n \"\"\"Implementation of dynamic masking. The optional arguments aren't needed for\n BERT/ELECTRA and are from early experiments in \"strategically\" masking out\n tokens instead of uniformly at random.\n\n Args:\n config: configure_pretraining.PretrainingConfig\n inputs: pretrain_data.Inputs containing input input_ids/input_mask\n mask_prob: percent of tokens to mask\n proposal_distribution: for non-uniform masking can be a [B, L] tensor\n of scores for masking each position.\n disallow_from_mask: a boolean tensor of [B, L] of positions that should\n not be masked out\n already_masked: a boolean tensor of [B, N] of already masked-out tokens\n for multiple rounds of masking\n Returns: a pretrain_data.Inputs with masking added\n \"\"\"\n # Get the batch size, sequence length, and max masked-out tokens\n N = config.max_predictions_per_seq\n B, L = get_shape_list(inputs.input_ids)\n\n # Find indices where masking out a token is allowed\n vocab = tokenization.ElectraTokenizer(\n config.vocab_file, do_lower_case=config.do_lower_case).get_vocab()\n candidates_mask = _get_candidates_mask(inputs, vocab, disallow_from_mask)\n\n # Set the number of tokens to mask out per example\n", "probing input new": "def mask(config, inputs, mask_prob, proposal_distribution=1.0,\n disallow_from_mask=None, already_masked=None):\n \"\"\"Implementation of dynamic masking. The optional arguments aren't needed for\n BERT/ELECTRA and are from early experiments in \"strategically\" masking out\n tokens instead of uniformly at random.\n\n Args:\n config: configure_pretraining.PretrainingConfig\n inputs: pretrain_data.Inputs containing input input_ids/input_mask\n mask_prob: percent of tokens to mask\n proposal_distribution: for non-uniform masking can be a [B, L] tensor\n of scores for masking each position.\n disallow_from_mask: a boolean tensor of [B, L] of positions that should\n not be masked out\n already_masked: a boolean tensor of [B, N] of already masked-out tokens\n for multiple rounds of masking\n Returns: a pretrain_data.Inputs with masking added\n \"\"\"\n # Get the batch size, sequence length, and max masked-out tokens\n N = config.max_predictions_per_seq\n B, L = get_shape_list(inputs.input_ids)\n\n # Find indices where masking out a token is allowed\n vocab = tokenization.ElectraTokenizer(\n config.vocab_file, do_lower_case=config.do_lower_case).get_vocab()\n candidates_mask = _get_candidates_mask(inputs, vocab, disallow_from_mask)\n\n # Set the number of tokens to mask out per example\n num_tokens = tf.", "reference": "num_tokens=tf.cast(tf.reduce_sum(inputs.input_mask,-1),tf.float32)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "num_tokens=tf.cast(tf.reduce_sum(inputs.input_mask,-1),tf.float32)", "y_neg": " num_tokens = tf.to_int32(tf.ceil(mask_prob * L))", "retain": "def mask(config, inputs, mask_prob, proposal_distribution=1.0,\n disallow_from_mask=None, already_masked=None):\n \"\"\"Implementation of dynamic masking. The optional arguments aren't needed for\n BERT/ELECTRA and are from early experiments in \"strategically\" masking out\n tokens instead of uniformly at random.\n\n Args:\n config: configure_pretraining.PretrainingConfig\n inputs: pretrain_data.Inputs containing input input_ids/input_mask\n mask_prob: percent of tokens to mask\n proposal_distribution: for non-uniform masking can be a [B, L] tensor\n of scores for masking each position.\n disallow_from_mask: a boolean tensor of [B, L] of positions that should\n not be masked out\n already_masked: a boolean tensor of [B, N] of already masked-out tokens\n for multiple rounds of masking\n Returns: a pretrain_data.Inputs with masking added\n \"\"\"\n # Get the batch size, sequence length, and max masked-out tokens\n N = config.max_predictions_per_seq\n B, L = get_shape_list(inputs.input_ids)\n\n # Find indices where masking out a token is allowed\n vocab = tokenization.ElectraTokenizer(\n config.vocab_file, do_lower_case=config.do_lower_case).get_vocab()\n candidates_mask = _get_candidates_mask(inputs, vocab, disallow_from_mask)\n\n # Set the number of tokens to mask out per example\n num_tokens = tf.cast(tf.reduce_sum(inputs.input_mask, -1), tf.float32)\n num_to_predict = tf.maximum(1, tf.minimum(\n N, tf.cast(tf.round(num_tokens * mask_prob), tf.int32)))\n masked_lm_weights = tf.cast(tf.sequence_mask(num_to_predict, N), tf.float32)\n if already_masked is not None:\n masked_lm_weights *= (1 - already_masked)\n\n # Get a probability of masking each position in the sequence\n candidate_mask_float = tf.cast(candidates_mask, tf.float32)\n sample_prob = (proposal_distribution * candidate_mask_float)\n sample_prob /= tf.reduce_sum(sample_prob, axis=-1, keepdims=True)\n\n # Sample the positions to mask out\n sample_prob = tf.stop_gradient(sample_prob)\n sample_logits = tf.math.log(sample_prob)\n masked_lm_positions = tf.random.categorical(\n sample_logits, N, dtype=tf.int32)\n masked_lm_positions *= tf.cast(masked_lm_weights, tf.int32)\n\n # Get the ids of the masked-out tokens\n shift = tf.expand_dims(L * tf.range(B), -1)\n flat_positions = tf.reshape(masked_lm_positions + shift, [-1, 1])\n masked_lm_ids = tf.gather_nd(tf.reshape(inputs.input_ids, [-1]),\n flat_positions)\n masked_lm_ids = tf.reshape(masked_lm_ids, [B, -1])\n masked_lm_ids *= tf.cast(masked_lm_weights, tf.int32)\n\n # Update the input ids\n replace_with_mask_positions = masked_lm_positions * tf.cast(\n tf.less(tf.random.uniform([B, N]), 0.85), tf.int32)\n inputs_ids, _ = scatter_update(\n inputs.input_ids, tf.fill([B, N], vocab[\"[MASK]\"]),\n replace_with_mask_positions)\n\n return get_updated_inputs(\n inputs,\n input_ids=tf.stop_gradient(inputs_ids),\n masked_lm_positions=masked_lm_positions,\n masked_lm_ids=masked_lm_ids,\n masked_lm_weights=masked_lm_weights\n )" }, { "id": 15732, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, dtype=tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), dtype=tf.float32)\n blur_filter = tf.exp(-tf.pow(x, 2.0) /\n (2.0 * tf.pow(tf.cast(sigma, dtype=tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred", "probing input": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n", "probing input new": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.", "reference": "radius=tf.cast(kernel_size/2,dtype=tf.int32)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "radius=tf.cast(kernel_size/2,dtype=tf.int32)", "y_neg": " radius = tf.to_int32(kernel_size / 2)", "retain": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, dtype=tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), dtype=tf.float32)\n blur_filter = tf.exp(-tf.pow(x, 2.0) /\n (2.0 * tf.pow(tf.cast(sigma, dtype=tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred" }, { "id": 15929, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def build_graph(self, state, action, futurereward, action_prob):\n logits, value = self._get_NN_prediction(state)\n value = tf.squeeze(value, [1], name='pred_value') # (B,)\n policy = tf.nn.softmax(logits, name='policy')\n if not self.training:\n return\n log_probs = tf.log(policy + 1e-6)\n\n log_pi_a_given_s = tf.reduce_sum(\n log_probs * tf.one_hot(action, NUM_ACTIONS), 1)\n advantage = tf.subtract(tf.stop_gradient(value), futurereward, name='advantage')\n\n pi_a_given_s = tf.reduce_sum(policy * tf.one_hot(action, NUM_ACTIONS), 1) # (B,)\n importance = tf.stop_gradient(tf.clip_by_value(pi_a_given_s / (action_prob + 1e-8), 0, 10))\n\n policy_loss = tf.reduce_sum(log_pi_a_given_s * advantage * importance, name='policy_loss')\n xentropy_loss = tf.reduce_sum(policy * log_probs, name='xentropy_loss')\n value_loss = tf.nn.l2_loss(value - futurereward, name='value_loss')\n\n pred_reward = tf.reduce_mean(value, name='predict_reward')\n advantage = tf.sqrt(tf.reduce_mean(tf.square(advantage)), name='rms_advantage')\n entropy_beta = tf.get_variable('entropy_beta', shape=[],\n initializer=tf.constant_initializer(0.01), trainable=False)\n cost = tf.add_n([policy_loss, xentropy_loss * entropy_beta, value_loss])\n cost = tf.truediv(cost, tf.cast(tf.shape(futurereward)[0], tf.float32), name='cost')\n summary.add_moving_summary(policy_loss, xentropy_loss,\n value_loss, pred_reward, advantage,\n cost, tf.reduce_mean(importance, name='importance'))\n return cost", "probing input": " def build_graph(self, state, action, futurereward, action_prob):\n logits, value = self._get_NN_prediction(state)\n value = tf.squeeze(value, [1], name='pred_value') # (B,)\n policy = tf.nn.softmax(logits, name='policy')\n if not self.training:\n return\n log_probs = tf.log(policy + 1e-6)\n\n log_pi_a_given_s = tf.reduce_sum(\n log_probs * tf.one_hot(action, NUM_ACTIONS), 1)\n advantage = tf.subtract(tf.stop_gradient(value), futurereward, name='advantage')\n\n pi_a_given_s = tf.reduce_sum(policy * tf.one_hot(action, NUM_ACTIONS), 1) # (B,)\n importance = tf.stop_gradient(tf.clip_by_value(pi_a_given_s / (action_prob + 1e-8), 0, 10))\n\n policy_loss = tf.reduce_sum(log_pi_a_given_s * advantage * importance, name='policy_loss')\n xentropy_loss = tf.reduce_sum(policy * log_probs, name='xentropy_loss')\n value_loss = tf.nn.l2_loss(value - futurereward, name='value_loss')\n\n pred_reward = tf.reduce_mean(value, name='predict_reward')\n advantage = tf.sqrt(tf.reduce_mean(tf.square(advantage)), name='rms_advantage')\n entropy_beta = tf.get_variable('entropy_beta', shape=[],\n initializer=tf.constant_initializer(0.01), trainable=False)\n cost = tf.add_n([policy_loss, xentropy_loss * entropy_beta, value_loss])\n", "probing input new": " def build_graph(self, state, action, futurereward, action_prob):\n logits, value = self._get_NN_prediction(state)\n value = tf.squeeze(value, [1], name='pred_value') # (B,)\n policy = tf.nn.softmax(logits, name='policy')\n if not self.training:\n return\n log_probs = tf.log(policy + 1e-6)\n\n log_pi_a_given_s = tf.reduce_sum(\n log_probs * tf.one_hot(action, NUM_ACTIONS), 1)\n advantage = tf.subtract(tf.stop_gradient(value), futurereward, name='advantage')\n\n pi_a_given_s = tf.reduce_sum(policy * tf.one_hot(action, NUM_ACTIONS), 1) # (B,)\n importance = tf.stop_gradient(tf.clip_by_value(pi_a_given_s / (action_prob + 1e-8), 0, 10))\n\n policy_loss = tf.reduce_sum(log_pi_a_given_s * advantage * importance, name='policy_loss')\n xentropy_loss = tf.reduce_sum(policy * log_probs, name='xentropy_loss')\n value_loss = tf.nn.l2_loss(value - futurereward, name='value_loss')\n\n pred_reward = tf.reduce_mean(value, name='predict_reward')\n advantage = tf.sqrt(tf.reduce_mean(tf.square(advantage)), name='rms_advantage')\n entropy_beta = tf.get_variable('entropy_beta', shape=[],\n initializer=tf.constant_initializer(0.01), trainable=False)\n cost = tf.add_n([policy_loss, xentropy_loss * entropy_beta, value_loss])\n cost = tf.truediv(cost, tf.", "reference": "cost=tf.truediv(cost,tf.cast(tf.shape(futurereward)[0],tf.float32),name='cost')", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "cost=tf.truediv(cost,tf.cast(tf.shape(futurereward)[0],tf.float32),name='cost')", "y_neg": " cost = tf.truediv(cost, tf.to_float(tf.get_variable('global_step', shape=[],", "retain": " def build_graph(self, state, action, futurereward, action_prob):\n logits, value = self._get_NN_prediction(state)\n value = tf.squeeze(value, [1], name='pred_value') # (B,)\n policy = tf.nn.softmax(logits, name='policy')\n if not self.training:\n return\n log_probs = tf.log(policy + 1e-6)\n\n log_pi_a_given_s = tf.reduce_sum(\n log_probs * tf.one_hot(action, NUM_ACTIONS), 1)\n advantage = tf.subtract(tf.stop_gradient(value), futurereward, name='advantage')\n\n pi_a_given_s = tf.reduce_sum(policy * tf.one_hot(action, NUM_ACTIONS), 1) # (B,)\n importance = tf.stop_gradient(tf.clip_by_value(pi_a_given_s / (action_prob + 1e-8), 0, 10))\n\n policy_loss = tf.reduce_sum(log_pi_a_given_s * advantage * importance, name='policy_loss')\n xentropy_loss = tf.reduce_sum(policy * log_probs, name='xentropy_loss')\n value_loss = tf.nn.l2_loss(value - futurereward, name='value_loss')\n\n pred_reward = tf.reduce_mean(value, name='predict_reward')\n advantage = tf.sqrt(tf.reduce_mean(tf.square(advantage)), name='rms_advantage')\n entropy_beta = tf.get_variable('entropy_beta', shape=[],\n initializer=tf.constant_initializer(0.01), trainable=False)\n cost = tf.add_n([policy_loss, xentropy_loss * entropy_beta, value_loss])\n cost = tf.truediv(cost, tf.cast(tf.shape(futurereward)[0], tf.float32), name='cost')\n summary.add_moving_summary(policy_loss, xentropy_loss,\n value_loss, pred_reward, advantage,\n cost, tf.reduce_mean(importance, name='importance'))\n return cost" }, { "id": 16444, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, dtype=tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), dtype=tf.float32)\n blur_filter = tf.exp(\n -tf.pow(x, 2.0) / (2.0 * tf.pow(tf.cast(sigma, dtype=tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred", "probing input": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n", "probing input new": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.", "reference": "radius=tf.cast(kernel_size/2,dtype=tf.int32)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.to_complex128", "tensorflow.compat.v1.to_int32", "tensorflow.to_complex64", "tensorflow.to_int32", "tensorflow.to_bfloat16", "tensorflow.compat.v1.to_double", "tensorflow.compat.v1.to_int64", "tensorflow.to_int64", "tensorflow.compat.v1.to_float", "tensorflow.to_double", "tensorflow.compat.v1.to_bfloat16", "tensorflow.to_float", "tensorflow.compat.v1.to_complex64", "tensorflow.to_complex128" ], "replacement api": "tensorflow.cast", "expected call": "tf.cast", "y_pos": "radius=tf.cast(kernel_size/2,dtype=tf.int32)", "y_neg": " radius = tf.to_int32(kernel_size / 2)", "retain": "def gaussian_blur(image, kernel_size, sigma, padding='SAME'):\n \"\"\"Blurs the given image with separable convolution.\n\n Args:\n image: Tensor of shape [height, width, channels] and dtype float to blur.\n kernel_size: Integer Tensor for the size of the blur kernel. This is should\n be an odd number. If it is an even number, the actual kernel size will be\n size + 1.\n sigma: Sigma value for gaussian operator.\n padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.\n\n Returns:\n A Tensor representing the blurred image.\n \"\"\"\n radius = tf.cast(kernel_size / 2, dtype=tf.int32)\n kernel_size = radius * 2 + 1\n x = tf.cast(tf.range(-radius, radius + 1), dtype=tf.float32)\n blur_filter = tf.exp(\n -tf.pow(x, 2.0) / (2.0 * tf.pow(tf.cast(sigma, dtype=tf.float32), 2.0)))\n blur_filter /= tf.reduce_sum(blur_filter)\n # One vertical and one horizontal filter.\n blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])\n blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])\n num_channels = tf.shape(image)[-1]\n blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])\n blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])\n expand_batch_dim = image.shape.ndims == 3\n if expand_batch_dim:\n # Tensorflow requires batched input to convolutions, which we can fake with\n # an extra dimension.\n image = tf.expand_dims(image, axis=0)\n blurred = tf.nn.depthwise_conv2d(\n image, blur_h, strides=[1, 1, 1, 1], padding=padding)\n blurred = tf.nn.depthwise_conv2d(\n blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)\n if expand_batch_dim:\n blurred = tf.squeeze(blurred, axis=0)\n return blurred" }, { "id": 16789, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "custom_binacc = custom_binacc_func()\n\nauc = tf.keras.metrics.AUC()", "probing input": "custom_binacc = custom_binacc_func()\n\n", "probing input new": "custom_binacc = custom_binacc_func()\n\nauc = tf.", "reference": "auc=tf.keras.metrics.AUC()", "reference dict": { "mse": "tf.keras.losses.MeanSquaredError", "mae": "tf.keras.losses.MeanAbsoluteError", "kld": "tf.keras.losses.KLDivergence", "binacc": "tf.keras.metrics.BinaryAccuracy", "auc": "tf.keras.metrics.AUC" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial", "keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing" }, "deprecated api": [ "tensorflow.metrics.auc", "tensorflow.compat.v1.metrics.auc" ], "replacement api": "tensorflow.keras.metrics.AUC", "expected call": "tf.keras.metrics.AUC", "y_pos": "auc=tf.keras.metrics.AUC()", "y_neg": "auc = tf.metrics.auc(custom_binacc.labels, custom_binacc.features)", "retain": "custom_binacc = custom_binacc_func()\n\nauc = tf.keras.metrics.AUC()" }, { "id": 16835, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def test_update_metric_by_small_chunks(self):\n labels = np.random.randint(0, 2, 1234)\n preds = np.random.random(1234)\n auc = tf.keras.metrics.AUC()\n auc.update_state(labels, preds)\n auc_value_0 = auc.result()\n\n auc.reset_states()\n EvaluationMetrics._update_metric_by_small_chunk(auc, labels, preds)\n auc_value_1 = auc.result()\n self.assertEqual(auc_value_0, auc_value_1)", "probing input": " def test_update_metric_by_small_chunks(self):\n labels = np.random.randint(0, 2, 1234)\n preds = np.random.random(1234)\n", "probing input new": " def test_update_metric_by_small_chunks(self):\n labels = np.random.randint(0, 2, 1234)\n preds = np.random.random(1234)\n auc = tf.", "reference": "auc=tf.keras.metrics.AUC()", "reference dict": { "auc": "tf.keras.metrics.AUC" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.metrics.auc", "tensorflow.compat.v1.metrics.auc" ], "replacement api": "tensorflow.keras.metrics.AUC", "expected call": "tf.keras.metrics.AUC", "y_pos": "auc=tf.keras.metrics.AUC()", "y_neg": " auc = tf.metrics.auc(labels, preds)", "retain": " def test_update_metric_by_small_chunks(self):\n labels = np.random.randint(0, 2, 1234)\n preds = np.random.random(1234)\n auc = tf.keras.metrics.AUC()\n auc.update_state(labels, preds)\n auc_value_0 = auc.result()\n\n auc.reset_states()\n EvaluationMetrics._update_metric_by_small_chunk(auc, labels, preds)\n auc_value_1 = auc.result()\n self.assertEqual(auc_value_0, auc_value_1)" }, { "id": 16861, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def auc(y_true, y_pred):\n \"\"\"\n Description:\n Calculate the area under the curve (AUC).\n Args:\n :y_true (np.ndarray): ground truth class labels.\n :y_pred (np.ndarray): predicted class labels.\n Returns:\n area under curve auc (float) - the total number of false positives during evaluation.\n \"\"\"\n auc_ = tf.keras.metrics.AUC(num_thresholds=3)\n auc_.update_state(y_true, y_pred)\n auc_result = auc_.result().numpy()\n\n # auc = tf.keras.metrics.AUC(y_true, y_pred)#[1]\n return auc_result", "probing input": "def auc(y_true, y_pred):\n \"\"\"\n Description:\n Calculate the area under the curve (AUC).\n Args:\n :y_true (np.ndarray): ground truth class labels.\n :y_pred (np.ndarray): predicted class labels.\n Returns:\n area under curve auc (float) - the total number of false positives during evaluation.\n \"\"\"\n", "probing input new": "def auc(y_true, y_pred):\n \"\"\"\n Description:\n Calculate the area under the curve (AUC).\n Args:\n :y_true (np.ndarray): ground truth class labels.\n :y_pred (np.ndarray): predicted class labels.\n Returns:\n area under curve auc (float) - the total number of false positives during evaluation.\n \"\"\"\n auc_ = tf.", "reference": "auc_=tf.keras.metrics.AUC(num_thresholds=3)", "reference dict": { "auc_": "tf.keras.metrics.AUC" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial", "tensorflow.keras.metrics.AUC": "tensorflow.keras.metrics.AUC" }, "deprecated api": [ "tensorflow.metrics.auc", "tensorflow.compat.v1.metrics.auc" ], "replacement api": "tensorflow.keras.metrics.AUC", "expected call": "tf.keras.metrics.AUC", "y_pos": "auc_=tf.keras.metrics.AUC(num_thresholds=3)", "y_neg": " auc_ = tf.metrics.auc(y_true, y_pred)", "retain": "def auc(y_true, y_pred):\n \"\"\"\n Description:\n Calculate the area under the curve (AUC).\n Args:\n :y_true (np.ndarray): ground truth class labels.\n :y_pred (np.ndarray): predicted class labels.\n Returns:\n area under curve auc (float) - the total number of false positives during evaluation.\n \"\"\"\n auc_ = tf.keras.metrics.AUC(num_thresholds=3)\n auc_.update_state(y_true, y_pred)\n auc_result = auc_.result().numpy()\n\n # auc = tf.keras.metrics.AUC(y_true, y_pred)#[1]\n return auc_result" }, { "id": 16927, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def print_metrics(metrics, step, every, decimals=2, name='metrics'):\n factor = 10 ** decimals\n means, updates = [], []\n for key, value in metrics.items():\n key = 'metrics_{}_{}'.format(name, key)\n mean = tools.StreamingMean((), tf.float32, key)\n means.append(mean)\n updates.append(mean.submit(value))\n with tf.control_dependencies(updates):\n message = '{}: step/{} ='.format(name, '/'.join(metrics.keys()))\n print_metrics = tf.cond(\n tf.equal(step % every, 0),\n lambda: tf.print(message, [step] + [\n tf.round(mean.clear() * factor) / factor for mean in means]),\n tf.no_op)\n return print_metrics", "probing input": "def print_metrics(metrics, step, every, decimals=2, name='metrics'):\n factor = 10 ** decimals\n means, updates = [], []\n for key, value in metrics.items():\n key = 'metrics_{}_{}'.format(name, key)\n mean = tools.StreamingMean((), tf.float32, key)\n means.append(mean)\n updates.append(mean.submit(value))\n with tf.control_dependencies(updates):\n message = '{}: step/{} ='.format(name, '/'.join(metrics.keys()))\n print_metrics = tf.cond(\n tf.equal(step % every, 0),\n", "probing input new": "def print_metrics(metrics, step, every, decimals=2, name='metrics'):\n factor = 10 ** decimals\n means, updates = [], []\n for key, value in metrics.items():\n key = 'metrics_{}_{}'.format(name, key)\n mean = tools.StreamingMean((), tf.float32, key)\n means.append(mean)\n updates.append(mean.submit(value))\n with tf.control_dependencies(updates):\n message = '{}: step/{} ='.format(name, '/'.join(metrics.keys()))\n print_metrics = tf.cond(\n tf.equal(step % every, 0),\n lambda: tf.", "reference": "lambda:tf.print(message,[step]+[tf.round(mean.clear()*factor)/factorformeaninmeans]),", "reference dict": { "mean": "tools.StreamingMean" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.Print", "tensorflow.Print" ], "replacement api": "tensorflow.print", "expected call": "tf.print", "y_pos": "lambda:tf.print(message,[step]+[tf.round(mean.clear()*factor)/factorformeaninmeans]),", "y_neg": " lambda: tf.Print(tf.constant(message), [mean.result()]),", "retain": "def print_metrics(metrics, step, every, decimals=2, name='metrics'):\n factor = 10 ** decimals\n means, updates = [], []\n for key, value in metrics.items():\n key = 'metrics_{}_{}'.format(name, key)\n mean = tools.StreamingMean((), tf.float32, key)\n means.append(mean)\n updates.append(mean.submit(value))\n with tf.control_dependencies(updates):\n message = '{}: step/{} ='.format(name, '/'.join(metrics.keys()))\n print_metrics = tf.cond(\n tf.equal(step % every, 0),\n lambda: tf.print(message, [step] + [\n tf.round(mean.clear() * factor) / factor for mean in means]),\n tf.no_op)\n return print_metrics" }, { "id": 16997, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def sum_normalize(cs, axis=TensorAxis.C):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.divide(cs, reduce_sum, name='sumNormalized')", "probing input": " def sum_normalize(cs, axis=TensorAxis.C):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n", "probing input new": " def sum_normalize(cs, axis=TensorAxis.C):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.", "reference": "returntf.divide(cs,reduce_sum,name='sumNormalized')", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "returntf.divide(cs,reduce_sum,name='sumNormalized')", "y_neg": " return tf.div(cs, reduce_sum, name='normalized')", "retain": " def sum_normalize(cs, axis=TensorAxis.C):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.divide(cs, reduce_sum, name='sumNormalized')" }, { "id": 16999, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def vgg_loss(feat_net, feat_weights, n_layers, reg=0.1):\n def loss_fcn(y_true, y_pred):\n y_true_feat = feat_net(Lambda(vgg_preprocess)(y_true))\n y_pred_feat = feat_net(Lambda(vgg_preprocess)(y_pred))\n\n loss = []\n for j in range(n_layers):\n\n std = feat_weights[str(j)][1] + reg\n std = tf.expand_dims(tf.expand_dims(tf.expand_dims(std, 0), 0), 0)\n d = tf.subtract(y_true_feat[j], y_pred_feat[j])\n loss_j = tf.reduce_mean(tf.abs(tf.divide(d, std)))\n\n if j == 0:\n loss = loss_j\n else:\n loss = tf.add(loss, loss_j)\n return loss / (n_layers * 1.0)\n\n return loss_fcn", "probing input": "def vgg_loss(feat_net, feat_weights, n_layers, reg=0.1):\n def loss_fcn(y_true, y_pred):\n y_true_feat = feat_net(Lambda(vgg_preprocess)(y_true))\n y_pred_feat = feat_net(Lambda(vgg_preprocess)(y_pred))\n\n loss = []\n for j in range(n_layers):\n\n std = feat_weights[str(j)][1] + reg\n std = tf.expand_dims(tf.expand_dims(tf.expand_dims(std, 0), 0), 0)\n d = tf.subtract(y_true_feat[j], y_pred_feat[j])\n", "probing input new": "def vgg_loss(feat_net, feat_weights, n_layers, reg=0.1):\n def loss_fcn(y_true, y_pred):\n y_true_feat = feat_net(Lambda(vgg_preprocess)(y_true))\n y_pred_feat = feat_net(Lambda(vgg_preprocess)(y_pred))\n\n loss = []\n for j in range(n_layers):\n\n std = feat_weights[str(j)][1] + reg\n std = tf.expand_dims(tf.expand_dims(tf.expand_dims(std, 0), 0), 0)\n d = tf.subtract(y_true_feat[j], y_pred_feat[j])\n loss_j = tf.reduce_mean(tf.abs(tf.", "reference": "loss_j=tf.reduce_mean(tf.abs(tf.divide(d,std)))", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "loss_j=tf.reduce_mean(tf.abs(tf.divide(d,std)))", "y_neg": " loss_j = tf.reduce_mean(tf.abs(tf.div(d, std)))", "retain": "def vgg_loss(feat_net, feat_weights, n_layers, reg=0.1):\n def loss_fcn(y_true, y_pred):\n y_true_feat = feat_net(Lambda(vgg_preprocess)(y_true))\n y_pred_feat = feat_net(Lambda(vgg_preprocess)(y_pred))\n\n loss = []\n for j in range(n_layers):\n\n std = feat_weights[str(j)][1] + reg\n std = tf.expand_dims(tf.expand_dims(tf.expand_dims(std, 0), 0), 0)\n d = tf.subtract(y_true_feat[j], y_pred_feat[j])\n loss_j = tf.reduce_mean(tf.abs(tf.divide(d, std)))\n\n if j == 0:\n loss = loss_j\n else:\n loss = tf.add(loss, loss_j)\n return loss / (n_layers * 1.0)\n\n return loss_fcn" }, { "id": 17000, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "config.gpu_options.allow_growth=True\n\n\n\n\n# Create directories\nif not os.path.exists(model_path):\n os.makedirs(model_path)\nif not os.path.exists(gifs_path):\n os.makedirs(gifs_path)\n\n\nglobal_step = tf.placeholder(tf.float32)\n \nif ADAPT_LR:\n # computes LR_Q/sqrt(ADAPT_COEFF*steps+1)\n # we need the +1 so that lr at step 0 is defined\n lr = tf.divide(tf.constant(LR_Q), tf.sqrt(tf.add(1., tf.multiply(tf.constant(ADAPT_COEFF), global_step))))\nelse:\n lr = tf.constant(LR_Q)", "probing input": "config.gpu_options.allow_growth=True\n\n\n\n\n# Create directories\nif not os.path.exists(model_path):\n os.makedirs(model_path)\nif not os.path.exists(gifs_path):\n os.makedirs(gifs_path)\n\n\nglobal_step = tf.placeholder(tf.float32)\n \nif ADAPT_LR:\n # computes LR_Q/sqrt(ADAPT_COEFF*steps+1)\n # we need the +1 so that lr at step 0 is defined\n", "probing input new": "config.gpu_options.allow_growth=True\n\n\n\n\n# Create directories\nif not os.path.exists(model_path):\n os.makedirs(model_path)\nif not os.path.exists(gifs_path):\n os.makedirs(gifs_path)\n\n\nglobal_step = tf.placeholder(tf.float32)\n \nif ADAPT_LR:\n # computes LR_Q/sqrt(ADAPT_COEFF*steps+1)\n # we need the +1 so that lr at step 0 is defined\n lr = tf.", "reference": "lr=tf.divide(tf.constant(LR_Q),tf.sqrt(tf.add(1.,tf.multiply(tf.constant(ADAPT_COEFF),global_step))))", "reference dict": { "config": "tf.ConfigProto" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "lr=tf.divide(tf.constant(LR_Q),tf.sqrt(tf.add(1.,tf.multiply(tf.constant(ADAPT_COEFF),global_step))))", "y_neg": " lr = tf.maximum(tf.div(tf.constant(LR_Q, dtype=tf.float32) / tf.sqrt(tf.constant(ADAPT_COEFF, dtype=tf.float32) * global_step + tf.constant(1, dtype=tf.float32)), tf.constant(0.001, dtype=tf.float32)), tf.constant(0.0001, dtype=tf.float32))", "retain": "config.gpu_options.allow_growth=True\n\n\n\n\n# Create directories\nif not os.path.exists(model_path):\n os.makedirs(model_path)\nif not os.path.exists(gifs_path):\n os.makedirs(gifs_path)\n\n\nglobal_step = tf.placeholder(tf.float32)\n \nif ADAPT_LR:\n # computes LR_Q/sqrt(ADAPT_COEFF*steps+1)\n # we need the +1 so that lr at step 0 is defined\n lr = tf.divide(tf.constant(LR_Q), tf.sqrt(tf.add(1., tf.multiply(tf.constant(ADAPT_COEFF), global_step))))\nelse:\n lr = tf.constant(LR_Q)" }, { "id": 17026, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n forward_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.divide(forward, forward_norm)\n\n to_side = tf.cross(forward, world_up)\n to_side_norm = tf.norm(to_side, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n to_side_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because up and gaze are close or'\n 'because up is degenerate.')\n to_side = tf.divide(to_side, to_side_norm)\n cam_up = tf.cross(to_side, forward)\n\n w_column = tf.constant(\n batch_size * [[0., 0., 0., 1.]], dtype=tf.float32) # [batch_size, 4]\n w_column = tf.reshape(w_column, [batch_size, 4, 1])\n view_rotation = tf.stack(\n [to_side, cam_up, -forward,\n tf.zeros_like(to_side, dtype=tf.float32)],\n axis=1) # [batch_size, 4, 3] matrix\n view_rotation = tf.concat(\n [view_rotation, w_column], axis=2) # [batch_size, 4, 4]\n\n identity_batch = tf.tile(tf.expand_dims(tf.eye(3), 0), [batch_size, 1, 1])\n view_translation = tf.concat([identity_batch, tf.expand_dims(-eye, 2)], 2)\n view_translation = tf.concat(\n [view_translation,\n tf.reshape(w_column, [batch_size, 1, 4])], 1)\n camera_matrices = tf.matmul(view_rotation, view_translation)\n return camera_matrices", "probing input": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n forward_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because eye and center are close.')\n", "probing input new": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n forward_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.", "reference": "forward=tf.divide(forward,forward_norm)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "forward=tf.divide(forward,forward_norm)", "y_neg": " forward = tf.div(forward, forward_norm, name='forward')", "retain": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n forward_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.divide(forward, forward_norm)\n\n to_side = tf.cross(forward, world_up)\n to_side_norm = tf.norm(to_side, ord='euclidean', axis=1, keep_dims=True)\n tf.assert_greater(\n to_side_norm,\n vector_degeneracy_cutoff,\n message='Camera matrix is degenerate because up and gaze are close or'\n 'because up is degenerate.')\n to_side = tf.divide(to_side, to_side_norm)\n cam_up = tf.cross(to_side, forward)\n\n w_column = tf.constant(\n batch_size * [[0., 0., 0., 1.]], dtype=tf.float32) # [batch_size, 4]\n w_column = tf.reshape(w_column, [batch_size, 4, 1])\n view_rotation = tf.stack(\n [to_side, cam_up, -forward,\n tf.zeros_like(to_side, dtype=tf.float32)],\n axis=1) # [batch_size, 4, 3] matrix\n view_rotation = tf.concat(\n [view_rotation, w_column], axis=2) # [batch_size, 4, 4]\n\n identity_batch = tf.tile(tf.expand_dims(tf.eye(3), 0), [batch_size, 1, 1])\n view_translation = tf.concat([identity_batch, tf.expand_dims(-eye, 2)], 2)\n view_translation = tf.concat(\n [view_translation,\n tf.reshape(w_column, [batch_size, 1, 4])], 1)\n camera_matrices = tf.matmul(view_rotation, view_translation)\n return camera_matrices" }, { "id": 17035, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def sum_normalize(cs, axis=3):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.divide(cs, reduce_sum, name='sumNormalized')", "probing input": " def sum_normalize(cs, axis=3):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n", "probing input new": " def sum_normalize(cs, axis=3):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.", "reference": "returntf.divide(cs,reduce_sum,name='sumNormalized')", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "returntf.divide(cs,reduce_sum,name='sumNormalized')", "y_neg": " return tf.div(cs, reduce_sum, name='normalized')", "retain": " def sum_normalize(cs, axis=3):\n reduce_sum = tf.reduce_sum(cs, axis, keep_dims=True, name='sum')\n return tf.divide(cs, reduce_sum, name='sumNormalized')" }, { "id": 17044, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def calculate_contextual_similarity(scaled_distances, sigma=float(0.1), b=float(1.0)):\n cs = tf.exp((b - scaled_distances) / sigma)\n reduce_sum = tf.reduce_sum(cs, axis=3, keepdims=True)\n cs_norm = tf.divide(cs, reduce_sum)\n return cs_norm", "probing input": "def calculate_contextual_similarity(scaled_distances, sigma=float(0.1), b=float(1.0)):\n cs = tf.exp((b - scaled_distances) / sigma)\n reduce_sum = tf.reduce_sum(cs, axis=3, keepdims=True)\n", "probing input new": "def calculate_contextual_similarity(scaled_distances, sigma=float(0.1), b=float(1.0)):\n cs = tf.exp((b - scaled_distances) / sigma)\n reduce_sum = tf.reduce_sum(cs, axis=3, keepdims=True)\n cs_norm = tf.", "reference": "cs_norm=tf.divide(cs,reduce_sum)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "cs_norm=tf.divide(cs,reduce_sum)", "y_neg": " cs_norm = tf.div(cs, reduce_sum)", "retain": "def calculate_contextual_similarity(scaled_distances, sigma=float(0.1), b=float(1.0)):\n cs = tf.exp((b - scaled_distances) / sigma)\n reduce_sum = tf.reduce_sum(cs, axis=3, keepdims=True)\n cs_norm = tf.divide(cs, reduce_sum)\n return cs_norm" }, { "id": 17046, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def r2_op(predictions, targets):\n \"\"\" r2_op.\n\n An op that calculates the standard error.\n\n Examples:\n ```python\n input_data = placeholder(shape=[None, 784])\n y_pred = my_network(input_data) # Apply some ops\n y_true = placeholder(shape=[None, 10]) # Labels\n stderr_op = r2_op(y_pred, y_true)\n\n # Calculate standard error by feeding data X and labels Y\n std_error = sess.run(stderr_op, feed_dict={input_data: X, y_true: Y})\n ```\n\n Arguments:\n predictions: `Tensor`.\n targets: `Tensor`.\n\n Returns:\n `Float`. The standard error.\n\n \"\"\"\n with tf.name_scope('StandardError'):\n a = tf.reduce_sum(tf.square(predictions))\n b = tf.reduce_sum(tf.square(targets))\n return tf.divide(a, b)", "probing input": "def r2_op(predictions, targets):\n \"\"\" r2_op.\n\n An op that calculates the standard error.\n\n Examples:\n ```python\n input_data = placeholder(shape=[None, 784])\n y_pred = my_network(input_data) # Apply some ops\n y_true = placeholder(shape=[None, 10]) # Labels\n stderr_op = r2_op(y_pred, y_true)\n\n # Calculate standard error by feeding data X and labels Y\n std_error = sess.run(stderr_op, feed_dict={input_data: X, y_true: Y})\n ```\n\n Arguments:\n predictions: `Tensor`.\n targets: `Tensor`.\n\n Returns:\n `Float`. The standard error.\n\n \"\"\"\n with tf.name_scope('StandardError'):\n a = tf.reduce_sum(tf.square(predictions))\n b = tf.reduce_sum(tf.square(targets))\n", "probing input new": "def r2_op(predictions, targets):\n \"\"\" r2_op.\n\n An op that calculates the standard error.\n\n Examples:\n ```python\n input_data = placeholder(shape=[None, 784])\n y_pred = my_network(input_data) # Apply some ops\n y_true = placeholder(shape=[None, 10]) # Labels\n stderr_op = r2_op(y_pred, y_true)\n\n # Calculate standard error by feeding data X and labels Y\n std_error = sess.run(stderr_op, feed_dict={input_data: X, y_true: Y})\n ```\n\n Arguments:\n predictions: `Tensor`.\n targets: `Tensor`.\n\n Returns:\n `Float`. The standard error.\n\n \"\"\"\n with tf.name_scope('StandardError'):\n a = tf.reduce_sum(tf.square(predictions))\n b = tf.reduce_sum(tf.square(targets))\n return tf.", "reference": "returntf.divide(a,b)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "returntf.divide(a,b)", "y_neg": " return tf.subtract(a, tf.div(tf.square(tf.reduce_mean(predictions)), b))", "retain": "def r2_op(predictions, targets):\n \"\"\" r2_op.\n\n An op that calculates the standard error.\n\n Examples:\n ```python\n input_data = placeholder(shape=[None, 784])\n y_pred = my_network(input_data) # Apply some ops\n y_true = placeholder(shape=[None, 10]) # Labels\n stderr_op = r2_op(y_pred, y_true)\n\n # Calculate standard error by feeding data X and labels Y\n std_error = sess.run(stderr_op, feed_dict={input_data: X, y_true: Y})\n ```\n\n Arguments:\n predictions: `Tensor`.\n targets: `Tensor`.\n\n Returns:\n `Float`. The standard error.\n\n \"\"\"\n with tf.name_scope('StandardError'):\n a = tf.reduce_sum(tf.square(predictions))\n b = tf.reduce_sum(tf.square(targets))\n return tf.divide(a, b)" }, { "id": 17075, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def softmax_sample(labels, predicted_scores):\n\n\tpredicted_scores = tf.reshape(predicted_scores, [-1, 1])\n\tlabels = tf.reshape(labels, [-1, 1])\n\tn_data = tf.shape(labels)[0]\n\t# # [[1. 0. 0.]]\n\ttransposed_predicted_scores = tf.transpose(predicted_scores)\n\texps = tf.exp(transposed_predicted_scores)\n\t# # keep it substruct \n\texp_sum = tf.reduce_sum(exps)\n\t# # [[0.5761169 0.21194157 0.21194157]]\n\tsoftmax_scores = tf.divide(exps, exp_sum)\n\t# # [[1]]\n\taction_0_index = tf.multinomial(softmax_scores, 1)\n\taction_0_index = tf.cast(action_0_index, tf.int32)\n\taction_0 = tf.gather(tf.transpose(transposed_predicted_scores), tf.reshape(action_0_index, [-1, 1]))\n\taction_0 = tf.reshape(action_0, [1, -1])\n\tactions = action_0\n\t# labels have always been vertical\n\tlabel_0 = tf.gather(labels, tf.reshape(action_0_index, [-1, 1]))\n\tlabel_0 = tf.reshape(label_0, [1, -1])\n\tnew_labels = label_0\n\n\n\tindices = tf.range(n_data, dtype=tf.int32)\n\tkeep_indices = tf.where(tf.not_equal(indices, tf.squeeze(action_0_index)))\n\tkeep_predicted_scores = tf.gather_nd(tf.transpose(transposed_predicted_scores), keep_indices)\n\tkeep_predicted_scores = tf.transpose(keep_predicted_scores)\n\t# labels have always been vertical\n\t# keep_labels have always been vertical\n\tkeep_labels = tf.gather_nd(labels, keep_indices)\n\n\titeration = n_data - 1\n\tshape_invariants = [iteration.get_shape(), tf.TensorShape([1, None]), \n\ttf.TensorShape([None, 1]), tf.TensorShape([None, 1]), tf.TensorShape([None, 1])]\n\n\tdef _cond(iteration, keep_predicted_scores, actions, keep_labels, new_labels):\n\t return tf.greater(iteration, 1)\n\n\tdef _gen_loop_body():\n\t def loop_body(iteration, keep_predicted_scores, actions, keep_labels, new_labels):\n\n\t exps = tf.exp(keep_predicted_scores)\n\t # # keep it substruct \n\t exp_sum = tf.reduce_sum(exps)\n\t # # [[0.5761169 0.21194157 0.21194157]]\n\t softmax_scores = tf.divide(exps, exp_sum)\n\t # # [[1]]\n\t action_i_index = tf.multinomial(softmax_scores, 1)\n\t action_i_index = tf.cast(action_i_index, tf.int32)\n\t action_i = tf.gather(tf.transpose(keep_predicted_scores), tf.reshape(action_i_index, [-1, 1]))\n\t action_i = tf.reshape(action_i, [1, -1])\n\t actions = tf.concat([actions, action_i], 0)\n\t # similar for labels\n\t label_i = tf.gather(keep_labels, tf.reshape(action_i_index, [-1, 1]))\n\t label_i = tf.reshape(label_i, [1, -1])\n\t new_labels = tf.concat([new_labels, label_i], 0)\n\t \n\t indices = tf.range(iteration, dtype=tf.int32)\n\t keep_indices = tf.where(tf.not_equal(indices, tf.squeeze(action_i_index)))\n\t vertical_keep_tensor = tf.gather_nd(tf.transpose(keep_predicted_scores), keep_indices)\n\t keep_predicted_scores = tf.transpose(vertical_keep_tensor)\n\t \n\t # labels have always been vertical\n\t # keep_labels have always been vertical\n\t keep_labels = tf.gather_nd(keep_labels, keep_indices) \n\t \n\t return tf.subtract(iteration, 1), keep_predicted_scores, actions, keep_labels, new_labels\n\t return loop_body\n\n\titeration, keep_predicted_scores, actions, keep_labels, new_labels = tf.while_loop(_cond, _gen_loop_body(),\n\t[iteration, keep_predicted_scores, actions, keep_labels, new_labels], shape_invariants=shape_invariants)\t\n\t# the final action\n\tactions = tf.concat([actions, keep_predicted_scores], 0)\n\tnew_labels = tf.concat([new_labels, keep_labels], 0)\n\tnew_labels = tf.reshape(new_labels, [-1, 1])\n\tactions = tf.reshape(actions, [-1, 1])\n\treturn new_labels, actions", "probing input": "def softmax_sample(labels, predicted_scores):\n\n\tpredicted_scores = tf.reshape(predicted_scores, [-1, 1])\n\tlabels = tf.reshape(labels, [-1, 1])\n\tn_data = tf.shape(labels)[0]\n\t# # [[1. 0. 0.]]\n\ttransposed_predicted_scores = tf.transpose(predicted_scores)\n\texps = tf.exp(transposed_predicted_scores)\n\t# # keep it substruct \n\texp_sum = tf.reduce_sum(exps)\n\t# # [[0.5761169 0.21194157 0.21194157]]\n", "probing input new": "def softmax_sample(labels, predicted_scores):\n\n\tpredicted_scores = tf.reshape(predicted_scores, [-1, 1])\n\tlabels = tf.reshape(labels, [-1, 1])\n\tn_data = tf.shape(labels)[0]\n\t# # [[1. 0. 0.]]\n\ttransposed_predicted_scores = tf.transpose(predicted_scores)\n\texps = tf.exp(transposed_predicted_scores)\n\t# # keep it substruct \n\texp_sum = tf.reduce_sum(exps)\n\t# # [[0.5761169 0.21194157 0.21194157]]\n\tsoftmax_scores = tf.", "reference": "softmax_scores=tf.divide(exps,exp_sum)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "softmax_scores=tf.divide(exps,exp_sum)", "y_neg": "\tsoftmax_scores = tf.div(exps, exp_sum)", "retain": "def softmax_sample(labels, predicted_scores):\n\n\tpredicted_scores = tf.reshape(predicted_scores, [-1, 1])\n\tlabels = tf.reshape(labels, [-1, 1])\n\tn_data = tf.shape(labels)[0]\n\t# # [[1. 0. 0.]]\n\ttransposed_predicted_scores = tf.transpose(predicted_scores)\n\texps = tf.exp(transposed_predicted_scores)\n\t# # keep it substruct \n\texp_sum = tf.reduce_sum(exps)\n\t# # [[0.5761169 0.21194157 0.21194157]]\n\tsoftmax_scores = tf.divide(exps, exp_sum)\n\t# # [[1]]\n\taction_0_index = tf.multinomial(softmax_scores, 1)\n\taction_0_index = tf.cast(action_0_index, tf.int32)\n\taction_0 = tf.gather(tf.transpose(transposed_predicted_scores), tf.reshape(action_0_index, [-1, 1]))\n\taction_0 = tf.reshape(action_0, [1, -1])\n\tactions = action_0\n\t# labels have always been vertical\n\tlabel_0 = tf.gather(labels, tf.reshape(action_0_index, [-1, 1]))\n\tlabel_0 = tf.reshape(label_0, [1, -1])\n\tnew_labels = label_0\n\n\n\tindices = tf.range(n_data, dtype=tf.int32)\n\tkeep_indices = tf.where(tf.not_equal(indices, tf.squeeze(action_0_index)))\n\tkeep_predicted_scores = tf.gather_nd(tf.transpose(transposed_predicted_scores), keep_indices)\n\tkeep_predicted_scores = tf.transpose(keep_predicted_scores)\n\t# labels have always been vertical\n\t# keep_labels have always been vertical\n\tkeep_labels = tf.gather_nd(labels, keep_indices)\n\n\titeration = n_data - 1\n\tshape_invariants = [iteration.get_shape(), tf.TensorShape([1, None]), \n\ttf.TensorShape([None, 1]), tf.TensorShape([None, 1]), tf.TensorShape([None, 1])]\n\n\tdef _cond(iteration, keep_predicted_scores, actions, keep_labels, new_labels):\n\t return tf.greater(iteration, 1)\n\n\tdef _gen_loop_body():\n\t def loop_body(iteration, keep_predicted_scores, actions, keep_labels, new_labels):\n\n\t exps = tf.exp(keep_predicted_scores)\n\t # # keep it substruct \n\t exp_sum = tf.reduce_sum(exps)\n\t # # [[0.5761169 0.21194157 0.21194157]]\n\t softmax_scores = tf.divide(exps, exp_sum)\n\t # # [[1]]\n\t action_i_index = tf.multinomial(softmax_scores, 1)\n\t action_i_index = tf.cast(action_i_index, tf.int32)\n\t action_i = tf.gather(tf.transpose(keep_predicted_scores), tf.reshape(action_i_index, [-1, 1]))\n\t action_i = tf.reshape(action_i, [1, -1])\n\t actions = tf.concat([actions, action_i], 0)\n\t # similar for labels\n\t label_i = tf.gather(keep_labels, tf.reshape(action_i_index, [-1, 1]))\n\t label_i = tf.reshape(label_i, [1, -1])\n\t new_labels = tf.concat([new_labels, label_i], 0)\n\t \n\t indices = tf.range(iteration, dtype=tf.int32)\n\t keep_indices = tf.where(tf.not_equal(indices, tf.squeeze(action_i_index)))\n\t vertical_keep_tensor = tf.gather_nd(tf.transpose(keep_predicted_scores), keep_indices)\n\t keep_predicted_scores = tf.transpose(vertical_keep_tensor)\n\t \n\t # labels have always been vertical\n\t # keep_labels have always been vertical\n\t keep_labels = tf.gather_nd(keep_labels, keep_indices) \n\t \n\t return tf.subtract(iteration, 1), keep_predicted_scores, actions, keep_labels, new_labels\n\t return loop_body\n\n\titeration, keep_predicted_scores, actions, keep_labels, new_labels = tf.while_loop(_cond, _gen_loop_body(),\n\t[iteration, keep_predicted_scores, actions, keep_labels, new_labels], shape_invariants=shape_invariants)\t\n\t# the final action\n\tactions = tf.concat([actions, keep_predicted_scores], 0)\n\tnew_labels = tf.concat([new_labels, keep_labels], 0)\n\tnew_labels = tf.reshape(new_labels, [-1, 1])\n\tactions = tf.reshape(actions, [-1, 1])\n\treturn new_labels, actions" }, { "id": 17078, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def shape2image(self, channels, height, width, resize=None):\n \"\"\" This function shapes the input instance to image tensor\n\n :param channels:\n :param height:\n :param width:\n :param resize: list of tuple\n :type resize: list, tuple\n :return:\n \"\"\"\n\n def image_preprocessor(image):\n # scale image to [-1,1]\n image = tf.subtract(tf.divide(image, 127.5), 1)\n # reshape - note this is determined by how the data is stored in tfrecords, modify with caution\n image = tf.reshape(image, (channels, height, width)) \\\n if FLAGS.IMAGE_FORMAT == 'channels_first' else tf.reshape(image, (height, width, channels))\n # resize\n if isinstance(resize, (list, tuple)):\n if FLAGS.IMAGE_FORMAT == 'channels_first':\n image = tf.transpose(\n tf.image.resize_images( # resize only support HWC\n tf.transpose(image, perm=(1, 2, 0)), resize, align_corners=True), perm=(2, 0, 1))\n else:\n image = tf.image.resize_images(image, resize, align_corners=True)\n\n return image\n\n # do image pre-processing\n if self.num_labels == 0:\n self.dataset = self.dataset.map(\n lambda image_data: image_preprocessor(image_data),\n num_parallel_calls=self.num_threads)\n else:\n self.dataset = self.dataset.map(\n lambda image_data, label: (image_preprocessor(image_data), label),\n num_parallel_calls=self.num_threads)\n\n # write batch shape\n if isinstance(resize, (list, tuple)):\n height, width = resize\n self.batch_shape = [self.batch_size, height, width, channels] \\\n if FLAGS.IMAGE_FORMAT == 'channels_last' else [self.batch_size, channels, height, width]", "probing input": " def shape2image(self, channels, height, width, resize=None):\n \"\"\" This function shapes the input instance to image tensor\n\n :param channels:\n :param height:\n :param width:\n :param resize: list of tuple\n :type resize: list, tuple\n :return:\n \"\"\"\n\n def image_preprocessor(image):\n # scale image to [-1,1]\n", "probing input new": " def shape2image(self, channels, height, width, resize=None):\n \"\"\" This function shapes the input instance to image tensor\n\n :param channels:\n :param height:\n :param width:\n :param resize: list of tuple\n :type resize: list, tuple\n :return:\n \"\"\"\n\n def image_preprocessor(image):\n # scale image to [-1,1]\n image = tf.subtract(tf.", "reference": "image=tf.subtract(tf.divide(image,127.5),1)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "image=tf.subtract(tf.divide(image,127.5),1)", "y_neg": " image = tf.subtract(tf.div(image, 127.5), 1)", "retain": " def shape2image(self, channels, height, width, resize=None):\n \"\"\" This function shapes the input instance to image tensor\n\n :param channels:\n :param height:\n :param width:\n :param resize: list of tuple\n :type resize: list, tuple\n :return:\n \"\"\"\n\n def image_preprocessor(image):\n # scale image to [-1,1]\n image = tf.subtract(tf.divide(image, 127.5), 1)\n # reshape - note this is determined by how the data is stored in tfrecords, modify with caution\n image = tf.reshape(image, (channels, height, width)) \\\n if FLAGS.IMAGE_FORMAT == 'channels_first' else tf.reshape(image, (height, width, channels))\n # resize\n if isinstance(resize, (list, tuple)):\n if FLAGS.IMAGE_FORMAT == 'channels_first':\n image = tf.transpose(\n tf.image.resize_images( # resize only support HWC\n tf.transpose(image, perm=(1, 2, 0)), resize, align_corners=True), perm=(2, 0, 1))\n else:\n image = tf.image.resize_images(image, resize, align_corners=True)\n\n return image\n\n # do image pre-processing\n if self.num_labels == 0:\n self.dataset = self.dataset.map(\n lambda image_data: image_preprocessor(image_data),\n num_parallel_calls=self.num_threads)\n else:\n self.dataset = self.dataset.map(\n lambda image_data, label: (image_preprocessor(image_data), label),\n num_parallel_calls=self.num_threads)\n\n # write batch shape\n if isinstance(resize, (list, tuple)):\n height, width = resize\n self.batch_shape = [self.batch_size, height, width, channels] \\\n if FLAGS.IMAGE_FORMAT == 'channels_last' else [self.batch_size, channels, height, width]" }, { "id": 17093, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def compute_proximity_loss(self):\n \"\"\"Compute the second part (distance from x1) of the loss function.\"\"\"\n proximity_loss = 0.0\n for i in range(self.total_CFs):\n proximity_loss = tf.add(proximity_loss, self.compute_dist(\n self.cfs_frozen[i], self.x1))\n return tf.divide(proximity_loss, tf.cast(tf.multiply(len(self.minx[0]), self.total_CFs), dtype=tf.float32))", "probing input": " def compute_proximity_loss(self):\n \"\"\"Compute the second part (distance from x1) of the loss function.\"\"\"\n proximity_loss = 0.0\n for i in range(self.total_CFs):\n proximity_loss = tf.add(proximity_loss, self.compute_dist(\n self.cfs_frozen[i], self.x1))\n", "probing input new": " def compute_proximity_loss(self):\n \"\"\"Compute the second part (distance from x1) of the loss function.\"\"\"\n proximity_loss = 0.0\n for i in range(self.total_CFs):\n proximity_loss = tf.add(proximity_loss, self.compute_dist(\n self.cfs_frozen[i], self.x1))\n return tf.", "reference": "returntf.divide(proximity_loss,tf.cast(tf.multiply(len(self.minx[0]),self.total_CFs),dtype=tf.float32))", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "returntf.divide(proximity_loss,tf.cast(tf.multiply(len(self.minx[0]),self.total_CFs),dtype=tf.float32))", "y_neg": " return tf.div(proximity_loss, tf.cast(self.total_CFs, tf.float32))", "retain": " def compute_proximity_loss(self):\n \"\"\"Compute the second part (distance from x1) of the loss function.\"\"\"\n proximity_loss = 0.0\n for i in range(self.total_CFs):\n proximity_loss = tf.add(proximity_loss, self.compute_dist(\n self.cfs_frozen[i], self.x1))\n return tf.divide(proximity_loss, tf.cast(tf.multiply(len(self.minx[0]), self.total_CFs), dtype=tf.float32))" }, { "id": 17095, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def tone_mapper(image, gamma):\n \"\"\"Applies gamma correction to the input image.\n\n Tone maps the input image batch in order to make scenes with a high dynamic\n range viewable. The gamma correction factor is computed separately per image,\n but is shared between all provided channels. The exact function computed is:\n\n image_out = A*image_in^gamma, where A is an image-wide constant computed so\n that the maximum image value is approximately 1. The correction is applied\n to all channels.\n\n Args:\n image: 4-D float32 tensor with shape [batch_size, image_height,\n image_width, channel_count]. The batch of images to tone map.\n gamma: 0-D float32 nonnegative tensor. Values of gamma below one compress\n relative contrast in the image, and values above one increase it. A\n value of 1 is equivalent to scaling the image to have a maximum value\n of 1.\n Returns:\n 4-D float32 tensor with shape [batch_size, image_height, image_width,\n channel_count]. Contains the gamma-corrected images, clipped to the range\n [0, 1].\n \"\"\"\n batch_size = image.shape[0].value\n corrected_image = tf.pow(image, gamma)\n image_max = tf.reduce_max(tf.reshape(corrected_image, [batch_size, -1]),\n axis=1)\n scaled_image = tf.divide(corrected_image,\n tf.reshape(image_max, [batch_size, 1, 1, 1]))\n return tf.clip_by_value(scaled_image, 0.0, 1.0)", "probing input": "def tone_mapper(image, gamma):\n \"\"\"Applies gamma correction to the input image.\n\n Tone maps the input image batch in order to make scenes with a high dynamic\n range viewable. The gamma correction factor is computed separately per image,\n but is shared between all provided channels. The exact function computed is:\n\n image_out = A*image_in^gamma, where A is an image-wide constant computed so\n that the maximum image value is approximately 1. The correction is applied\n to all channels.\n\n Args:\n image: 4-D float32 tensor with shape [batch_size, image_height,\n image_width, channel_count]. The batch of images to tone map.\n gamma: 0-D float32 nonnegative tensor. Values of gamma below one compress\n relative contrast in the image, and values above one increase it. A\n value of 1 is equivalent to scaling the image to have a maximum value\n of 1.\n Returns:\n 4-D float32 tensor with shape [batch_size, image_height, image_width,\n channel_count]. Contains the gamma-corrected images, clipped to the range\n [0, 1].\n \"\"\"\n batch_size = image.shape[0].value\n corrected_image = tf.pow(image, gamma)\n image_max = tf.reduce_max(tf.reshape(corrected_image, [batch_size, -1]),\n axis=1)\n", "probing input new": "def tone_mapper(image, gamma):\n \"\"\"Applies gamma correction to the input image.\n\n Tone maps the input image batch in order to make scenes with a high dynamic\n range viewable. The gamma correction factor is computed separately per image,\n but is shared between all provided channels. The exact function computed is:\n\n image_out = A*image_in^gamma, where A is an image-wide constant computed so\n that the maximum image value is approximately 1. The correction is applied\n to all channels.\n\n Args:\n image: 4-D float32 tensor with shape [batch_size, image_height,\n image_width, channel_count]. The batch of images to tone map.\n gamma: 0-D float32 nonnegative tensor. Values of gamma below one compress\n relative contrast in the image, and values above one increase it. A\n value of 1 is equivalent to scaling the image to have a maximum value\n of 1.\n Returns:\n 4-D float32 tensor with shape [batch_size, image_height, image_width,\n channel_count]. Contains the gamma-corrected images, clipped to the range\n [0, 1].\n \"\"\"\n batch_size = image.shape[0].value\n corrected_image = tf.pow(image, gamma)\n image_max = tf.reduce_max(tf.reshape(corrected_image, [batch_size, -1]),\n axis=1)\n scaled_image = tf.", "reference": "scaled_image=tf.divide(corrected_image,tf.reshape(image_max,[batch_size,1,1,1]))", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "scaled_image=tf.divide(corrected_image,tf.reshape(image_max,[batch_size,1,1,1]))", "y_neg": " scaled_image = tf.div(corrected_image, tf.reshape(image_max, [batch_size, -1]))", "retain": "def tone_mapper(image, gamma):\n \"\"\"Applies gamma correction to the input image.\n\n Tone maps the input image batch in order to make scenes with a high dynamic\n range viewable. The gamma correction factor is computed separately per image,\n but is shared between all provided channels. The exact function computed is:\n\n image_out = A*image_in^gamma, where A is an image-wide constant computed so\n that the maximum image value is approximately 1. The correction is applied\n to all channels.\n\n Args:\n image: 4-D float32 tensor with shape [batch_size, image_height,\n image_width, channel_count]. The batch of images to tone map.\n gamma: 0-D float32 nonnegative tensor. Values of gamma below one compress\n relative contrast in the image, and values above one increase it. A\n value of 1 is equivalent to scaling the image to have a maximum value\n of 1.\n Returns:\n 4-D float32 tensor with shape [batch_size, image_height, image_width,\n channel_count]. Contains the gamma-corrected images, clipped to the range\n [0, 1].\n \"\"\"\n batch_size = image.shape[0].value\n corrected_image = tf.pow(image, gamma)\n image_max = tf.reduce_max(tf.reshape(corrected_image, [batch_size, -1]),\n axis=1)\n scaled_image = tf.divide(corrected_image,\n tf.reshape(image_max, [batch_size, 1, 1, 1]))\n return tf.clip_by_value(scaled_image, 0.0, 1.0)" }, { "id": 17098, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # forward_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.divide(forward, forward_norm)\n\n to_side = tf.linalg.cross(forward, world_up)\n to_side_norm = tf.norm(to_side, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # to_side_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because up and gaze are close or'\n # 'because up is degenerate.')\n to_side = tf.divide(to_side, to_side_norm)\n cam_up = tf.linalg.cross(to_side, forward)\n\n w_column = tf.constant(\n batch_size * [[0., 0., 0., 1.]], dtype=tf.float32) # [batch_size, 4]\n w_column = tf.reshape(w_column, [batch_size, 4, 1])\n view_rotation = tf.stack(\n [to_side, cam_up, -forward,\n tf.zeros_like(to_side, dtype=tf.float32)],\n axis=1) # [batch_size, 4, 3] matrix\n view_rotation = tf.concat(\n [view_rotation, w_column], axis=2) # [batch_size, 4, 4]\n\n identity_batch = tf.tile(tf.expand_dims(tf.eye(3), 0), [batch_size, 1, 1])\n view_translation = tf.concat([identity_batch, tf.expand_dims(-eye, 2)], 2)\n view_translation = tf.concat(\n [view_translation,\n tf.reshape(w_column, [batch_size, 1, 4])], 1)\n camera_matrices = tf.matmul(view_rotation, view_translation)\n return camera_matrices", "probing input": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # forward_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because eye and center are close.')\n", "probing input new": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # forward_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.", "reference": "forward=tf.divide(forward,forward_norm)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.div", "tensorflow.div" ], "replacement api": "tensorflow.divide", "expected call": "tf.divide", "y_pos": "forward=tf.divide(forward,forward_norm)", "y_neg": " forward = tf.div(forward, forward_norm, name='forward')", "retain": "def look_at(eye, center, world_up):\n \"\"\"Computes camera viewing matrices.\n\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] containing a position\n along the center of the camera's gaze.\n world_up: 2-D float32 tensor with shape [batch_size, 3] specifying the\n world's up direction; the output camera will have no tilt with respect\n to this direction.\n\n Returns:\n A [batch_size, 4, 4] float tensor containing a right-handed camera\n extrinsics matrix that maps points from world space to points in eye space.\n \"\"\"\n batch_size = center.shape[0].value\n vector_degeneracy_cutoff = 1e-6\n forward = center - eye\n forward_norm = tf.norm(forward, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # forward_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because eye and center are close.')\n forward = tf.divide(forward, forward_norm)\n\n to_side = tf.linalg.cross(forward, world_up)\n to_side_norm = tf.norm(to_side, ord='euclidean', axis=1, keepdims=True)\n #tf.assert_greater(\n # to_side_norm,\n # vector_degeneracy_cutoff,\n # message='Camera matrix is degenerate because up and gaze are close or'\n # 'because up is degenerate.')\n to_side = tf.divide(to_side, to_side_norm)\n cam_up = tf.linalg.cross(to_side, forward)\n\n w_column = tf.constant(\n batch_size * [[0., 0., 0., 1.]], dtype=tf.float32) # [batch_size, 4]\n w_column = tf.reshape(w_column, [batch_size, 4, 1])\n view_rotation = tf.stack(\n [to_side, cam_up, -forward,\n tf.zeros_like(to_side, dtype=tf.float32)],\n axis=1) # [batch_size, 4, 3] matrix\n view_rotation = tf.concat(\n [view_rotation, w_column], axis=2) # [batch_size, 4, 4]\n\n identity_batch = tf.tile(tf.expand_dims(tf.eye(3), 0), [batch_size, 1, 1])\n view_translation = tf.concat([identity_batch, tf.expand_dims(-eye, 2)], 2)\n view_translation = tf.concat(\n [view_translation,\n tf.reshape(w_column, [batch_size, 1, 4])], 1)\n camera_matrices = tf.matmul(view_rotation, view_translation)\n return camera_matrices" }, { "id": 17811, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def _init_optimizer(self):\n # 整理输出并计算loss\n logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n targets = tf.transpose(self.decoder_train_targets, [1, 0])\n self.logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n self.targets = tf.transpose(self.decoder_train_targets, [1, 0])\n\n self.loss = seq2seq.sequence_loss(logits=logits, targets=targets,\n weights=self.loss_weights)\n\n opt = tf.train.AdamOptimizer()\n self.train_op = opt.minimize(self.loss)\n\n # add\n params = tf.trainable_variables()\n self.gradient_norms = []\n self.updates = []\n\n gradients = tf.gradients(self.loss, params)\n clipped_gradients, norm = tf.clip_by_global_norm(gradients,\n self.max_gradient_norm)\n self.gradient_norms.append(norm)\n self.updates.append(opt.apply_gradients(\n zip(clipped_gradients, params), global_step=self.global_step))\n\n self.saver = tf.train.Saver(tf.global_variables())", "probing input": " def _init_optimizer(self):\n # 整理输出并计算loss\n logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n targets = tf.transpose(self.decoder_train_targets, [1, 0])\n self.logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n self.targets = tf.transpose(self.decoder_train_targets, [1, 0])\n\n self.loss = seq2seq.sequence_loss(logits=logits, targets=targets,\n weights=self.loss_weights)\n\n opt = tf.train.AdamOptimizer()\n self.train_op = opt.minimize(self.loss)\n\n # add\n params = tf.trainable_variables()\n self.gradient_norms = []\n self.updates = []\n\n gradients = tf.gradients(self.loss, params)\n clipped_gradients, norm = tf.clip_by_global_norm(gradients,\n self.max_gradient_norm)\n self.gradient_norms.append(norm)\n self.updates.append(opt.apply_gradients(\n zip(clipped_gradients, params), global_step=self.global_step))\n\n", "probing input new": " def _init_optimizer(self):\n # 整理输出并计算loss\n logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n targets = tf.transpose(self.decoder_train_targets, [1, 0])\n self.logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n self.targets = tf.transpose(self.decoder_train_targets, [1, 0])\n\n self.loss = seq2seq.sequence_loss(logits=logits, targets=targets,\n weights=self.loss_weights)\n\n opt = tf.train.AdamOptimizer()\n self.train_op = opt.minimize(self.loss)\n\n # add\n params = tf.trainable_variables()\n self.gradient_norms = []\n self.updates = []\n\n gradients = tf.gradients(self.loss, params)\n clipped_gradients, norm = tf.clip_by_global_norm(gradients,\n self.max_gradient_norm)\n self.gradient_norms.append(norm)\n self.updates.append(opt.apply_gradients(\n zip(clipped_gradients, params), global_step=self.global_step))\n\n self.saver = tf.train.Saver(tf.", "reference": "self.saver=tf.train.Saver(tf.global_variables())", "reference dict": { "opt": "tf.train.AdamOptimizer", "self.saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "self.saver=tf.train.Saver(tf.global_variables())", "y_neg": " self.saver = tf.train.Saver(tf.all_variables())", "retain": " def _init_optimizer(self):\n # 整理输出并计算loss\n logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n targets = tf.transpose(self.decoder_train_targets, [1, 0])\n self.logits = tf.transpose(self.decoder_logits_train, [1, 0, 2])\n self.targets = tf.transpose(self.decoder_train_targets, [1, 0])\n\n self.loss = seq2seq.sequence_loss(logits=logits, targets=targets,\n weights=self.loss_weights)\n\n opt = tf.train.AdamOptimizer()\n self.train_op = opt.minimize(self.loss)\n\n # add\n params = tf.trainable_variables()\n self.gradient_norms = []\n self.updates = []\n\n gradients = tf.gradients(self.loss, params)\n clipped_gradients, norm = tf.clip_by_global_norm(gradients,\n self.max_gradient_norm)\n self.gradient_norms.append(norm)\n self.updates.append(opt.apply_gradients(\n zip(clipped_gradients, params), global_step=self.global_step))\n\n self.saver = tf.train.Saver(tf.global_variables())" }, { "id": 17831, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def add_saver(self):\n \"\"\"Adds a Saver for all variables in the graph.\"\"\"\n logging.info('Saving variables:\\n\\t%s',\n '\\n\\t'.join([x.name for x in tf.global_variables()]))\n self.saver = tf.train.Saver(\n var_list=[x for x in tf.global_variables()],\n write_version=saver_pb2.SaverDef.V1)", "probing input": " def add_saver(self):\n \"\"\"Adds a Saver for all variables in the graph.\"\"\"\n logging.info('Saving variables:\\n\\t%s',\n", "probing input new": " def add_saver(self):\n \"\"\"Adds a Saver for all variables in the graph.\"\"\"\n logging.info('Saving variables:\\n\\t%s',\n '\\n\\t'.join([x.name for x in tf.", "reference": "'\\n\\t'.join([x.nameforxintf.global_variables()]))", "reference dict": { "self.saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "'\\n\\t'.join([x.nameforxintf.global_variables()]))", "y_neg": " '\\n\\t'.join([x.name for x in tf.all_variables()]))", "retain": " def add_saver(self):\n \"\"\"Adds a Saver for all variables in the graph.\"\"\"\n logging.info('Saving variables:\\n\\t%s',\n '\\n\\t'.join([x.name for x in tf.global_variables()]))\n self.saver = tf.train.Saver(\n var_list=[x for x in tf.global_variables()],\n write_version=saver_pb2.SaverDef.V1)" }, { "id": 17833, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def print_variable_summary():\n import pprint\n variables = sorted([[v.name, v.get_shape()] for v in tf.global_variables()])\n pprint.pprint(variables)", "probing input": "def print_variable_summary():\n import pprint\n", "probing input new": "def print_variable_summary():\n import pprint\n variables = sorted([[v.name, v.get_shape()] for v in tf.", "reference": "variables=sorted([[v.name,v.get_shape()]forvintf.global_variables()])", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "variables=sorted([[v.name,v.get_shape()]forvintf.global_variables()])", "y_neg": " variables = sorted([[v.name, v.get_shape()] for v in tf.all_variables()])", "retain": "def print_variable_summary():\n import pprint\n variables = sorted([[v.name, v.get_shape()] for v in tf.global_variables()])\n pprint.pprint(variables)" }, { "id": 17837, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def initialize_tf_variables(session, only_uninitialized=True):\n variables = tf.global_variables() + tf.local_variables()\n\n def is_initialized(variable):\n try:\n session.run(variable)\n return True\n except tf.errors.FailedPreconditionError:\n return False\n\n return False\n\n if only_uninitialized:\n variables = [\n variable for variable in variables\n if not is_initialized(variable)\n ]\n\n session.run(tf.variables_initializer(variables))", "probing input": "def initialize_tf_variables(session, only_uninitialized=True):\n", "probing input new": "def initialize_tf_variables(session, only_uninitialized=True):\n variables = tf.", "reference": "variables=tf.global_variables()+tf.local_variables()", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "variables=tf.global_variables()+tf.local_variables()", "y_neg": " variables = tf.all_variables()", "retain": "def initialize_tf_variables(session, only_uninitialized=True):\n variables = tf.global_variables() + tf.local_variables()\n\n def is_initialized(variable):\n try:\n session.run(variable)\n return True\n except tf.errors.FailedPreconditionError:\n return False\n\n return False\n\n if only_uninitialized:\n variables = [\n variable for variable in variables\n if not is_initialized(variable)\n ]\n\n session.run(tf.variables_initializer(variables))" }, { "id": 17846, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def load_old_graph(self, ckpt): \n ckpt_loader = create_loader(ckpt)\n self.say(old_graph_msg.format(ckpt))\n \n for var in tf.global_variables():\n name = var.name.split(':')[0]\n args = [name, var.get_shape()]\n val = ckpt_loader(args)\n assert val is not None, \\\n 'Cannot find and load {}'.format(var.name)\n shp = val.shape\n plh = tf.placeholder(tf.float32, shp)\n op = tf.assign(var, plh)\n self.sess.run(op, {plh: val})", "probing input": "def load_old_graph(self, ckpt): \n ckpt_loader = create_loader(ckpt)\n self.say(old_graph_msg.format(ckpt))\n \n", "probing input new": "def load_old_graph(self, ckpt): \n ckpt_loader = create_loader(ckpt)\n self.say(old_graph_msg.format(ckpt))\n \n for var in tf.", "reference": "forvarintf.global_variables():", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "forvarintf.global_variables():", "y_neg": " for var in tf.all_variables():", "retain": "def load_old_graph(self, ckpt): \n ckpt_loader = create_loader(ckpt)\n self.say(old_graph_msg.format(ckpt))\n \n for var in tf.global_variables():\n name = var.name.split(':')[0]\n args = [name, var.get_shape()]\n val = ckpt_loader(args)\n assert val is not None, \\\n 'Cannot find and load {}'.format(var.name)\n shp = val.shape\n plh = tf.placeholder(tf.float32, shp)\n op = tf.assign(var, plh)\n self.sess.run(op, {plh: val})" }, { "id": 17861, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def predict(words):\n word_data = reader.sentence_to_word_ids(FLAGS.pos_data_path, words)\n tag_data = [0]*len(word_data)\n\n config = get_config(FLAGS.pos_lang)\n config.batch_size = 1\n # config.num_steps, num_steps is T, should not be set to 1, CRF decode whe whole sequence at one time\n\n # intialize model\n ckpt_path = os.path.join(FLAGS.pos_train_dir, \"pos_bilstm_crf.ckpt\")\n \n with tf.Graph().as_default(), tf.Session() as session:\n with tf.variable_scope(\"pos_var_scope\"): #Need to Change in Pos_Tagger Save Function\n model = POSTagger(is_training=False, config=config) # save object after is_training\n \n if len(glob.glob(ckpt_path + '.data*')) > 0: # file exist with pattern: 'pos.ckpt.data*'\n print(\"Loading model parameters from %s\" % ckpt_path)\n all_vars = tf.global_variables()\n model_vars = [k for k in all_vars if k.name.startswith(\"pos_var_scope\")]\n tf.train.Saver(model_vars).restore(session, ckpt_path)\n else:\n print(\"Model not found, created with fresh parameters.\")\n session.run(tf.global_variables_initializer())\n\n # Make Prediciton\n word_data = np.array(word_data, dtype=np.int32)\n sequence_len = len(word_data)\n x = np.zeros([1, config.num_steps], dtype=np.int32)\n for i in range(sequence_len): # pad word_data len to num_steps\n x[0, i] = word_data[i]\n y = np.zeros([1, config.num_steps], dtype=np.int32)\n\n fetches = [model.cost, model.logits, model.transition_params]\n feed_dict = {}\n feed_dict[model.input_data] = x\n feed_dict[model.targets] = y\n cost, logits, transition_params = session.run(fetches, feed_dict)\n print (logits[0])\n print (logits)\n\n # print (transition_params)\n print (transition_params[0, :])\n\n # Remove padding from the scores and tag sequence.\n tf_unary_scores = logits[0, :, :] # One Example [batch_size, num_steps, target_num]\n print (\"unary_score %d\" % len(tf_unary_scores))\n\n tf_unary_scores = tf_unary_scores[:sequence_len]\n print (\"unary_score %d\" % len(tf_unary_scores))\n\n # transition_params [Aij] tag transition probability\n viterbi_sequence, _ = tf.contrib.crf.viterbi_decode(tf_unary_scores, transition_params)\n print (\"optimal sequence found by viterbi algorithm\")\n print (viterbi_sequence)\n predict_tag = reader.word_ids_to_sentence(FLAGS.pos_data_path, viterbi_sequence)\n return predict_tag", "probing input": "def predict(words):\n word_data = reader.sentence_to_word_ids(FLAGS.pos_data_path, words)\n tag_data = [0]*len(word_data)\n\n config = get_config(FLAGS.pos_lang)\n config.batch_size = 1\n # config.num_steps, num_steps is T, should not be set to 1, CRF decode whe whole sequence at one time\n\n # intialize model\n ckpt_path = os.path.join(FLAGS.pos_train_dir, \"pos_bilstm_crf.ckpt\")\n \n with tf.Graph().as_default(), tf.Session() as session:\n with tf.variable_scope(\"pos_var_scope\"): #Need to Change in Pos_Tagger Save Function\n model = POSTagger(is_training=False, config=config) # save object after is_training\n \n if len(glob.glob(ckpt_path + '.data*')) > 0: # file exist with pattern: 'pos.ckpt.data*'\n print(\"Loading model parameters from %s\" % ckpt_path)\n", "probing input new": "def predict(words):\n word_data = reader.sentence_to_word_ids(FLAGS.pos_data_path, words)\n tag_data = [0]*len(word_data)\n\n config = get_config(FLAGS.pos_lang)\n config.batch_size = 1\n # config.num_steps, num_steps is T, should not be set to 1, CRF decode whe whole sequence at one time\n\n # intialize model\n ckpt_path = os.path.join(FLAGS.pos_train_dir, \"pos_bilstm_crf.ckpt\")\n \n with tf.Graph().as_default(), tf.Session() as session:\n with tf.variable_scope(\"pos_var_scope\"): #Need to Change in Pos_Tagger Save Function\n model = POSTagger(is_training=False, config=config) # save object after is_training\n \n if len(glob.glob(ckpt_path + '.data*')) > 0: # file exist with pattern: 'pos.ckpt.data*'\n print(\"Loading model parameters from %s\" % ckpt_path)\n all_vars = tf.", "reference": "all_vars=tf.global_variables()", "reference dict": { "model": "POSTagger" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "all_vars=tf.global_variables()", "y_neg": " all_vars = tf.all_variables()", "retain": "def predict(words):\n word_data = reader.sentence_to_word_ids(FLAGS.pos_data_path, words)\n tag_data = [0]*len(word_data)\n\n config = get_config(FLAGS.pos_lang)\n config.batch_size = 1\n # config.num_steps, num_steps is T, should not be set to 1, CRF decode whe whole sequence at one time\n\n # intialize model\n ckpt_path = os.path.join(FLAGS.pos_train_dir, \"pos_bilstm_crf.ckpt\")\n \n with tf.Graph().as_default(), tf.Session() as session:\n with tf.variable_scope(\"pos_var_scope\"): #Need to Change in Pos_Tagger Save Function\n model = POSTagger(is_training=False, config=config) # save object after is_training\n \n if len(glob.glob(ckpt_path + '.data*')) > 0: # file exist with pattern: 'pos.ckpt.data*'\n print(\"Loading model parameters from %s\" % ckpt_path)\n all_vars = tf.global_variables()\n model_vars = [k for k in all_vars if k.name.startswith(\"pos_var_scope\")]\n tf.train.Saver(model_vars).restore(session, ckpt_path)\n else:\n print(\"Model not found, created with fresh parameters.\")\n session.run(tf.global_variables_initializer())\n\n # Make Prediciton\n word_data = np.array(word_data, dtype=np.int32)\n sequence_len = len(word_data)\n x = np.zeros([1, config.num_steps], dtype=np.int32)\n for i in range(sequence_len): # pad word_data len to num_steps\n x[0, i] = word_data[i]\n y = np.zeros([1, config.num_steps], dtype=np.int32)\n\n fetches = [model.cost, model.logits, model.transition_params]\n feed_dict = {}\n feed_dict[model.input_data] = x\n feed_dict[model.targets] = y\n cost, logits, transition_params = session.run(fetches, feed_dict)\n print (logits[0])\n print (logits)\n\n # print (transition_params)\n print (transition_params[0, :])\n\n # Remove padding from the scores and tag sequence.\n tf_unary_scores = logits[0, :, :] # One Example [batch_size, num_steps, target_num]\n print (\"unary_score %d\" % len(tf_unary_scores))\n\n tf_unary_scores = tf_unary_scores[:sequence_len]\n print (\"unary_score %d\" % len(tf_unary_scores))\n\n # transition_params [Aij] tag transition probability\n viterbi_sequence, _ = tf.contrib.crf.viterbi_decode(tf_unary_scores, transition_params)\n print (\"optimal sequence found by viterbi algorithm\")\n print (viterbi_sequence)\n predict_tag = reader.word_ids_to_sentence(FLAGS.pos_data_path, viterbi_sequence)\n return predict_tag" }, { "id": 17865, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def define_saver(exclude=None):\n \"\"\"Create a saver for the variables we want to checkpoint.\n\n Args:\n exclude: List of regexes to match variable names to exclude.\n\n Returns:\n Saver object.\n \"\"\"\n variables = []\n exclude = exclude or []\n exclude = [re.compile(regex) for regex in exclude]\n for variable in tf.global_variables():\n if any(regex.match(variable.name) for regex in exclude):\n continue\n variables.append(variable)\n saver = tf.train.Saver(variables, keep_checkpoint_every_n_hours=5)\n return saver", "probing input": "def define_saver(exclude=None):\n \"\"\"Create a saver for the variables we want to checkpoint.\n\n Args:\n exclude: List of regexes to match variable names to exclude.\n\n Returns:\n Saver object.\n \"\"\"\n variables = []\n exclude = exclude or []\n exclude = [re.compile(regex) for regex in exclude]\n", "probing input new": "def define_saver(exclude=None):\n \"\"\"Create a saver for the variables we want to checkpoint.\n\n Args:\n exclude: List of regexes to match variable names to exclude.\n\n Returns:\n Saver object.\n \"\"\"\n variables = []\n exclude = exclude or []\n exclude = [re.compile(regex) for regex in exclude]\n for variable in tf.", "reference": "forvariableintf.global_variables():", "reference dict": { "saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "forvariableintf.global_variables():", "y_neg": " for variable in tf.all_variables():", "retain": "def define_saver(exclude=None):\n \"\"\"Create a saver for the variables we want to checkpoint.\n\n Args:\n exclude: List of regexes to match variable names to exclude.\n\n Returns:\n Saver object.\n \"\"\"\n variables = []\n exclude = exclude or []\n exclude = [re.compile(regex) for regex in exclude]\n for variable in tf.global_variables():\n if any(regex.match(variable.name) for regex in exclude):\n continue\n variables.append(variable)\n saver = tf.train.Saver(variables, keep_checkpoint_every_n_hours=5)\n return saver" }, { "id": 17868, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def init_saver(self):\n \"\"\"\n 初始化saver对象\n :return:\n \"\"\"\n self.saver = tf.train.Saver(tf.global_variables(), max_to_keep=100)", "probing input": " def init_saver(self):\n \"\"\"\n 初始化saver对象\n :return:\n \"\"\"\n", "probing input new": " def init_saver(self):\n \"\"\"\n 初始化saver对象\n :return:\n \"\"\"\n self.saver = tf.train.Saver(tf.", "reference": "self.saver=tf.train.Saver(tf.global_variables(),max_to_keep=100)", "reference dict": { "self.saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "self.saver=tf.train.Saver(tf.global_variables(),max_to_keep=100)", "y_neg": " self.saver = tf.train.Saver(tf.all_variables())", "retain": " def init_saver(self):\n \"\"\"\n 初始化saver对象\n :return:\n \"\"\"\n self.saver = tf.train.Saver(tf.global_variables(), max_to_keep=100)" }, { "id": 17930, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size,\n infer_sample=True)\n\n# Create model saver\nsaver = tf.train.Saver(tf.global_variables())", "probing input": "lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size,\n infer_sample=True)\n\n# Create model saver\n", "probing input new": "lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size,\n infer_sample=True)\n\n# Create model saver\nsaver = tf.train.Saver(tf.", "reference": "saver=tf.train.Saver(tf.global_variables())", "reference dict": { "sess": "tf.Session", "lstm_model": "LSTM_Model", "saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "saver=tf.train.Saver(tf.global_variables())", "y_neg": "saver = tf.train.Saver(tf.all_variables())", "retain": "lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(rnn_size,\n num_layers,\n batch_size,\n learning_rate,\n training_seq_len,\n vocab_size,\n infer_sample=True)\n\n# Create model saver\nsaver = tf.train.Saver(tf.global_variables())" }, { "id": 17985, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "config.gpu_options.allow_growth = True\nconfig.gpu_options.visible_device_list = str(FLAGS.visiable_gpu)\nconfig.log_device_placement=False\nsess = tf.Session(config=config)\nsaver = tf.train.Saver(tf.global_variables())", "probing input": "config.gpu_options.allow_growth = True\nconfig.gpu_options.visible_device_list = str(FLAGS.visiable_gpu)\nconfig.log_device_placement=False\nsess = tf.Session(config=config)\n", "probing input new": "config.gpu_options.allow_growth = True\nconfig.gpu_options.visible_device_list = str(FLAGS.visiable_gpu)\nconfig.log_device_placement=False\nsess = tf.Session(config=config)\nsaver = tf.train.Saver(tf.", "reference": "saver=tf.train.Saver(tf.global_variables())", "reference dict": { "net": "resnet.ResNet", "config": "tf.ConfigProto", "sess": "tf.Session", "saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "saver=tf.train.Saver(tf.global_variables())", "y_neg": "saver = tf.train.Saver(tf.all_variables())", "retain": "config.gpu_options.allow_growth = True\nconfig.gpu_options.visible_device_list = str(FLAGS.visiable_gpu)\nconfig.log_device_placement=False\nsess = tf.Session(config=config)\nsaver = tf.train.Saver(tf.global_variables())" }, { "id": 17990, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, path, at_epoch, at_every_epoch=0):\n self.path = path + \"/\"\n self.at_epoch = at_epoch\n self.at_every_epoch = at_every_epoch\n self.saver = tf.train.Saver(tf.global_variables())", "probing input": " def __init__(self, path, at_epoch, at_every_epoch=0):\n self.path = path + \"/\"\n self.at_epoch = at_epoch\n self.at_every_epoch = at_every_epoch\n", "probing input new": " def __init__(self, path, at_epoch, at_every_epoch=0):\n self.path = path + \"/\"\n self.at_epoch = at_epoch\n self.at_every_epoch = at_every_epoch\n self.saver = tf.train.Saver(tf.", "reference": "self.saver=tf.train.Saver(tf.global_variables())", "reference dict": { "self.saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "self.saver=tf.train.Saver(tf.global_variables())", "y_neg": " self.saver = tf.train.Saver(tf.all_variables())", "retain": " def __init__(self, path, at_epoch, at_every_epoch=0):\n self.path = path + \"/\"\n self.at_epoch = at_epoch\n self.at_every_epoch = at_every_epoch\n self.saver = tf.train.Saver(tf.global_variables())" }, { "id": 18004, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size, infer_sample=True)\n\n\n# Create model saver\nsaver = tf.train.Saver(tf.global_variables())", "probing input": "lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size, infer_sample=True)\n\n\n# Create model saver\n", "probing input new": "lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size, infer_sample=True)\n\n\n# Create model saver\nsaver = tf.train.Saver(tf.", "reference": "saver=tf.train.Saver(tf.global_variables())", "reference dict": { "sess": "tf.Session", "lstm_model": "LSTM_Model", "saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "saver=tf.train.Saver(tf.global_variables())", "y_neg": "saver = tf.train.Saver(tf.all_variables())", "retain": "lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size)\n\n# Tell TensorFlow we are reusing the scope for the testing\nwith tf.variable_scope(tf.get_variable_scope(), reuse=True):\n test_lstm_model = LSTM_Model(embedding_size, rnn_size, batch_size, learning_rate,\n training_seq_len, vocab_size, infer_sample=True)\n\n\n# Create model saver\nsaver = tf.train.Saver(tf.global_variables())" }, { "id": 18048, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def train(self, data=0, steps=-1, dropout=None, display_step=10, test_step=200, batch_size=10,\n\t do_resume=False): # epochs=-1,\n\t\tif data: self.data = data\n\t\tsteps = 9999999 if steps == -1 else steps\n\t\tsession = self.session\n\t\t# with tf.device(_cpu):\n\n\t\t# import tensorflow.contrib.layers as layers\n\t\t# t = tf.verify_tensor_all_finite(t, msg)\n\t\ttf.add_check_numerics_ops()\n\t\ttry:\n\t\t\tself.summaries = tf.summary.merge_all()\n\t\texcept:\n\t\t\tself.summaries = tf.merge_all_summaries()\n\t\ttry:\n\t\t\tself.summary_writer = tf.summary.FileWriter(current_logdir(), session.graph) #\n\t\texcept:\n\t\t\tself.summary_writer = tf.train.SummaryWriter(current_logdir(), session.graph) #\n\t\tif not dropout: dropout = 1. # keep all\n\t\tx = self.x\n\t\ty = self.y\n\t\tkeep_prob = self.keep_prob\n\t\ttry:\n\t\t\tsaver = tf.train.Saver(tf.global_variables())\n\t\texcept:\n\t\t\tsaver = tf.train.Saver(tf.all_variables())\n\t\tsnapshot = self.name + str(get_last_tensorboard_run_nr())\n\t\tcheckpoint = tf.train.latest_checkpoint(checkpoint_dir)\n\t\tif do_resume and checkpoint:\n\t\t\tprint(\"LOADING \" + checkpoint + \" !!!\")\n\t\t\tsaver.restore(session, checkpoint)\n\t\ttry:\n\t\t\tsession.run([tf.global_variables_initializer()])\n\t\texcept:\n\t\t\tsession.run([tf.initialize_all_variables()])\n\t\tstep = 0 # show first\n\t\twhile step < steps:\n\t\t\tbatch_xs, batch_ys = self.next_batch(batch_size, session)\n\t\t\t# print(\"step %d \\r\" % step)# end=' ')\n\n\t\t\t# tf.train.shuffle_batch_join(example_list, batch_size, capacity=min_queue_size + batch_size * 16, min_queue_size)\n\t\t\t# Fit training using batch data\n\t\t\tfeed_dict = {x: batch_xs, y: batch_ys, keep_prob: dropout, self.train_phase: True}\n\t\t\tloss, _ = session.run([self.cost, self.optimizer], feed_dict=feed_dict)\n\t\t\tif step % display_step == 0:\n\t\t\t\tseconds = int(time.time()) - start\n\t\t\t\t# Calculate batch accuracy, loss\n\t\t\t\tfeed = {x: batch_xs, y: batch_ys, keep_prob: 1., self.train_phase: False}\n\t\t\t\tacc, summary = session.run([self.accuracy, self.summaries], feed_dict=feed)\n\t\t\t\t# self.summary_writer.add_summary(summary, step) # only test summaries for smoother curve\n\t\t\t\tprint(\"\\rStep {:d} Loss= {:.6f} Accuracy= {:.3f} Time= {:d}s\".format(step, loss, acc, seconds), end=' ')\n\t\t\t\tif str(loss) == \"nan\": return print(\"\\nLoss gradiant explosion, exiting!!!\") # restore!\n\t\t\tif step % test_step == 0: self.test(step)\n\t\t\tif step % save_step == 0 and step > 0:\n\t\t\t\tprint(\"SAVING snapshot %s\" % snapshot)\n\t\t\t\tsaver.save(session, checkpoint_dir + snapshot + \".ckpt\", self.global_step)\n\n\t\t\tstep += 1\n\t\tprint(\"\\nOptimization Finished!\")\n\t\tself.test(step, number=10000)", "probing input": " def train(self, data=0, steps=-1, dropout=None, display_step=10, test_step=200, batch_size=10,\n\t do_resume=False): # epochs=-1,\n\t\tif data: self.data = data\n\t\tsteps = 9999999 if steps == -1 else steps\n\t\tsession = self.session\n\t\t# with tf.device(_cpu):\n\n\t\t# import tensorflow.contrib.layers as layers\n\t\t# t = tf.verify_tensor_all_finite(t, msg)\n\t\ttf.add_check_numerics_ops()\n\t\ttry:\n\t\t\tself.summaries = tf.summary.merge_all()\n\t\texcept:\n\t\t\tself.summaries = tf.merge_all_summaries()\n\t\ttry:\n\t\t\tself.summary_writer = tf.summary.FileWriter(current_logdir(), session.graph) #\n\t\texcept:\n\t\t\tself.summary_writer = tf.train.SummaryWriter(current_logdir(), session.graph) #\n\t\tif not dropout: dropout = 1. # keep all\n\t\tx = self.x\n\t\ty = self.y\n\t\tkeep_prob = self.keep_prob\n\t\ttry:\n", "probing input new": " def train(self, data=0, steps=-1, dropout=None, display_step=10, test_step=200, batch_size=10,\n\t do_resume=False): # epochs=-1,\n\t\tif data: self.data = data\n\t\tsteps = 9999999 if steps == -1 else steps\n\t\tsession = self.session\n\t\t# with tf.device(_cpu):\n\n\t\t# import tensorflow.contrib.layers as layers\n\t\t# t = tf.verify_tensor_all_finite(t, msg)\n\t\ttf.add_check_numerics_ops()\n\t\ttry:\n\t\t\tself.summaries = tf.summary.merge_all()\n\t\texcept:\n\t\t\tself.summaries = tf.merge_all_summaries()\n\t\ttry:\n\t\t\tself.summary_writer = tf.summary.FileWriter(current_logdir(), session.graph) #\n\t\texcept:\n\t\t\tself.summary_writer = tf.train.SummaryWriter(current_logdir(), session.graph) #\n\t\tif not dropout: dropout = 1. # keep all\n\t\tx = self.x\n\t\ty = self.y\n\t\tkeep_prob = self.keep_prob\n\t\ttry:\n\t\t\tsaver = tf.train.Saver(tf.", "reference": "saver=tf.train.Saver(tf.global_variables())", "reference dict": { "self.summary_writer": "tf.train.SummaryWriter", "saver": "tf.train.Saver" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "saver=tf.train.Saver(tf.global_variables())", "y_neg": "\t\t\tsaver = tf.train.Saver(tf.all_variables(), max_to_keep=1)", "retain": " def train(self, data=0, steps=-1, dropout=None, display_step=10, test_step=200, batch_size=10,\n\t do_resume=False): # epochs=-1,\n\t\tif data: self.data = data\n\t\tsteps = 9999999 if steps == -1 else steps\n\t\tsession = self.session\n\t\t# with tf.device(_cpu):\n\n\t\t# import tensorflow.contrib.layers as layers\n\t\t# t = tf.verify_tensor_all_finite(t, msg)\n\t\ttf.add_check_numerics_ops()\n\t\ttry:\n\t\t\tself.summaries = tf.summary.merge_all()\n\t\texcept:\n\t\t\tself.summaries = tf.merge_all_summaries()\n\t\ttry:\n\t\t\tself.summary_writer = tf.summary.FileWriter(current_logdir(), session.graph) #\n\t\texcept:\n\t\t\tself.summary_writer = tf.train.SummaryWriter(current_logdir(), session.graph) #\n\t\tif not dropout: dropout = 1. # keep all\n\t\tx = self.x\n\t\ty = self.y\n\t\tkeep_prob = self.keep_prob\n\t\ttry:\n\t\t\tsaver = tf.train.Saver(tf.global_variables())\n\t\texcept:\n\t\t\tsaver = tf.train.Saver(tf.all_variables())\n\t\tsnapshot = self.name + str(get_last_tensorboard_run_nr())\n\t\tcheckpoint = tf.train.latest_checkpoint(checkpoint_dir)\n\t\tif do_resume and checkpoint:\n\t\t\tprint(\"LOADING \" + checkpoint + \" !!!\")\n\t\t\tsaver.restore(session, checkpoint)\n\t\ttry:\n\t\t\tsession.run([tf.global_variables_initializer()])\n\t\texcept:\n\t\t\tsession.run([tf.initialize_all_variables()])\n\t\tstep = 0 # show first\n\t\twhile step < steps:\n\t\t\tbatch_xs, batch_ys = self.next_batch(batch_size, session)\n\t\t\t# print(\"step %d \\r\" % step)# end=' ')\n\n\t\t\t# tf.train.shuffle_batch_join(example_list, batch_size, capacity=min_queue_size + batch_size * 16, min_queue_size)\n\t\t\t# Fit training using batch data\n\t\t\tfeed_dict = {x: batch_xs, y: batch_ys, keep_prob: dropout, self.train_phase: True}\n\t\t\tloss, _ = session.run([self.cost, self.optimizer], feed_dict=feed_dict)\n\t\t\tif step % display_step == 0:\n\t\t\t\tseconds = int(time.time()) - start\n\t\t\t\t# Calculate batch accuracy, loss\n\t\t\t\tfeed = {x: batch_xs, y: batch_ys, keep_prob: 1., self.train_phase: False}\n\t\t\t\tacc, summary = session.run([self.accuracy, self.summaries], feed_dict=feed)\n\t\t\t\t# self.summary_writer.add_summary(summary, step) # only test summaries for smoother curve\n\t\t\t\tprint(\"\\rStep {:d} Loss= {:.6f} Accuracy= {:.3f} Time= {:d}s\".format(step, loss, acc, seconds), end=' ')\n\t\t\t\tif str(loss) == \"nan\": return print(\"\\nLoss gradiant explosion, exiting!!!\") # restore!\n\t\t\tif step % test_step == 0: self.test(step)\n\t\t\tif step % save_step == 0 and step > 0:\n\t\t\t\tprint(\"SAVING snapshot %s\" % snapshot)\n\t\t\t\tsaver.save(session, checkpoint_dir + snapshot + \".ckpt\", self.global_step)\n\n\t\t\tstep += 1\n\t\tprint(\"\\nOptimization Finished!\")\n\t\tself.test(step, number=10000)" }, { "id": 18065, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def evaluate():\n tf.set_random_seed(0) # for reproducibility\n with tf.Graph().as_default():\n # convert feature_names and feature_sizes to lists of values\n feature_names, feature_sizes = utils.GetListOfFeatureNamesAndSizes(\n FLAGS.feature_names, FLAGS.feature_sizes)\n\n if FLAGS.frame_features:\n reader = readers.YT8MFrameFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n else:\n reader = readers.YT8MAggregatedFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n\n model = find_class_by_name(FLAGS.model,\n [frame_level_models, video_level_models])()\n label_loss_fn = find_class_by_name(FLAGS.label_loss, [losses])()\n\n if FLAGS.eval_data_pattern is \"\":\n raise IOError(\"'eval_data_pattern' was not specified. \" +\n \"Nothing to evaluate.\")\n\n build_graph(\n reader=reader,\n model=model,\n eval_data_pattern=FLAGS.eval_data_pattern,\n label_loss_fn=label_loss_fn,\n num_readers=FLAGS.num_readers,\n batch_size=FLAGS.batch_size)\n logging.info(\"built evaluation graph\")\n video_id_batch = tf.get_collection(\"video_id_batch\")[0]\n prediction_batch = tf.get_collection(\"predictions\")[0]\n label_batch = tf.get_collection(\"labels\")[0]\n loss = tf.get_collection(\"loss\")[0]\n summary_op = tf.get_collection(\"summary_op\")[0]\n\n saver = tf.train.Saver(tf.global_variables())\n summary_writer = tf.summary.FileWriter(\n FLAGS.train_dir, graph=tf.get_default_graph())\n\n evl_metrics = eval_util.EvaluationMetrics(reader.num_classes, FLAGS.top_k)\n\n last_global_step_val = -1\n while True:\n last_global_step_val = evaluation_loop(video_id_batch, prediction_batch,\n label_batch, loss, summary_op,\n saver, summary_writer, evl_metrics,\n last_global_step_val)\n if FLAGS.run_once:\n break", "probing input": "def evaluate():\n tf.set_random_seed(0) # for reproducibility\n with tf.Graph().as_default():\n # convert feature_names and feature_sizes to lists of values\n feature_names, feature_sizes = utils.GetListOfFeatureNamesAndSizes(\n FLAGS.feature_names, FLAGS.feature_sizes)\n\n if FLAGS.frame_features:\n reader = readers.YT8MFrameFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n else:\n reader = readers.YT8MAggregatedFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n\n model = find_class_by_name(FLAGS.model,\n [frame_level_models, video_level_models])()\n label_loss_fn = find_class_by_name(FLAGS.label_loss, [losses])()\n\n if FLAGS.eval_data_pattern is \"\":\n raise IOError(\"'eval_data_pattern' was not specified. \" +\n \"Nothing to evaluate.\")\n\n build_graph(\n reader=reader,\n model=model,\n eval_data_pattern=FLAGS.eval_data_pattern,\n label_loss_fn=label_loss_fn,\n num_readers=FLAGS.num_readers,\n batch_size=FLAGS.batch_size)\n logging.info(\"built evaluation graph\")\n video_id_batch = tf.get_collection(\"video_id_batch\")[0]\n prediction_batch = tf.get_collection(\"predictions\")[0]\n label_batch = tf.get_collection(\"labels\")[0]\n loss = tf.get_collection(\"loss\")[0]\n summary_op = tf.get_collection(\"summary_op\")[0]\n\n", "probing input new": "def evaluate():\n tf.set_random_seed(0) # for reproducibility\n with tf.Graph().as_default():\n # convert feature_names and feature_sizes to lists of values\n feature_names, feature_sizes = utils.GetListOfFeatureNamesAndSizes(\n FLAGS.feature_names, FLAGS.feature_sizes)\n\n if FLAGS.frame_features:\n reader = readers.YT8MFrameFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n else:\n reader = readers.YT8MAggregatedFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n\n model = find_class_by_name(FLAGS.model,\n [frame_level_models, video_level_models])()\n label_loss_fn = find_class_by_name(FLAGS.label_loss, [losses])()\n\n if FLAGS.eval_data_pattern is \"\":\n raise IOError(\"'eval_data_pattern' was not specified. \" +\n \"Nothing to evaluate.\")\n\n build_graph(\n reader=reader,\n model=model,\n eval_data_pattern=FLAGS.eval_data_pattern,\n label_loss_fn=label_loss_fn,\n num_readers=FLAGS.num_readers,\n batch_size=FLAGS.batch_size)\n logging.info(\"built evaluation graph\")\n video_id_batch = tf.get_collection(\"video_id_batch\")[0]\n prediction_batch = tf.get_collection(\"predictions\")[0]\n label_batch = tf.get_collection(\"labels\")[0]\n loss = tf.get_collection(\"loss\")[0]\n summary_op = tf.get_collection(\"summary_op\")[0]\n\n saver = tf.train.Saver(tf.", "reference": "saver=tf.train.Saver(tf.global_variables())", "reference dict": { "feature_names, feature_sizes": "utils.GetListOfFeatureNamesAndSizes", "saver": "tf.train.Saver", "summary_writer": "tf.summary.FileWriter", "evl_metrics": "eval_util.EvaluationMetrics", "reader": "readers.YT8MAggregatedFeatureReader" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.compat.v1.all_variables", "tensorflow.all_variables" ], "replacement api": "tensorflow.global_variables", "expected call": "tf.global_variables", "y_pos": "saver=tf.train.Saver(tf.global_variables())", "y_neg": " saver = tf.train.Saver(tf.all_variables())", "retain": "def evaluate():\n tf.set_random_seed(0) # for reproducibility\n with tf.Graph().as_default():\n # convert feature_names and feature_sizes to lists of values\n feature_names, feature_sizes = utils.GetListOfFeatureNamesAndSizes(\n FLAGS.feature_names, FLAGS.feature_sizes)\n\n if FLAGS.frame_features:\n reader = readers.YT8MFrameFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n else:\n reader = readers.YT8MAggregatedFeatureReader(feature_names=feature_names,\n feature_sizes=feature_sizes)\n\n model = find_class_by_name(FLAGS.model,\n [frame_level_models, video_level_models])()\n label_loss_fn = find_class_by_name(FLAGS.label_loss, [losses])()\n\n if FLAGS.eval_data_pattern is \"\":\n raise IOError(\"'eval_data_pattern' was not specified. \" +\n \"Nothing to evaluate.\")\n\n build_graph(\n reader=reader,\n model=model,\n eval_data_pattern=FLAGS.eval_data_pattern,\n label_loss_fn=label_loss_fn,\n num_readers=FLAGS.num_readers,\n batch_size=FLAGS.batch_size)\n logging.info(\"built evaluation graph\")\n video_id_batch = tf.get_collection(\"video_id_batch\")[0]\n prediction_batch = tf.get_collection(\"predictions\")[0]\n label_batch = tf.get_collection(\"labels\")[0]\n loss = tf.get_collection(\"loss\")[0]\n summary_op = tf.get_collection(\"summary_op\")[0]\n\n saver = tf.train.Saver(tf.global_variables())\n summary_writer = tf.summary.FileWriter(\n FLAGS.train_dir, graph=tf.get_default_graph())\n\n evl_metrics = eval_util.EvaluationMetrics(reader.num_classes, FLAGS.top_k)\n\n last_global_step_val = -1\n while True:\n last_global_step_val = evaluation_loop(video_id_batch, prediction_batch,\n label_batch, loss, summary_op,\n saver, summary_writer, evl_metrics,\n last_global_step_val)\n if FLAGS.run_once:\n break" }, { "id": 18258, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def main(_):\n\n # pylint: disable=line-too-long\n # Prepare images and checkpoints: please run these commands in shell.\n # !mkdir tmp\n # !wget https://user-images.githubusercontent.com/11736571/77320690-099af300-6d37-11ea-9d86-24f14dc2d540.png -O tmp/img.png\n # !wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz -O tmp/efficientdet-d0.tar.gz\n # !tar zxf tmp/efficientdet-d0.tar.gz -C tmp\n imgs = [np.array(Image.open(FLAGS.image_path))]\n # Create model config.\n config = hparams_config.get_efficientdet_config(FLAGS.model_name)\n config.is_training_bn = False\n config.image_size = '1920x1280'\n config.nms_configs.score_thresh = 0.4\n config.nms_configs.max_output_size = 100\n config.override(FLAGS.hparams)\n\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('float32')\n tf.keras.mixed_precision.set_global_policy(policy)\n tf.config.run_functions_eagerly(FLAGS.debug)\n\n # Create and run the model.\n model = efficientdet_keras.EfficientDetModel(config=config)\n model.build((None, None, None, 3))\n model.load_weights(tf.train.latest_checkpoint(FLAGS.model_dir))\n model.summary(expand_nested=True)\n\n class ExportModel(tf.Module):\n\n def __init__(self, model):\n super().__init__()\n self.model = model\n\n @tf.function\n def f(self, imgs):\n return self.model(imgs, training=False, post_mode='global')\n\n imgs = tf.convert_to_tensor(imgs, dtype=tf.uint8)\n export_model = ExportModel(model)\n if FLAGS.saved_model_dir:\n tf.saved_model.save(\n export_model,\n FLAGS.saved_model_dir,\n signatures=export_model.f.get_concrete_function(\n tf.TensorSpec(shape=(None, None, None, 3), dtype=tf.uint8)))\n export_model = tf.saved_model.load(FLAGS.saved_model_dir)\n\n boxes, scores, classes, valid_len = export_model.f(imgs)\n\n # Visualize results.\n for i, img in enumerate(imgs):\n length = valid_len[i]\n img = inference.visualize_image(\n img,\n boxes[i].numpy()[:length],\n classes[i].numpy().astype(np.int)[:length],\n scores[i].numpy()[:length],\n label_map=config.label_map,\n min_score_thresh=config.nms_configs.score_thresh,\n max_boxes_to_draw=config.nms_configs.max_output_size)\n output_image_path = os.path.join(FLAGS.output_dir, str(i) + '.jpg')\n Image.fromarray(img).save(output_image_path)\n print('writing annotated image to %s' % output_image_path)", "probing input": "def main(_):\n\n # pylint: disable=line-too-long\n # Prepare images and checkpoints: please run these commands in shell.\n # !mkdir tmp\n # !wget https://user-images.githubusercontent.com/11736571/77320690-099af300-6d37-11ea-9d86-24f14dc2d540.png -O tmp/img.png\n # !wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz -O tmp/efficientdet-d0.tar.gz\n # !tar zxf tmp/efficientdet-d0.tar.gz -C tmp\n imgs = [np.array(Image.open(FLAGS.image_path))]\n # Create model config.\n config = hparams_config.get_efficientdet_config(FLAGS.model_name)\n config.is_training_bn = False\n config.image_size = '1920x1280'\n config.nms_configs.score_thresh = 0.4\n config.nms_configs.max_output_size = 100\n config.override(FLAGS.hparams)\n\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('float32')\n tf.keras.mixed_precision.set_global_policy(policy)\n", "probing input new": "def main(_):\n\n # pylint: disable=line-too-long\n # Prepare images and checkpoints: please run these commands in shell.\n # !mkdir tmp\n # !wget https://user-images.githubusercontent.com/11736571/77320690-099af300-6d37-11ea-9d86-24f14dc2d540.png -O tmp/img.png\n # !wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz -O tmp/efficientdet-d0.tar.gz\n # !tar zxf tmp/efficientdet-d0.tar.gz -C tmp\n imgs = [np.array(Image.open(FLAGS.image_path))]\n # Create model config.\n config = hparams_config.get_efficientdet_config(FLAGS.model_name)\n config.is_training_bn = False\n config.image_size = '1920x1280'\n config.nms_configs.score_thresh = 0.4\n config.nms_configs.max_output_size = 100\n config.override(FLAGS.hparams)\n\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('float32')\n tf.keras.mixed_precision.set_global_policy(policy)\n tf.config.", "reference": "tf.config.run_functions_eagerly(FLAGS.debug)", "reference dict": { "policy": "tf.keras.mixed_precision.Policy", "model": "efficientdet_keras.EfficientDetModel", "export_model": "ExportModel" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(FLAGS.debug)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": "def main(_):\n\n # pylint: disable=line-too-long\n # Prepare images and checkpoints: please run these commands in shell.\n # !mkdir tmp\n # !wget https://user-images.githubusercontent.com/11736571/77320690-099af300-6d37-11ea-9d86-24f14dc2d540.png -O tmp/img.png\n # !wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz -O tmp/efficientdet-d0.tar.gz\n # !tar zxf tmp/efficientdet-d0.tar.gz -C tmp\n imgs = [np.array(Image.open(FLAGS.image_path))]\n # Create model config.\n config = hparams_config.get_efficientdet_config(FLAGS.model_name)\n config.is_training_bn = False\n config.image_size = '1920x1280'\n config.nms_configs.score_thresh = 0.4\n config.nms_configs.max_output_size = 100\n config.override(FLAGS.hparams)\n\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('float32')\n tf.keras.mixed_precision.set_global_policy(policy)\n tf.config.run_functions_eagerly(FLAGS.debug)\n\n # Create and run the model.\n model = efficientdet_keras.EfficientDetModel(config=config)\n model.build((None, None, None, 3))\n model.load_weights(tf.train.latest_checkpoint(FLAGS.model_dir))\n model.summary(expand_nested=True)\n\n class ExportModel(tf.Module):\n\n def __init__(self, model):\n super().__init__()\n self.model = model\n\n @tf.function\n def f(self, imgs):\n return self.model(imgs, training=False, post_mode='global')\n\n imgs = tf.convert_to_tensor(imgs, dtype=tf.uint8)\n export_model = ExportModel(model)\n if FLAGS.saved_model_dir:\n tf.saved_model.save(\n export_model,\n FLAGS.saved_model_dir,\n signatures=export_model.f.get_concrete_function(\n tf.TensorSpec(shape=(None, None, None, 3), dtype=tf.uint8)))\n export_model = tf.saved_model.load(FLAGS.saved_model_dir)\n\n boxes, scores, classes, valid_len = export_model.f(imgs)\n\n # Visualize results.\n for i, img in enumerate(imgs):\n length = valid_len[i]\n img = inference.visualize_image(\n img,\n boxes[i].numpy()[:length],\n classes[i].numpy().astype(np.int)[:length],\n scores[i].numpy()[:length],\n label_map=config.label_map,\n min_score_thresh=config.nms_configs.score_thresh,\n max_boxes_to_draw=config.nms_configs.max_output_size)\n output_image_path = os.path.join(FLAGS.output_dir, str(i) + '.jpg')\n Image.fromarray(img).save(output_image_path)\n print('writing annotated image to %s' % output_image_path)" }, { "id": 18259, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def main(_):\n tf.config.run_functions_eagerly(False)\n logging.set_verbosity(logging.INFO)\n tf.compat.v1.enable_v2_behavior()\n strategy = strategy_utils.get_strategy(FLAGS.tpu, FLAGS.use_gpu)\n\n gin.parse_config_files_and_bindings(FLAGS.gin_file, FLAGS.gin_bindings)\n logging.info('Gin bindings: %s', FLAGS.gin_bindings)\n logging.info('# Gin-Config:\\n %s', gin.config.operative_config_str())\n\n train_eval(FLAGS.root_dir, strategy=strategy, reverb_port=FLAGS.reverb_port)", "probing input": "def main(_):\n", "probing input new": "def main(_):\n tf.config.", "reference": "tf.config.run_functions_eagerly(False)", "reference dict": {}, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(False)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": "def main(_):\n tf.config.run_functions_eagerly(False)\n logging.set_verbosity(logging.INFO)\n tf.compat.v1.enable_v2_behavior()\n strategy = strategy_utils.get_strategy(FLAGS.tpu, FLAGS.use_gpu)\n\n gin.parse_config_files_and_bindings(FLAGS.gin_file, FLAGS.gin_bindings)\n logging.info('Gin bindings: %s', FLAGS.gin_bindings)\n logging.info('# Gin-Config:\\n %s', gin.config.operative_config_str())\n\n train_eval(FLAGS.root_dir, strategy=strategy, reverb_port=FLAGS.reverb_port)" }, { "id": 18260, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def testConcat(self):\n \"\"\"Tests inconsistent behavior with `.concat()`.\n\n Bugs: b/180921284\n Status: Missing error message\n Issue: Running functions eagerly, calling `.concat` on a `tf.TensorArray`\n should raise an error but it does not.\n\n Error message:\n Expected error message is \"Concatenating scalars in `tf.TensorArray` is\n unsupported in eager mode. Please use `.stack()` instead\".\n\n Improve error message? Needed. (b/187851559)\n\n Notes:\n * Inconsistent behavior between eager and non-eager mode execution of the\n `tf.function` decorated function. In graph mode, the error is thrown.\n * We need to improve graph mode error message though. The error gets thrown\n is \"Shapes must be equal rank, but are 1 and 0\" and is hard to grasp.\n * Using `.stack()` as a workaround is working as intended:\n ```\n def f(x):\n return x.write(1, tf.constant([4, 5, 6]))\n\n ta = tf.TensorArray(dtype=tf.int32, dynamic_size=True, size=0)\n ta = ta.write(0, tf.constant([1, 2, 3]))\n f(ta).stack() # \n ```\n \"\"\"\n self.skipTest('b/180921284')\n try:\n tf.config.run_functions_eagerly(True)\n\n @tf.function\n def f(x, y, z):\n ta = tf.TensorArray(size=3, dtype=tf.int32, element_shape=())\n ta = ta.write(0, x)\n ta = ta.write(1, y)\n ta = ta.write(2, z)\n return ta.concat()\n\n with self.assertRaisesWithPredicateMatch(\n BaseException,\n # TODO(hyey): Below is a placeholder error message of what we\n # probably want but it needs to be updated to specify what caused\n # the error and where.\n 'Concatenating scalars in `tf.TensorArray` is unsupported in eager '\n 'mode. Please use `.stack()` instead'):\n f(1, 2, 3)\n\n finally:\n tf.config.run_functions_eagerly(False)", "probing input": " def testConcat(self):\n \"\"\"Tests inconsistent behavior with `.concat()`.\n\n Bugs: b/180921284\n Status: Missing error message\n Issue: Running functions eagerly, calling `.concat` on a `tf.TensorArray`\n should raise an error but it does not.\n\n Error message:\n Expected error message is \"Concatenating scalars in `tf.TensorArray` is\n unsupported in eager mode. Please use `.stack()` instead\".\n\n Improve error message? Needed. (b/187851559)\n\n Notes:\n * Inconsistent behavior between eager and non-eager mode execution of the\n `tf.function` decorated function. In graph mode, the error is thrown.\n * We need to improve graph mode error message though. The error gets thrown\n is \"Shapes must be equal rank, but are 1 and 0\" and is hard to grasp.\n * Using `.stack()` as a workaround is working as intended:\n ```\n def f(x):\n return x.write(1, tf.constant([4, 5, 6]))\n\n ta = tf.TensorArray(dtype=tf.int32, dynamic_size=True, size=0)\n ta = ta.write(0, tf.constant([1, 2, 3]))\n f(ta).stack() # \n ```\n \"\"\"\n self.skipTest('b/180921284')\n try:\n", "probing input new": " def testConcat(self):\n \"\"\"Tests inconsistent behavior with `.concat()`.\n\n Bugs: b/180921284\n Status: Missing error message\n Issue: Running functions eagerly, calling `.concat` on a `tf.TensorArray`\n should raise an error but it does not.\n\n Error message:\n Expected error message is \"Concatenating scalars in `tf.TensorArray` is\n unsupported in eager mode. Please use `.stack()` instead\".\n\n Improve error message? Needed. (b/187851559)\n\n Notes:\n * Inconsistent behavior between eager and non-eager mode execution of the\n `tf.function` decorated function. In graph mode, the error is thrown.\n * We need to improve graph mode error message though. The error gets thrown\n is \"Shapes must be equal rank, but are 1 and 0\" and is hard to grasp.\n * Using `.stack()` as a workaround is working as intended:\n ```\n def f(x):\n return x.write(1, tf.constant([4, 5, 6]))\n\n ta = tf.TensorArray(dtype=tf.int32, dynamic_size=True, size=0)\n ta = ta.write(0, tf.constant([1, 2, 3]))\n f(ta).stack() # \n ```\n \"\"\"\n self.skipTest('b/180921284')\n try:\n tf.config.", "reference": "tf.config.run_functions_eagerly(True)", "reference dict": { "ta": "tf.TensorArray" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(True)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": " def testConcat(self):\n \"\"\"Tests inconsistent behavior with `.concat()`.\n\n Bugs: b/180921284\n Status: Missing error message\n Issue: Running functions eagerly, calling `.concat` on a `tf.TensorArray`\n should raise an error but it does not.\n\n Error message:\n Expected error message is \"Concatenating scalars in `tf.TensorArray` is\n unsupported in eager mode. Please use `.stack()` instead\".\n\n Improve error message? Needed. (b/187851559)\n\n Notes:\n * Inconsistent behavior between eager and non-eager mode execution of the\n `tf.function` decorated function. In graph mode, the error is thrown.\n * We need to improve graph mode error message though. The error gets thrown\n is \"Shapes must be equal rank, but are 1 and 0\" and is hard to grasp.\n * Using `.stack()` as a workaround is working as intended:\n ```\n def f(x):\n return x.write(1, tf.constant([4, 5, 6]))\n\n ta = tf.TensorArray(dtype=tf.int32, dynamic_size=True, size=0)\n ta = ta.write(0, tf.constant([1, 2, 3]))\n f(ta).stack() # \n ```\n \"\"\"\n self.skipTest('b/180921284')\n try:\n tf.config.run_functions_eagerly(True)\n\n @tf.function\n def f(x, y, z):\n ta = tf.TensorArray(size=3, dtype=tf.int32, element_shape=())\n ta = ta.write(0, x)\n ta = ta.write(1, y)\n ta = ta.write(2, z)\n return ta.concat()\n\n with self.assertRaisesWithPredicateMatch(\n BaseException,\n # TODO(hyey): Below is a placeholder error message of what we\n # probably want but it needs to be updated to specify what caused\n # the error and where.\n 'Concatenating scalars in `tf.TensorArray` is unsupported in eager '\n 'mode. Please use `.stack()` instead'):\n f(1, 2, 3)\n\n finally:\n tf.config.run_functions_eagerly(False)" }, { "id": 18261, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "debug_data = False\noptimise = True\ndebug = False\nprofile = False\ntf.config.run_functions_eagerly(debug or debug_data or not params.graph_mode)", "probing input": "debug_data = False\noptimise = True\ndebug = False\nprofile = False\n", "probing input new": "debug_data = False\noptimise = True\ndebug = False\nprofile = False\ntf.config.", "reference": "tf.config.run_functions_eagerly(debugordebug_dataornotparams.graph_mode)", "reference dict": { "model": "tem.TEM", "optimizer": "tf.keras.optimizers.Adam" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(debugordebug_dataornotparams.graph_mode)", "y_neg": "tf.config.experimental_run_functions_eagerly(debug_data)", "retain": "debug_data = False\noptimise = True\ndebug = False\nprofile = False\ntf.config.run_functions_eagerly(debug or debug_data or not params.graph_mode)" }, { "id": 18262, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": "def build_tf2_model():\n \"\"\"Build the tf2 model.\"\"\"\n tf.config.run_functions_eagerly(FLAGS.debug)\n if FLAGS.mixed_precision:\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('mixed_float16')\n tf.keras.mixed_precision.set_global_policy(policy)\n\n model = effnetv2_model.get_model(\n FLAGS.model_name,\n FLAGS.hparam_str,\n include_top=True,\n weights=FLAGS.model_dir or 'imagenet')\n model.summary()\n return model", "probing input": "def build_tf2_model():\n \"\"\"Build the tf2 model.\"\"\"\n", "probing input new": "def build_tf2_model():\n \"\"\"Build the tf2 model.\"\"\"\n tf.config.", "reference": "tf.config.run_functions_eagerly(FLAGS.debug)", "reference dict": { "policy": "tf.keras.mixed_precision.Policy" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial", "tf1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf1.all_variables": "tensorflow.compat.v1.all_variables", "tf1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf1.to_int64": "tensorflow.compat.v1.to_int64", "tf1.to_int32": "tensorflow.compat.v1.to_int32", "tf1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf1.div": "tensorflow.compat.v1.div", "tf1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf1.to_double": "tensorflow.compat.v1.to_double", "tf1.arg_min": "tensorflow.compat.v1.arg_min", "tf1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf1.substr": "tensorflow.compat.v1.substr", "tf1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf1.arg_max": "tensorflow.compat.v1.arg_max", "tf1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf1.Print": "tensorflow.compat.v1.Print", "tf1.to_float": "tensorflow.compat.v1.to_float", "tf1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf1.multinomial": "tensorflow.compat.v1.multinomial", "tf1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(FLAGS.debug)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": "def build_tf2_model():\n \"\"\"Build the tf2 model.\"\"\"\n tf.config.run_functions_eagerly(FLAGS.debug)\n if FLAGS.mixed_precision:\n # Use 'mixed_float16' if running on GPUs.\n policy = tf.keras.mixed_precision.Policy('mixed_float16')\n tf.keras.mixed_precision.set_global_policy(policy)\n\n model = effnetv2_model.get_model(\n FLAGS.model_name,\n FLAGS.hparam_str,\n include_top=True,\n weights=FLAGS.model_dir or 'imagenet')\n model.summary()\n return model" }, { "id": 18265, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def build(self, params_override=None):\n \"\"\"Build model and restore checkpoints.\"\"\"\n params = copy.deepcopy(self.params)\n if params_override:\n params.update(params_override)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n if self.only_network:\n self.model = efficientdet_keras.EfficientDetNet(config=config)\n else:\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(params['image_size'])\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(self.model, self.ckpt_path,\n self.params['moving_average_decay'],\n skip_mismatch=False)\n if self.debug:\n tf.config.run_functions_eagerly(self.debug)", "probing input": " def build(self, params_override=None):\n \"\"\"Build model and restore checkpoints.\"\"\"\n params = copy.deepcopy(self.params)\n if params_override:\n params.update(params_override)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n if self.only_network:\n self.model = efficientdet_keras.EfficientDetNet(config=config)\n else:\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(params['image_size'])\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(self.model, self.ckpt_path,\n self.params['moving_average_decay'],\n skip_mismatch=False)\n if self.debug:\n", "probing input new": " def build(self, params_override=None):\n \"\"\"Build model and restore checkpoints.\"\"\"\n params = copy.deepcopy(self.params)\n if params_override:\n params.update(params_override)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n if self.only_network:\n self.model = efficientdet_keras.EfficientDetNet(config=config)\n else:\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(params['image_size'])\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(self.model, self.ckpt_path,\n self.params['moving_average_decay'],\n skip_mismatch=False)\n if self.debug:\n tf.config.", "reference": "tf.config.run_functions_eagerly(self.debug)", "reference dict": { "self.model": "efficientdet_keras.EfficientDetModel" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(self.debug)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": " def build(self, params_override=None):\n \"\"\"Build model and restore checkpoints.\"\"\"\n params = copy.deepcopy(self.params)\n if params_override:\n params.update(params_override)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n if self.only_network:\n self.model = efficientdet_keras.EfficientDetNet(config=config)\n else:\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(params['image_size'])\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(self.model, self.ckpt_path,\n self.params['moving_average_decay'],\n skip_mismatch=False)\n if self.debug:\n tf.config.run_functions_eagerly(self.debug)" }, { "id": 18266, "library": "tensorflow", "category": "up-to-dated", "source": "sourcegraph", "function": " def __init__(self, ckpt_path, debug, *args, **kwargs):\n \"\"\" Initialize the inference driver.\n\n Args:\n ckpt_path: checkpoint path, such as /tmp/efficientdet-d0/.\n debug: bool, if true, run in debug mode.\n \"\"\"\n super().__init__(*args, **kwargs)\n params = copy.deepcopy(self.params)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n precision = utils.get_precision(config.strategy, config.mixed_precision)\n policy = tf.keras.mixed_precision.Policy(precision)\n tf.keras.mixed_precision.set_global_policy(policy)\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(config.image_size)\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(\n self.model, ckpt_path, config.moving_average_decay, skip_mismatch=False)\n self.debug = debug\n if debug:\n tf.config.run_functions_eagerly(debug)", "probing input": " def __init__(self, ckpt_path, debug, *args, **kwargs):\n \"\"\" Initialize the inference driver.\n\n Args:\n ckpt_path: checkpoint path, such as /tmp/efficientdet-d0/.\n debug: bool, if true, run in debug mode.\n \"\"\"\n super().__init__(*args, **kwargs)\n params = copy.deepcopy(self.params)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n precision = utils.get_precision(config.strategy, config.mixed_precision)\n policy = tf.keras.mixed_precision.Policy(precision)\n tf.keras.mixed_precision.set_global_policy(policy)\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(config.image_size)\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(\n self.model, ckpt_path, config.moving_average_decay, skip_mismatch=False)\n self.debug = debug\n if debug:\n", "probing input new": " def __init__(self, ckpt_path, debug, *args, **kwargs):\n \"\"\" Initialize the inference driver.\n\n Args:\n ckpt_path: checkpoint path, such as /tmp/efficientdet-d0/.\n debug: bool, if true, run in debug mode.\n \"\"\"\n super().__init__(*args, **kwargs)\n params = copy.deepcopy(self.params)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n precision = utils.get_precision(config.strategy, config.mixed_precision)\n policy = tf.keras.mixed_precision.Policy(precision)\n tf.keras.mixed_precision.set_global_policy(policy)\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(config.image_size)\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(\n self.model, ckpt_path, config.moving_average_decay, skip_mismatch=False)\n self.debug = debug\n if debug:\n tf.config.", "reference": "tf.config.run_functions_eagerly(debug)", "reference dict": { "policy": "tf.keras.mixed_precision.Policy", "self.model": "efficientdet_keras.EfficientDetModel" }, "alias dict": { "tf.to_complex128": "tensorflow.to_complex128", "tf.compat.v1.initialize_variables": "tensorflow.compat.v1.initialize_variables", "tf.metrics.sparse_average_precision_at_k": "tensorflow.metrics.sparse_average_precision_at_k", "tf.compat.v1.train.experimental.DynamicLossScale": "tensorflow.compat.v1.train.experimental.DynamicLossScale", "tf.data.experimental.dense_to_sparse_batch": "tensorflow.data.experimental.dense_to_sparse_batch", "tf.metrics.auc": "tensorflow.metrics.auc", "tf.compat.v1.initialize_all_tables": "tensorflow.compat.v1.initialize_all_tables", "tf.clip_by_average_norm": "tensorflow.clip_by_average_norm", "tf.compat.v1.mixed_precision.FixedLossScale": "tensorflow.compat.v1.mixed_precision.FixedLossScale", "tf.variables_initializer": "tensorflow.variables_initializer", "tf.saved_model.load": "tensorflow.saved_model.load", "tf.compat.v1.to_int32": "tensorflow.compat.v1.to_int32", "tf.config.functions_run_eagerly": "tensorflow.config.functions_run_eagerly", "tf.compat.v1.div": "tensorflow.compat.v1.div", "tf.print": "tensorflow.print", "tf.compat.v1.image.sample_distorted_bounding_box": "tensorflow.compat.v1.image.sample_distorted_bounding_box", "tf.substr": "tensorflow.substr", "tf.train.experimental.FixedLossScale": "tensorflow.train.experimental.FixedLossScale", "tf.initializers.variance_scaling": "tensorflow.initializers.variance_scaling", "tf.compat.v1.arg_min": "tensorflow.compat.v1.arg_min", "tf.config.experimental_run_functions_eagerly": "tensorflow.config.experimental_run_functions_eagerly", "tf.load_file_system_library": "tensorflow.load_file_system_library", "tf.RaggedTensorSpec": "tensorflow.RaggedTensorSpec", "tf.multinomial": "tensorflow.multinomial", "tf.initialize_all_tables": "tensorflow.initialize_all_tables", "tf.compat.v1.saved_model.loader.load": "tensorflow.compat.v1.saved_model.loader.load", "tf.compat.v1.mixed_precision.experimental.FixedLossScale": "tensorflow.compat.v1.mixed_precision.experimental.FixedLossScale", "tf.compat.v1.load_file_system_library": "tensorflow.compat.v1.load_file_system_library", "tf.global_variables": "tensorflow.global_variables", "tf.sample_distorted_bounding_box_v2": "tensorflow.sample_distorted_bounding_box_v2", "tf.config.experimental_functions_run_eagerly": "tensorflow.config.experimental_functions_run_eagerly", "tf.keras.layers.experimental.preprocessing.HashedCrossing": "tensorflow.keras.layers.experimental.preprocessing.HashedCrossing", "tf.data.experimental.TensorStructure": "tensorflow.data.experimental.TensorStructure", "tf.random.stateless_categorical": "tensorflow.random.stateless_categorical", "tf.Print": "tensorflow.Print", "tf.compat.v1.random.multinomial": "tensorflow.compat.v1.random.multinomial", "tf.compat.v1.initialize_local_variables": "tensorflow.compat.v1.initialize_local_variables", "tf.uniform_unit_scaling_initializer": "tensorflow.uniform_unit_scaling_initializer", "tf.compat.v1.data.experimental.TensorArrayStructure": "tensorflow.compat.v1.data.experimental.TensorArrayStructure", "tf.image.sample_distorted_bounding_box": "tensorflow.image.sample_distorted_bounding_box", "tf.metrics.sparse_precision_at_k": "tensorflow.metrics.sparse_precision_at_k", "tf.data.Dataset.ragged_batch": "tensorflow.data.Dataset.ragged_batch", "tf.data.Dataset.ignore_errors": "tensorflow.data.Dataset.ignore_errors", "tf.random.stateless_multinomial": "tensorflow.random.stateless_multinomial", "tf.distribute.experimental.MultiWorkerMirroredStrategy": "tensorflow.distribute.experimental.MultiWorkerMirroredStrategy", "tf.sparse.to_dense": "tensorflow.sparse.to_dense", "tf.feature_column.crossed_column": "tensorflow.feature_column.crossed_column", "tf.compat.v1.to_int64": "tensorflow.compat.v1.to_int64", "tf.compat.v1.train.experimental.FixedLossScale": "tensorflow.compat.v1.train.experimental.FixedLossScale", "tf.quantize_v2": "tensorflow.quantize_v2", "tf.compat.v1.initialize_all_variables": "tensorflow.compat.v1.initialize_all_variables", "tf.compat.v1.data.experimental.TensorStructure": "tensorflow.compat.v1.data.experimental.TensorStructure", "tf.data.experimental.get_next_as_optional": "tensorflow.data.experimental.get_next_as_optional", "tf.compat.v1.mixed_precision.experimental.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.experimental.DynamicLossScale", "tf.mixed_precision.experimental.DynamicLossScale": "tensorflow.mixed_precision.experimental.DynamicLossScale", "tf.data.Iterator.get_next_as_optional": "tensorflow.data.Iterator.get_next_as_optional", "tf.batch_gather": "tensorflow.batch_gather", "tf.compat.v1.arg_max": "tensorflow.compat.v1.arg_max", "tf.TensorArraySpec": "tensorflow.TensorArraySpec", "tf.div": "tensorflow.div", "tf.compat.v1.random.stateless_multinomial": "tensorflow.compat.v1.random.stateless_multinomial", "tf.compat.v1.Print": "tensorflow.compat.v1.Print", "tf.compat.v1.to_float": "tensorflow.compat.v1.to_float", "tf.data.experimental.ignore_errors": "tensorflow.data.experimental.ignore_errors", "tf.arg_max": "tensorflow.arg_max", "tf.compat.v1.sparse_to_dense": "tensorflow.compat.v1.sparse_to_dense", "tf.keras.metrics.AUC": "tensorflow.keras.metrics.AUC", "tf.mixed_precision.DynamicLossScale": "tensorflow.mixed_precision.DynamicLossScale", "tf.distribute.MultiWorkerMirroredStrategy": "tensorflow.distribute.MultiWorkerMirroredStrategy", "tf.random.categorical": "tensorflow.random.categorical", "tf.tables_initializer": "tensorflow.tables_initializer", "tf.compat.v1.metrics.sparse_average_precision_at_k": "tensorflow.compat.v1.metrics.sparse_average_precision_at_k", "tf.compat.v1.batch_gather": "tensorflow.compat.v1.batch_gather", "tf.compat.v1.metrics.sparse_precision_at_k": "tensorflow.compat.v1.metrics.sparse_precision_at_k", "tf.data.experimental.RaggedTensorStructure": "tensorflow.data.experimental.RaggedTensorStructure", "tf.data.experimental.TensorArrayStructure": "tensorflow.data.experimental.TensorArrayStructure", "tf.config.run_functions_eagerly": "tensorflow.config.run_functions_eagerly", "tf.math.argmin": "tensorflow.math.argmin", "tf.random.multinomial": "tensorflow.random.multinomial", "tf.data.experimental.make_saveable_from_iterator": "tensorflow.data.experimental.make_saveable_from_iterator", "tf.train.experimental.DynamicLossScale": "tensorflow.train.experimental.DynamicLossScale", "tf.to_bfloat16": "tensorflow.to_bfloat16", "tf.all_variables": "tensorflow.all_variables", "tf.compat.v1.data.experimental.SparseTensorStructure": "tensorflow.compat.v1.data.experimental.SparseTensorStructure", "tf.compat.v1.substr": "tensorflow.compat.v1.substr", "tf.compat.v1.to_complex128": "tensorflow.compat.v1.to_complex128", "tf.data.experimental.SparseTensorStructure": "tensorflow.data.experimental.SparseTensorStructure", "tf.load_library": "tensorflow.load_library", "tf.compat.v1.clip_by_average_norm": "tensorflow.compat.v1.clip_by_average_norm", "tf.initialize_all_variables": "tensorflow.initialize_all_variables", "tf.cast": "tensorflow.cast", "tf.compat.v1.saved_model.load": "tensorflow.compat.v1.saved_model.load", "tf.compat.v1.to_bfloat16": "tensorflow.compat.v1.to_bfloat16", "tf.to_int64": "tensorflow.to_int64", "tf.data.Dataset.sparse_batch": "tensorflow.data.Dataset.sparse_batch", "tf.clip_by_norm": "tensorflow.clip_by_norm", "tf.initializers.uniform_unit_scaling": "tensorflow.initializers.uniform_unit_scaling", "tf.compat.v1.quantize_v2": "tensorflow.compat.v1.quantize_v2", "tf.SparseTensorSpec": "tensorflow.SparseTensorSpec", "tf.compat.v1.uniform_unit_scaling_initializer": "tensorflow.compat.v1.uniform_unit_scaling_initializer", "tf.divide": "tensorflow.divide", "tf.mixed_precision.experimental.FixedLossScale": "tensorflow.mixed_precision.experimental.FixedLossScale", "tf.arg_min": "tensorflow.arg_min", "tf.initialize_variables": "tensorflow.initialize_variables", "tf.strings.substr": "tensorflow.strings.substr", "tf.compat.v1.all_variables": "tensorflow.compat.v1.all_variables", "tf.data.experimental.dense_to_ragged_batch": "tensorflow.data.experimental.dense_to_ragged_batch", "tf.to_int32": "tensorflow.to_int32", "tf.compat.v1.initializers.uniform_unit_scaling": "tensorflow.compat.v1.initializers.uniform_unit_scaling", "tf.gather": "tensorflow.gather", "tf.global_variables_initializer": "tensorflow.global_variables_initializer", "tf.compat.v1.mixed_precision.DynamicLossScale": "tensorflow.compat.v1.mixed_precision.DynamicLossScale", "tf.compat.v1.to_complex64": "tensorflow.compat.v1.to_complex64", "tf.to_float": "tensorflow.to_float", "tf.compat.v1.metrics.auc": "tensorflow.compat.v1.metrics.auc", "tf.local_variables_initializer": "tensorflow.local_variables_initializer", "tf.precision_at_k": "tensorflow.precision_at_k", "tf.saved_model.loader.load": "tensorflow.saved_model.loader.load", "tf.compat.v1.to_double": "tensorflow.compat.v1.to_double", "tf.keras.mixed_precision.LossScaleOptimizer": "tensorflow.keras.mixed_precision.LossScaleOptimizer", "tf.to_double": "tensorflow.to_double", "tf.average_precision_at_k": "tensorflow.average_precision_at_k", "tf.TensorSpec": "tensorflow.TensorSpec", "tf.compat.v1.data.experimental.RaggedTensorStructure": "tensorflow.compat.v1.data.experimental.RaggedTensorStructure", "tf.math.argmax": "tensorflow.math.argmax", "tf.train.Checkpoint": "tensorflow.train.Checkpoint", "tf.sparse_to_dense": "tensorflow.sparse_to_dense", "tf.quantization.quantize": "tensorflow.quantization.quantize", "tf.to_complex64": "tensorflow.to_complex64", "tf.mixed_precision.FixedLossScale": "tensorflow.mixed_precision.FixedLossScale", "tf.initialize_local_variables": "tensorflow.initialize_local_variables", "tf.compat.v1.multinomial": "tensorflow.compat.v1.multinomial" }, "deprecated api": [ "tensorflow.config.experimental_run_functions_eagerly" ], "replacement api": "tensorflow.config.run_functions_eagerly", "expected call": "tf.config.run_functions_eagerly", "y_pos": "tf.config.run_functions_eagerly(debug)", "y_neg": " tf.config.experimental_run_functions_eagerly(True)", "retain": " def __init__(self, ckpt_path, debug, *args, **kwargs):\n \"\"\" Initialize the inference driver.\n\n Args:\n ckpt_path: checkpoint path, such as /tmp/efficientdet-d0/.\n debug: bool, if true, run in debug mode.\n \"\"\"\n super().__init__(*args, **kwargs)\n params = copy.deepcopy(self.params)\n config = hparams_config.get_efficientdet_config(self.model_name)\n config.override(params)\n precision = utils.get_precision(config.strategy, config.mixed_precision)\n policy = tf.keras.mixed_precision.Policy(precision)\n tf.keras.mixed_precision.set_global_policy(policy)\n self.model = efficientdet_keras.EfficientDetModel(config=config)\n image_size = utils.parse_image_size(config.image_size)\n self.model.build((self.batch_size, *image_size, 3))\n util_keras.restore_ckpt(\n self.model, ckpt_path, config.moving_average_decay, skip_mismatch=False)\n self.debug = debug\n if debug:\n tf.config.run_functions_eagerly(debug)" } ]