This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credit 🙏: I just used the example from langchain docs and it works quite well: https://python.langchain.com/en/latest/use_cases/question_answering.html | |
# Note 2: The Arxiv -> PDF logic is a bit messy, I'm sure it can be done better | |
# Note 3: Please install the following: | |
# To run: | |
# Save this in a `app.py` | |
# pip install arxiv PyPDF2 langchain chromadb | |
# The chat feature was shipped in H2O nightly this week, we will need to install from nightly link: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from typing import Dict, Tuple, Optional, List | |
class SparseMatrix: | |
"""Sparse Matrix class | |
Args: | |
data: A dictionary of (i, j) -> value | |
""" | |
def __init__(self, data: Dict[Tuple[int, int], float] = None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras import backend as K | |
import tensorflow as tf | |
from tensorflow.keras import layers | |
from tensorflow.keras import models | |
import tensorflow as tf | |
from tensorflow.keras.regularizers import l1,l1_l2,l2 | |
from tensorflow.python.keras.regularizers import L1 | |
from rosbag2numpy.config import params | |
def euclidean_distance_loss(y_true, y_pred): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Copyright (c) 2019 Uber Technologies, Inc. | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
@tf.keras.utils.register_keras_serializable() | |
class CustomLayer(tf.keras.layers.Layer): | |
def __init__(self, k, **kwargs): | |
self.k = k | |
super(CustomLayer, self).__init__(**kwargs) | |
def get_config(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wandb | |
from wandb.keras import WandbCallback | |
import tensorflow as tf | |
class cd_wandb_custom(WandbCallback): | |
def __init__( | |
self, | |
# newly added | |
ds_test, | |
np_test_dataset:Dict[str,Union[ndarray,List]], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras import layers | |
from tensorflow.keras import models | |
import tensorflow as tf | |
class CustomMaskLayer(layers.Layer): | |
"""Layer that masks tensor at specific locations as mentioned in binary tensor | |
Args: | |
layers (layers.Layer): keras.layers baseclass | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
class CustomLayer(tf.keras.layers.Layer): | |
def __init__(self, k, name=None, **kwargs): | |
super(CustomLayer, self).__init__(name=name) | |
self.k = k | |
super(CustomLayer, self).__init__(**kwargs) | |
def get_config(self): | |
config = super(CustomLayer, self).get_config() |