code stringlengths 17 6.64M |
|---|
def rebuild_cond_unit_col(valid_col_units, cond_unit, kmap):
if (cond_unit is None):
return cond_unit
(not_op, op_id, val_unit, val1, val2) = cond_unit
val_unit = rebuild_val_unit_col(valid_col_units, val_unit, kmap)
return (not_op, op_id, val_unit, val1, val2)
|
def rebuild_condition_col(valid_col_units, condition, kmap):
for idx in range(len(condition)):
if ((idx % 2) == 0):
condition[idx] = rebuild_cond_unit_col(valid_col_units, condition[idx], kmap)
return condition
|
def rebuild_select_col(valid_col_units, sel, kmap):
if (sel is None):
return sel
(distinct, _list) = sel
new_list = []
for it in _list:
(agg_id, val_unit) = it
new_list.append((agg_id, rebuild_val_unit_col(valid_col_units, val_unit, kmap)))
if DISABLE_DISTINCT:
dist... |
def rebuild_from_col(valid_col_units, from_, kmap):
if (from_ is None):
return from_
from_['table_units'] = [rebuild_table_unit_col(valid_col_units, table_unit, kmap) for table_unit in from_['table_units']]
from_['conds'] = rebuild_condition_col(valid_col_units, from_['conds'], kmap)
return fr... |
def rebuild_group_by_col(valid_col_units, group_by, kmap):
if (group_by is None):
return group_by
return [rebuild_col_unit_col(valid_col_units, col_unit, kmap) for col_unit in group_by]
|
def rebuild_order_by_col(valid_col_units, order_by, kmap):
if ((order_by is None) or (len(order_by) == 0)):
return order_by
(direction, val_units) = order_by
new_val_units = [rebuild_val_unit_col(valid_col_units, val_unit, kmap) for val_unit in val_units]
return (direction, new_val_units)
|
def rebuild_sql_col(valid_col_units, sql, kmap):
if (sql is None):
return sql
sql['select'] = rebuild_select_col(valid_col_units, sql['select'], kmap)
sql['from'] = rebuild_from_col(valid_col_units, sql['from'], kmap)
sql['where'] = rebuild_condition_col(valid_col_units, sql['where'], kmap)
... |
def build_foreign_key_map(entry):
cols_orig = entry['column_names_original']
tables_orig = entry['table_names_original']
cols = []
for col_orig in cols_orig:
if (col_orig[0] >= 0):
t = tables_orig[col_orig[0]]
c = col_orig[1]
cols.append((((('__' + t.lower()... |
def build_foreign_key_map_from_json(table):
with open(table) as f:
data = json.load(f)
tables = {}
for entry in data:
tables[entry['db_id']] = build_foreign_key_map(entry)
return tables
|
class Schema():
'\n Simple schema which maps table&column to a unique identifier\n '
def __init__(self, schema, table):
self._schema = schema
self._table = table
self._idMap = self._map(self._schema, self._table)
@property
def schema(self):
return self._schema
... |
def get_schemas_from_json(fpath):
with open(fpath) as f:
data = json.load(f)
db_names = [db['db_id'] for db in data]
tables = {}
schemas = {}
for db in data:
db_id = db['db_id']
schema = {}
column_names_original = db['column_names_original']
table_names_orig... |
class Schema():
'\n Simple schema which maps table&column to a unique identifier\n '
def __init__(self, schema):
self._schema = schema
self._idMap = self._map(self._schema)
@property
def schema(self):
return self._schema
@property
def idMap(self):
retur... |
def get_schema(db):
"\n Get database's schema, which is a dict with table name as key\n and list of column names as value\n :param db: database path\n :return: schema dict\n "
schema = {}
conn = sqlite3.connect(db)
cursor = conn.cursor()
cursor.execute("SELECT name FROM sqlite_maste... |
def get_schema_from_json(fpath):
with open(fpath) as f:
data = json.load(f)
schema = {}
for entry in data:
table = str(entry['table'].lower())
cols = [str(col['column_name'].lower()) for col in entry['col_data']]
schema[table] = cols
return schema
|
def tokenize(string):
string = str(string)
string = string.replace("'", '"')
quote_idxs = [idx for (idx, char) in enumerate(string) if (char == '"')]
assert ((len(quote_idxs) % 2) == 0), 'Unexpected quote'
vals = {}
for i in range((len(quote_idxs) - 1), (- 1), (- 2)):
qidx1 = quote_idx... |
def scan_alias(toks):
"Scan the index of 'as' and build the map for all alias"
as_idxs = [idx for (idx, tok) in enumerate(toks) if (tok == 'as')]
alias = {}
for idx in as_idxs:
alias[toks[(idx + 1)]] = toks[(idx - 1)]
return alias
|
def get_tables_with_alias(schema, toks):
tables = scan_alias(toks)
for key in schema:
assert (key not in tables), 'Alias {} has the same name in table'.format(key)
tables[key] = key
return tables
|
def parse_col(toks, start_idx, tables_with_alias, schema, default_tables=None):
'\n :returns next idx, column id\n '
tok = toks[start_idx]
if (tok == '*'):
return ((start_idx + 1), schema.idMap[tok])
if ('.' in tok):
(alias, col) = tok.split('.')
key = ((tables_with_a... |
def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):
'\n :returns next idx, (agg_op id, col_id)\n '
idx = start_idx
len_ = len(toks)
isBlock = False
isDistinct = False
if (toks[idx] == '('):
isBlock = True
idx += 1
if (toks[idx] in ... |
def parse_val_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):
idx = start_idx
len_ = len(toks)
isBlock = False
if (toks[idx] == '('):
isBlock = True
idx += 1
col_unit1 = None
col_unit2 = None
unit_op = UNIT_OPS.index('none')
(idx, col_unit1) = par... |
def parse_table_unit(toks, start_idx, tables_with_alias, schema):
'\n :returns next idx, table id, table name\n '
idx = start_idx
len_ = len(toks)
key = tables_with_alias[toks[idx]]
if (((idx + 1) < len_) and (toks[(idx + 1)] == 'as')):
idx += 3
else:
idx += 1
ret... |
def parse_value(toks, start_idx, tables_with_alias, schema, default_tables=None):
idx = start_idx
len_ = len(toks)
isBlock = False
if (toks[idx] == '('):
isBlock = True
idx += 1
if (toks[idx] == 'select'):
(idx, val) = parse_sql(toks, idx, tables_with_alias, schema)
eli... |
def parse_condition(toks, start_idx, tables_with_alias, schema, default_tables=None):
idx = start_idx
len_ = len(toks)
conds = []
while (idx < len_):
(idx, val_unit) = parse_val_unit(toks, idx, tables_with_alias, schema, default_tables)
not_op = False
if (toks[idx] == 'not'):
... |
def parse_select(toks, start_idx, tables_with_alias, schema, default_tables=None):
idx = start_idx
len_ = len(toks)
assert (toks[idx] == 'select'), "'select' not found"
idx += 1
isDistinct = False
if ((idx < len_) and (toks[idx] == 'distinct')):
idx += 1
isDistinct = True
v... |
def parse_from(toks, start_idx, tables_with_alias, schema):
'\n Assume in the from clause, all table units are combined with join\n '
assert ('from' in toks[start_idx:]), "'from' not found"
len_ = len(toks)
idx = (toks.index('from', start_idx) + 1)
default_tables = []
table_units = []
... |
def parse_where(toks, start_idx, tables_with_alias, schema, default_tables):
idx = start_idx
len_ = len(toks)
if ((idx >= len_) or (toks[idx] != 'where')):
return (idx, [])
idx += 1
(idx, conds) = parse_condition(toks, idx, tables_with_alias, schema, default_tables)
return (idx, conds)... |
def parse_group_by(toks, start_idx, tables_with_alias, schema, default_tables):
idx = start_idx
len_ = len(toks)
col_units = []
if ((idx >= len_) or (toks[idx] != 'group')):
return (idx, col_units)
idx += 1
assert (toks[idx] == 'by')
idx += 1
while ((idx < len_) and (not ((toks... |
def parse_order_by(toks, start_idx, tables_with_alias, schema, default_tables):
idx = start_idx
len_ = len(toks)
val_units = []
order_type = 'asc'
if ((idx >= len_) or (toks[idx] != 'order')):
return (idx, val_units)
idx += 1
assert (toks[idx] == 'by')
idx += 1
while ((idx ... |
def parse_having(toks, start_idx, tables_with_alias, schema, default_tables):
idx = start_idx
len_ = len(toks)
if ((idx >= len_) or (toks[idx] != 'having')):
return (idx, [])
idx += 1
(idx, conds) = parse_condition(toks, idx, tables_with_alias, schema, default_tables)
return (idx, cond... |
def parse_limit(toks, start_idx):
idx = start_idx
len_ = len(toks)
if ((idx < len_) and (toks[idx] == 'limit')):
idx += 2
return (idx, int(toks[(idx - 1)]))
return (idx, None)
|
def parse_sql(toks, start_idx, tables_with_alias, schema):
isBlock = False
len_ = len(toks)
idx = start_idx
sql = {}
if (toks[idx] == '('):
isBlock = True
idx += 1
(from_end_idx, table_units, conds, default_tables) = parse_from(toks, start_idx, tables_with_alias, schema)
sq... |
def load_data(fpath):
with open(fpath) as f:
data = json.load(f)
return data
|
def get_sql(schema, query):
toks = tokenize(query)
tables_with_alias = get_tables_with_alias(schema.schema, toks)
(_, sql) = parse_sql(toks, 0, tables_with_alias, schema)
return sql
|
def skip_semicolon(toks, start_idx):
idx = start_idx
while ((idx < len(toks)) and (toks[idx] == ';')):
idx += 1
return idx
|
class Column():
ATTRIBUTE_TXT = 'TXT'
ATTRIBUTE_NUM = 'NUM'
ATTRIBUTE_GROUP_BY_ABLE = 'GROUPBY'
def __init__(self, name, natural_name, table=None, attributes=None):
self.name = name
self.natural_name = natural_name
self.table = table
if (attributes is not None):
... |
class Table(object):
def __init__(self, name, natural_name):
self.name = name
self.natural_name = natural_name
self.foreign_keys = []
def add_foreign_key_to(self, my_col, their_col, that_table):
self.foreign_keys.append((my_col, their_col, that_table))
def get_foreign_ke... |
class DummyTable(Table):
def add_foreign_key_to(self, my_col, their_col, that_table):
pass
def get_foreign_keys(self):
return []
|
class ColumnPlaceholder():
def __init__(self, id_in_pattern, attributes):
self.id_in_pattern = id_in_pattern
self.attributes = attributes
self.column = None
def attach_to_column(self, column):
self.column = column
|
class Pattern():
def __init__(self, schema, json_data):
self.schema = schema
self.raw_sql = json_data['SQL Pattern']
self.raw_questions = json_data['Question Patterns']
reference_id_to_original_id = json_data['Column Identity']
self.column_identity = {}
for (refere... |
class Schema():
def __init__(self, json_data):
tables = []
table_index_to_table_object = {}
table_name_to_table_object = {}
next_table_index = 0
self.orginal_table = json_data['table_names_original']
for (table_name, table_name_natural) in zip(json_data['table_name... |
def load_database_schema(path):
data = json.load(open(path, 'r'))
schema = Schema(random.choice(data))
return schema
|
def load_patterns(data, schema):
patterns = []
for pattern_data in data:
patterns.append(Pattern(schema, pattern_data))
return patterns
|
def generate_every_db(db, schemas, tables, patterns_data):
db_name = db['db_id']
col_types = db['column_types']
process_sql_schema = schema_mod.Schema(schemas[db_name], tables[db_name])
if ('number' in col_types):
try:
schema = Schema(db)
except:
traceback.print... |
def convert_to_op_index(is_not, op):
op = OLD_WHERE_OPS[op]
if (is_not and (op == 'in')):
return 7
try:
return NEW_WHERE_DICT[op]
except:
print('Unsupport op: {}'.format(op))
return (- 1)
|
def index_to_column_name(index, table):
column_name = table['column_names'][index][1]
table_index = table['column_names'][index][0]
table_name = table['table_names'][table_index]
return (table_name, column_name, index)
|
def get_label_cols(with_join, fk_dict, labels):
cols = set()
ret = []
for i in range(len(labels)):
cols.add(labels[i][0][2])
if (len(cols) > 3):
break
for col in cols:
if (with_join and (len(fk_dict[col]) > 0)):
ret.append(([col] + fk_dict[col]))
... |
class MultiSqlPredictor():
def __init__(self, question, sql, history):
self.sql = sql
self.question = question
self.history = history
self.keywords = ('intersect', 'except', 'union')
def generate_output(self):
for key in self.sql:
if ((key in self.keywords... |
class KeyWordPredictor():
def __init__(self, question, sql, history):
self.sql = sql
self.question = question
self.history = history
self.keywords = ('select', 'where', 'groupBy', 'orderBy', 'limit', 'having')
def generate_output(self):
sql_keywords = []
for k... |
class ColPredictor():
def __init__(self, question, sql, table, history, kw=None):
self.sql = sql
self.question = question
self.history = history
self.table = table
self.keywords = ('select', 'where', 'groupBy', 'orderBy', 'having')
self.kw = kw
def generate_ou... |
class OpPredictor():
def __init__(self, question, sql, history):
self.sql = sql
self.question = question
self.history = history
def generate_output(self):
return (self.history, convert_to_op_index(self.sql[0], self.sql[1]), (self.sql[3], self.sql[4]))
|
class AggPredictor():
def __init__(self, question, sql, history, kw=None):
self.sql = sql
self.question = question
self.history = history
self.kw = kw
def generate_output(self):
label = (- 1)
if self.kw:
key = self.kw
else:
key ... |
class DesAscPredictor():
def __init__(self, question, sql, table, history):
self.sql = sql
self.question = question
self.history = history
self.table = table
def generate_output(self):
for key in self.sql:
if ((key == 'orderBy') and self.sql[key]):
... |
class AndOrPredictor():
def __init__(self, question, sql, table, history):
self.sql = sql
self.question = question
self.history = history
self.table = table
def generate_output(self):
if (('where' in self.sql) and self.sql['where'] and (len(self.sql['where']) > 1)):
... |
def parser_item_with_long_history(question_tokens, sql, table, history, dataset):
table_schema = [table['table_names'], table['column_names'], table['column_types']]
stack = [('root', sql)]
with_join = False
fk_dict = defaultdict(list)
for fk in table['foreign_keys']:
fk_dict[fk[0]].append... |
def parser_item(question_tokens, sql, table, history, dataset):
table_schema = [table['table_names'], table['column_names'], table['column_types']]
(history, label, sql) = MultiSqlPredictor(question_tokens, sql, history).generate_output()
dataset['multi_sql_dataset'].append({'question_tokens': question_to... |
def get_table_dict(table_data_path):
data = json.load(open(table_data_path))
table = dict()
for item in data:
table[item['db_id']] = item
return table
|
def parse_data(data):
dataset = {'multi_sql_dataset': [], 'keyword_dataset': [], 'col_dataset': [], 'op_dataset': [], 'agg_dataset': [], 'root_tem_dataset': [], 'des_asc_dataset': [], 'having_dataset': [], 'andor_dataset': []}
table_dict = get_table_dict(table_data_path)
for item in data:
if (hist... |
class Stack():
def __init__(self):
self.items = []
def isEmpty(self):
return (self.items == [])
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[(len(self.items) - 1)]
def size(s... |
def to_batch_tables(tables, B, table_type):
col_seq = []
ts = [tables['table_names'], tables['column_names'], tables['column_types']]
tname_toks = [x.split(' ') for x in ts[0]]
col_type = ts[2]
cols = [x.split(' ') for (xid, x) in ts[1]]
tab_seq = [xid for (xid, x) in ts[1]]
cols_add = []
... |
class SuperModel(nn.Module):
def __init__(self, word_emb, N_word, N_h=300, N_depth=2, gpu=True, trainable_emb=False, table_type='std', use_hs=True):
super(SuperModel, self).__init__()
self.gpu = gpu
self.N_h = N_h
self.N_depth = N_depth
self.trainable_emb = trainable_emb
... |
@attr.s
class TrainConfig():
eval_every_n = attr.ib(default=100)
report_every_n = attr.ib(default=100)
save_every_n = attr.ib(default=100)
keep_every_n = attr.ib(default=1000)
batch_size = attr.ib(default=32)
eval_batch_size = attr.ib(default=32)
max_steps = attr.ib(default=100000)
num... |
class Logger():
def __init__(self, log_path=None, reopen_to_flush=False):
self.log_file = None
self.reopen_to_flush = reopen_to_flush
if (log_path is not None):
os.makedirs(os.path.dirname(log_path), exist_ok=True)
self.log_file = open(log_path, 'a+')
def log(... |
class Trainer():
def __init__(self, logger, config):
if torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')
self.logger = logger
self.train_config = registry.instantiate(TrainConfig, config['train'])
self.data... |
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--logdir', required=True)
parser.add_argument('--config', required=True)
parser.add_argument('--config-args')
args = parser.parse_args()
if args.config_args:
config = json.loads(_jsonnet.evaluate_file(args.config, tla_... |
def TreeRep(d):
'\n This is a python wrapper to the TreeRep algorithm written in Julia.\n \n Input:\n d - Distance matrix, assumed to be symmetric with 0 on the diagonal\n\n Output:\n W - Adjacenct matrix of the tree. Note that W may have rows/cols full of zeros, and they should be ignored.\n\n\... |
def TreeRep_no_recursion(d):
'\n This is a python wrapper to the TreeRep algorithm written in Julia.\n \n Input:\n d - Distance matrix, assumed to be symmetric with 0 on the diagonal\n Output:\n W - Adjacenct matrix of the tree. Note that W may have rows/cols full of zeros, and they should be ig... |
class BatchCoCaBO(CoCaBO_Base):
def __init__(self, objfn, initN, bounds, acq_type, C, **kwargs):
super(BatchCoCaBO, self).__init__(objfn, initN, bounds, acq_type, C, **kwargs)
self.best_val_list = []
self.C_list = self.C
self.name = 'BCoCaBO'
def runOptim(self, budget, seed, ... |
class CoCaBO(CoCaBO_Base):
def __init__(self, objfn, initN, bounds, acq_type, C, **kwargs):
super(CoCaBO, self).__init__(objfn, initN, bounds, acq_type, C, **kwargs)
self.best_val_list = []
self.C_list = self.C
self.name = 'CoCaBO'
def runOptim(self, budget, seed, batch_size=... |
def CoCaBO_Exps(obj_func, budget, initN=24, trials=40, kernel_mix=0.5, batch=None):
saving_path = f'data/syntheticFns/{obj_func}/'
if (not os.path.exists(saving_path)):
os.makedirs(saving_path)
if (obj_func == 'func2C'):
f = testFunctions.syntheticFunctions.func2C
categories = [3, ... |
def DepRound(weights_p, k=1, isWeights=True):
' [[Algorithms for adversarial bandit problems with multiple plays, by T.Uchiya, A.Nakamura and M.Kudo, 2010](http://hdl.handle.net/2115/47057)] Figure 5 (page 15) is a very clean presentation of the algorithm.\n\n - Inputs: :math:`k < K` and weights_p :math:`= (p_... |
class AcquisitionFunction(object):
'\n Base class for acquisition functions. Used to define the interface\n '
def __init__(self, surrogate=None, verbose=False):
self.surrogate = surrogate
self.verbose = verbose
def evaluate(self, x: np.ndarray, **kwargs) -> np.ndarray:
rais... |
class AcquisitionOnSubspace():
def __init__(self, acq, free_idx, fixed_vals):
self.acq = acq
self.free_idx = free_idx
self.fixed_vals = fixed_vals
def evaluate(self, x: np.ndarray, **kwargs):
x_fixed = ([self.fixed_vals] * len(x))
x_complete = np.hstack((np.vstack(x_f... |
class EI(AcquisitionFunction):
'\n Expected improvement acquisition function for a Gaussian model\n\n Model should return (mu, var)\n '
def __init__(self, surrogate: GP, best: np.ndarray, verbose=False):
self.best = best
super().__init__(surrogate, verbose)
def __str__(self) -> ... |
class PI(AcquisitionFunction):
'\n Probability of improvement acquisition function for a Gaussian model\n\n Model should return (mu, var)\n '
def __init__(self, surrogate: GP, best: np.ndarray, tradeoff: float, verbose=False):
self.best = best
self.tradeoff = tradeoff
super()... |
class UCB(AcquisitionFunction):
'\n Upper confidence bound acquisition function for a Gaussian model\n\n Model should return (mu, var)\n '
def __init__(self, surrogate: GP, tradeoff: float, verbose=False):
self.tradeoff = tradeoff
super().__init__(surrogate, verbose)
def __str__... |
class AsyncBayesianOptimization(BayesianOptimisation):
"Async Bayesian optimization class\n\n Performs Bayesian optimization with a set number of busy and free workers\n\n Parameters\n ----------\n sampler : Callable\n function handle returning sample from expensive function being\n opti... |
class AsyncBOHeuristicQEI(AsyncBayesianOptimization):
"Async BO with approximate q-EI\n\n Q-EI is approximated by sequentially finding the best location and\n setting its y-value using one of Ginsbourger's heuristics until the\n batch is full\n "
def __init__(self, sampler, surrogate, bounds, asy... |
class BatchBOHeuristic(AsyncBOHeuristicQEI):
pass
|
class ExecutorBase():
'Base interface for interaction with multiple parallel workers\n\n The simulator and real async interfaces will subclass this class so that\n their interfaces are the same\n\n Main way to interact with this object is to queue jobs using\n add_job_to_queue(), to wait until the des... |
class JobExecutor(ExecutorBase):
"Async controller that interacts with external async function calls\n\n Will be used to run ML algorithms in parallel for synch and async BO\n\n Functions that run must take in a job dict and return the same\n job dict with the result ['y'] and runtime ['t'].\n "
... |
class JobExecutorInSeries(JobExecutor):
'Interface that runs the jobs in series\n but acts like a batch-running interface to the outside.\n\n self._futures is not a list of futures any more. This is a placeholder\n for the jobs that have yet to run to complete the batch\n '
def __init__(self, n_w... |
class JobExecutorInSeriesBlocking(ExecutorBase):
"Interface that runs the jobs in series and blocks execution of code\n until it's done\n "
def __init__(self, n_workers: int, verbose=False):
super().__init__(n_workers, verbose=verbose)
self._creation_time = time.time()
def run_unti... |
def add_hallucinations_to_x_and_y(bo, old_x, old_y, x_new, fixed_dim_vals=None) -> Tuple[(np.ndarray, np.ndarray)]:
'Add hallucinations to the data arrays.\n\n Parameters\n ----------\n old_x\n Current x values\n old_y\n Current y values\n x_new\n Locations at which to use the ... |
def make_hallucinated_data(bo, x: np.ndarray, strat: str) -> np.ndarray:
"Returns fake y-values based on the chosen heuristic\n\n Parameters\n ----------\n x\n Used to get the value for the kriging believer. Otherwise, this\n sets the number of values returned\n\n bo\n Instance of... |
def draw(weights):
choice = random.uniform(0, sum(weights))
choiceIndex = 0
for weight in weights:
choice -= weight
if (choice <= 0):
return choiceIndex
choiceIndex += 1
|
def distr(weights, gamma=0.0):
theSum = float(sum(weights))
return tuple(((((1.0 - gamma) * (w / theSum)) + (gamma / len(weights))) for w in weights))
|
def mean(aList):
theSum = 0
count = 0
for x in aList:
theSum += x
count += 1
return (0 if (count == 0) else (theSum / count))
|
def with_proba(epsilon):
'Bernoulli test, with probability :math:`\x0barepsilon`, return `True`, and with probability :math:`1 - \x0barepsilon`, return `False`.\n\n Example:\n\n >>> from random import seed; seed(0) # reproductible\n >>> with_proba(0.5)\n False\n >>> with_proba(0.9)\n True\n ... |
def log_string(out_str):
global LOG_FOUT
LOG_FOUT.write(out_str)
LOG_FOUT.flush()
|
def log_string(out_str):
global LOG_FOUT
LOG_FOUT.write(out_str)
LOG_FOUT.flush()
|
def build_shared_mlp(mlp_spec: List[int], bn: bool=True):
layers = []
for i in range(1, len(mlp_spec)):
layers.append(nn.Conv2d(mlp_spec[(i - 1)], mlp_spec[i], kernel_size=1, bias=(not bn)))
if bn:
layers.append(nn.BatchNorm2d(mlp_spec[i]))
layers.append(nn.ReLU(True))
... |
class _PointnetSAModuleBase(nn.Module):
def __init__(self):
super(_PointnetSAModuleBase, self).__init__()
self.npoint = None
self.groupers = None
self.mlps = None
def forward(self, xyz: torch.Tensor, features: Optional[torch.Tensor]) -> Tuple[(torch.Tensor, torch.Tensor)]:
... |
class PointnetSAModuleMSG(_PointnetSAModuleBase):
'Pointnet set abstrction layer with multiscale grouping\n\n Parameters\n ----------\n npoint : int\n Number of features\n radii : list of float32\n list of radii to group with\n nsamples : list of int32\n Number of samples in ea... |
class PointnetSAModule(PointnetSAModuleMSG):
'Pointnet set abstrction layer\n\n Parameters\n ----------\n npoint : int\n Number of features\n radius : float\n Radius of ball\n nsample : int\n Number of samples in the ball query\n mlp : list\n Spec of the pointnet befo... |
class PointnetFPModule(nn.Module):
'Propigates the features of one set to another\n\n Parameters\n ----------\n mlp : list\n Pointnet module parameters\n bn : bool\n Use batchnorm\n '
def __init__(self, mlp, bn=True):
super(PointnetFPModule, self).__init__()
self.... |
class FurthestPointSampling(Function):
@staticmethod
def forward(ctx, xyz, npoint):
'\n Uses iterative furthest point sampling to select a set of npoint features that have the largest\n minimum distance\n\n Parameters\n ----------\n xyz : torch.Tensor\n (... |
class GatherOperation(Function):
@staticmethod
def forward(ctx, features, idx):
'\n\n Parameters\n ----------\n features : torch.Tensor\n (B, C, N) tensor\n\n idx : torch.Tensor\n (B, npoint) tensor of the features to gather\n\n Returns\n ... |
class ThreeNN(Function):
@staticmethod
def forward(ctx, unknown, known):
'\n Find the three nearest neighbors of unknown in known\n Parameters\n ----------\n unknown : torch.Tensor\n (B, n, 3) tensor of known features\n known : torch.Tensor\n ... |
class ThreeInterpolate(Function):
@staticmethod
def forward(ctx, features, idx, weight):
'\n Performs weight linear interpolation on 3 features\n Parameters\n ----------\n features : torch.Tensor\n (B, c, m) Features descriptors to be interpolated from\n ... |
class GroupingOperation(Function):
@staticmethod
def forward(ctx, features, idx):
'\n\n Parameters\n ----------\n features : torch.Tensor\n (B, C, N) tensor of features to group\n idx : torch.Tensor\n (B, npoint, nsample) tensor containing the indicie... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.