id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
168,072
import os import boto3 from flask import Flask, jsonify, make_response, request dynamodb_client = boto3.client('dynamodb') USERS_TABLE = os.environ['USERS_TABLE'] def get_user(user_id): result = dynamodb_client.get_item( TableName=USERS_TABLE, Key={'userId': {'S': user_id}} ) item = result.get('Ite...
null
168,073
import os import boto3 from flask import Flask, jsonify, make_response, request dynamodb_client = boto3.client('dynamodb') USERS_TABLE = os.environ['USERS_TABLE'] def create_user(): user_id = request.json.get('userId') name = request.json.get('name') if not user_id or not name: return jsonify({'err...
null
168,074
import os import boto3 from flask import Flask, jsonify, make_response, request def resource_not_found(e): return make_response(jsonify(error='Not found!'), 404)
null
168,075
import os import boto3 dynamodb = boto3.resource('dynamodb') def delete(event, context): table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) # delete the todo from the database table.delete_item( Key={ 'id': event['pathParameters']['id'] } ) # create a response re...
null
168,076
import json import time import logging import os from todos import decimalencoder import boto3 dynamodb = boto3.resource('dynamodb') def update(event, context): data = json.loads(event['body']) if 'text' not in data or 'checked' not in data: logging.error("Validation Failed") raise Exception("C...
null
168,077
import os import json from todos import decimalencoder import boto3 dynamodb = boto3.resource('dynamodb') def get(event, context): table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) # fetch todo from the database result = table.get_item( Key={ 'id': event['pathParameters']['id'] ...
null
168,078
import json import logging import os import time import uuid import boto3 dynamodb = boto3.resource('dynamodb') def create(event, context): data = json.loads(event['body']) if 'text' not in data: logging.error("Validation Failed") raise Exception("Couldn't create the todo item.") times...
null
168,079
import json import os from todos import decimalencoder import boto3 dynamodb = boto3.resource('dynamodb') def list(event, context): table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) # fetch all todos from the database result = table.scan() # create a response response = { "statusCode":...
null
168,080
import json import telegram import os import logging logger = logging.getLogger() if logger.handlers: for handler in logger.handlers: logger.removeHandler(handler) OK_RESPONSE = { 'statusCode': 200, 'headers': {'Content-Type': 'application/json'}, 'body': json.dumps('ok') } ERROR_RESPONSE = { ...
Sets the Telegram bot webhook.
168,081
import json import sys from solidgpt.definitions import * def load_from_json(filename="data.json"): # Load data from a JSON file with open(filename, "r") as json_file: loaded_data = json.load(json_file) return loaded_data
null
168,082
import json import sys from solidgpt.definitions import * def create_directories_if_not_exist(filepath: str): dir_name = os.path.dirname(filepath) if not os.path.exists(dir_name): os.makedirs(dir_name) return def save_to_md(filename, content: str, path = "") -> str: create_directories_if_not_ex...
null
168,083
import json import sys from solidgpt.definitions import * def create_directories_if_not_exist(filepath: str): dir_name = os.path.dirname(filepath) if not os.path.exists(dir_name): os.makedirs(dir_name) return def add_extension_if_not_exist(input_string, extension): if not input_string.endswith(e...
null
168,084
import json import sys from solidgpt.definitions import * def create_directories_if_not_exist(filepath: str): dir_name = os.path.dirname(filepath) if not os.path.exists(dir_name): os.makedirs(dir_name) return def add_extension_if_not_exist(input_string, extension): if not input_string.endswith(e...
null
168,085
import json import sys from solidgpt.definitions import * def create_directories_if_not_exist(filepath: str): dir_name = os.path.dirname(filepath) if not os.path.exists(dir_name): os.makedirs(dir_name) return def add_extension_if_not_exist(input_string, extension): if not input_string.endswith(e...
null
168,086
import json import sys from solidgpt.definitions import * def add_extension_if_not_exist(input_string, extension): def load_from_text(filename, path = "", extension = ".md") -> str: full_path = os.path.join(path, filename) full_path = add_extension_if_not_exist(full_path, extension) with open(full_path, "r...
null
168,087
import json import sys from solidgpt.definitions import * def same_string(s1: str, s2: str, case_sensitive: bool = False): if case_sensitive: return s1 == s2 return s1.lower() == s2.lower()
null
168,088
import json import sys from solidgpt.definitions import * def print_error_message(message): print(f"Error: {message}", file=sys.stderr)
null
168,089
import json import sys from solidgpt.definitions import * def delete_directory_contents(directory): for root, dirs, files in os.walk(directory, topdown=False): for file in files: file_path = os.path.join(root, file) try: os.remove(file_path) print(f"D...
null
168,090
import os import re import sys import argparse import webbrowser from threading import Timer from websvc.app import app http_host = "0.0.0.0" http_port = 5000 def open_browser() -> None: webbrowser.open_new(f"http://{http_host}:{http_port}/")
null
168,091
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `update_button...
show/hide control buttons
168,092
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `btn_schedule_...
Add scanner/screen schedule
168,093
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `btn_buy_click...
Place a buy order
168,094
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `btn_sell_clic...
Place a sell order
168,095
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `btn_open_orde...
restart pairs with open orders
168,096
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper scan_layoutv2 = html.Div( [ dbc.Row( dbc.Col( html.Div( html.H5("Options", style={"textAlign": "center"}), ...
show scan options
168,097
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper The provided code snippet includes necessary dependencies for implementing the `toggle_options_collapse` function. Write a Python function `def toggle_options_collapse(n, is_ope...
toggle scan option collapsible
168,098
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def start_scan_and_bots(clicks): # pylint: disable=missing-function-docstring if clicks ...
null
168,099
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def start_scan_only(clicks): # pylint: disable=missing-function-docstring if clicks > 0:...
null
168,100
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def start_bots_only(clicks): # pylint: disable=missing-function-docstring if clicks > 0:...
null
168,101
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def btn_pause_click(click, market): # pylint: disable=missing-function-docstring if clic...
null
168,102
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def btn_resume_click(click, market): # pylint: disable=missing-function-docstring if cli...
null
168,103
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def btn_stop_click(click, market): # pylint: disable=missing-function-docstring if click...
null
168,104
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `btn_start_cli...
start bot manually
168,105
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() The provided code snippet includes necessary dependencies for implementing the `update_start_...
update manual start bot list
168,106
import dash_bootstrap_components as dbc from dash import dcc, html, Input, Output, State, MATCH, callback from models.telegram import Wrapper tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.clean_data_folder() def get_bot_status(pair): """ Get bot status for accordion heading """ if pair is not ...
create bot accordions
168,107
import os import dash_bootstrap_components as dbc from dash import dcc, html, callback, Output, Input def get_last_n_lines(file_name, N): """Get lines in file""" # Create an empty list to keep the track of last N lines list_of_lines = [] # Open file for reading in binary mode with open(file_name, "r...
read log file updated
168,108
import os import dash_bootstrap_components as dbc from dash import dcc, html, callback, Output, Input The provided code snippet includes necessary dependencies for implementing the `get_log_content` function. Write a Python function `def get_log_content(n)` to solve the following problem: read log files add names to d...
read log files add names to dropdown
168,109
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
Save changes
168,110
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
enable/disable buy size amount
168,111
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity The provided code snippet includes necessary dependencies for implementing the `buy_near_high_switch` function. Write a Python function `def buy...
enable/disable buy size amount
168,112
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity The provided code snippet includes necessary dependencies for implementing the `buy_size_switch` function. Write a Python function `def buy_size...
enable/disable buy size amount
168,113
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
enable/disable prevent loss settings
168,114
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity The provided code snippet includes necessary dependencies for implementing the `trailing_stop_loss_switch` function. Write a Python function `de...
enable/disable trailing stop loss settings
168,115
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
Select Exchange
168,116
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() def sellatloss(value): result = 0 margin = 0 if value ...
null
168,117
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() def buy_near_high(value): result = 0 if value is not None:...
null
168,118
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() def buy_max_size(value): result = 0 if value is not None: ...
null
168,119
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() def buy_min_size(value): result = 0 if value is not None: ...
null
168,120
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() class Granularity(Enum): ONE_MINUTE = 60, "1m", "1min", "1T" ...
read granularityfrom config
168,121
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
read trailingstoplosstrigger from config
168,122
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
read preventloss from config
168,123
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() The provided code snippet includes necessary dependencies for impl...
Make config changes
168,124
from dash import dcc, html, Input, Output, callback, State import dash_bootstrap_components as dbc from models.telegram import Wrapper from models.exchange import Granularity tg_wrapper = Wrapper("config.json", "webgui") tg_wrapper.helper.read_config() class Granularity(Enum): ONE_MINUTE = 60, "1m", "1min", "1T" ...
Set exchange granularity
168,125
import os import re import sys import argparse import webbrowser from threading import Timer from logsvc.app import app http_host = "0.0.0.0" http_port = 5000 def open_browser() -> None: webbrowser.open_new(f"http://{http_host}:{http_port}/")
null
168,126
import re import sys import datetime from models.Trading import TechnicalAnalysis from models.exchange.binance import PublicAPI as BPublicAPI from models.exchange.coinbase_pro import PublicAPI as CPublicAPI def header() -> str: return """ <!doctype html> <html lang="en"> <head> <!-- Required me...
null
168,127
import re import sys import datetime from models.Trading import TechnicalAnalysis from models.exchange.binance import PublicAPI as BPublicAPI from models.exchange.coinbase_pro import PublicAPI as CPublicAPI def footer() -> str: return """ </body> </html> """
null
168,128
import re import sys import datetime from models.Trading import TechnicalAnalysis from models.exchange.binance import PublicAPI as BPublicAPI from models.exchange.coinbase_pro import PublicAPI as CPublicAPI def is_binance_market_valid(market: str) -> bool: p = re.compile(r"^[A-Z0-9]{5,12}$") if p.match(market)...
null
168,129
import re import sys import datetime from models.Trading import TechnicalAnalysis from models.exchange.binance import PublicAPI as BPublicAPI from models.exchange.coinbase_pro import PublicAPI as CPublicAPI def is_coinbase_market_valid(market: str) -> bool: p = re.compile(r"^[0-9A-Z]{1,20}\-[1-9A-Z]{2,5}$") if...
null
168,130
import os import sys import time import signal from models.exchange.coinbase_pro import WebSocketClient as CWebSocketClient from models.exchange.Granularity import Granularity def cls(): os.system("cls" if os.name == "nt" else "clear")
null
168,131
import os import sys import time import signal from models.exchange.coinbase_pro import WebSocketClient as CWebSocketClient from models.exchange.Granularity import Granularity def handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,132
import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.dates as mdates from controllers.PyCryptoBot import PyCryptoBot from models.exchange.ExchangesEnum import Exchange from models.exchange.Granularity import Granularity from models.Trading import TechnicalAnalysis uppe...
null
168,133
import os import sys import time import signal from models.exchange.binance import WebSocketClient as BWebSocketClient from models.exchange.Granularity import Granularity def cls(): os.system("cls" if os.name == "nt" else "clear")
null
168,134
import os import sys import time import signal from models.exchange.binance import WebSocketClient as BWebSocketClient from models.exchange.Granularity import Granularity def signal_handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,135
import os import sys import time import signal from models.exchange.kucoin import WebSocketClient as KWebSocketClient from models.exchange.Granularity import Granularity def cls(): os.system("cls" if os.name == "nt" else "clear")
null
168,136
import os import sys import time import signal from models.exchange.kucoin import WebSocketClient as KWebSocketClient from models.exchange.Granularity import Granularity def signal_handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,138
import os import sys import time import signal from models.exchange.coinbase_pro import WebSocketClient as CWebSocketClient from models.exchange.Granularity import Granularity def signal_handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,139
import os import sys import time import signal from models.exchange.binance import WebSocketClient as BWebSocketClient def cls(): os.system("cls" if os.name == "nt" else "clear")
null
168,140
import os import sys import time import signal from models.exchange.binance import WebSocketClient as BWebSocketClient def handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,142
import os import sys import time import signal from models.exchange.kucoin import WebSocketClient as KWebSocketClient from models.exchange.Granularity import Granularity def handler(signum, frame): if signum == 2: print(" -> not finished yet!") return
null
168,143
import os import sys import time import json import random import sched import signal import functools import pandas as pd import numpy as np from regex import R from rich.console import Console from rich.table import Table from rich.text import Text from rich import box from datetime import datetime, timedelta from os...
null
168,144
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
page navigation
168,145
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
Update all data
168,146
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
Update graphs
168,147
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
Update Graphs
168,148
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
Active Margins Gauge
168,149
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
7 Day Total Margins Gauge
168,150
import json import os from datetime import datetime, timedelta import pandas as pd import dash_bootstrap_components as dbc import dash_daq as daq from dash import ( Dash, html, dcc, callback, clientside_callback, Input, Output, dash_table, ) from pages import controls, config, terminals,...
hides some columns based on screen width
168,151
import time import json import pandas as pd import re import sys from datetime import datetime from decimal import Decimal from itertools import islice from tradingview_ta import * from importlib.metadata import version from controllers.PyCryptoBot import PyCryptoBot from models.helper.TelegramBotHelper import Telegram...
null
168,152
import time import json import pandas as pd import re import sys from datetime import datetime from decimal import Decimal from itertools import islice from tradingview_ta import * from importlib.metadata import version from controllers.PyCryptoBot import PyCryptoBot from models.helper.TelegramBotHelper import Telegram...
null
168,153
import time import json import pandas as pd import re import sys from datetime import datetime from decimal import Decimal from itertools import islice from tradingview_ta import * from importlib.metadata import version from controllers.PyCryptoBot import PyCryptoBot from models.helper.TelegramBotHelper import Telegram...
Hit TradingView up for the goods so we don't waste unnecessary time/compute resources (brandon's top picks)
168,154
from stat import UF_APPEND from views.PyCryptoBot import RichText class RichText: def notify(_notification, app: object = None, level: str = "normal") -> None: # if notification is not a string, convert it to a string notification = "" if isinstance(_notification, str): notifica...
Calculate the margin for a given trade.
168,155
import ast import json import os.path import re import sys from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args from models.exchange.Granularity import Granularity def parse_market(market): def merge_config_and_args(exchange_config, args): def is_currency_valid(currency): def ...
null
168,156
import re from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args from models.helper.LogHelper import Logger def parser(app, logger_config): if not logger_config: raise Exception("There is an error in your config dictionary") if not app: raise Exception("No a...
null
168,157
import re from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args def parse_market(market): if not is_market_valid(market): raise ValueError(f'Dummy market invalid: {market}') base_currency, quote_currency = market.split('-', 2) return market, base_currency, quote_...
null
168,158
import ast import json import os.path import re import sys from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args from models.exchange.Granularity import Granularity def parse_market(market): if not is_market_valid(market): raise ValueError(f"Coinbase market invalid: {mar...
null
168,159
import ast import json import os.path import re import sys from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args def parse_market(market): base_currency = "BTC" quote_currency = "GBP" if not is_market_valid(market): raise ValueError(f"Binance market invalid: {mar...
null
168,160
import re import ast import json import os.path import sys from .default_parser import is_currency_valid, default_config_parse, merge_config_and_args from models.exchange.Granularity import Granularity def parse_market(market): if not is_market_valid(market): raise ValueError("Kucoin market invalid: " + mar...
null
168,161
import math from typing import Union def truncate(f: Union[int, float], n: Union[int, float]) -> str: """ Format a given number ``f`` with a given precision ``n``. """ if not isinstance(f, int) and not isinstance(f, float): return "0.0" if not isinstance(n, int) and not isinstance(n, float):...
Compare two values and print a message if they are not equal.
168,162
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os from disentanglement_lib.evaluation import evaluate from disentanglement_lib.evaluation.metrics import utils from disentanglement_lib.methods.unsupervised import train from disentanglement_lib.methods....
Example of a custom (dummy) metric. Preimplemented metrics can be found in disentanglement_lib.evaluation.metrics. Args: ground_truth_data: GroundTruthData to be sampled from. representation_function: Function that takes observations as input and outputs a dim_representation sized representation for each observation. r...
168,163
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os from disentanglement_lib.data.ground_truth import ground_truth_data from disentanglement_lib.data.ground_truth import util import numpy as np import PIL from six.moves import range from six.moves impor...
Loads several chunks of the small norb data set for final use.
168,164
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os from disentanglement_lib.data.ground_truth import ground_truth_data from disentanglement_lib.data.ground_truth import util import numpy as np import PIL import scipy.io as sio from six.moves import ran...
Parses a single source file and rescales contained images.
168,165
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import time from disentanglement_lib.data.ground_truth import named_data from disentanglement_lib.evaluation.metrics import beta_vae from disentanglement_lib.evaluation.metrics import dci from disent...
Validate a representation based on the provided gin configuration. This function will set the provided gin bindings, call the evaluate() function and clear the gin config. Please see the evaluate() for required gin bindings. Args: model_dir: String with path to directory where the representation is saved. output_dir: S...
168,166
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import time from disentanglement_lib.data.ground_truth import named_data from disentanglement_lib.methods.unsupervised import gaussian_encoder_model from disentanglement_lib.methods.weak import weak_va...
Trains a model based on the provided gin configuration. This function will set the provided gin bindings, call the train() function and clear the gin config. Please see the train() for required gin bindings. Args: model_dir: String with path to directory where model output should be saved. overwrite: Boolean indicating...
168,167
from __future__ import absolute_import from __future__ import division from __future__ import print_function from disentanglement_lib.methods.shared import losses from disentanglement_lib.methods.shared import optimizers from disentanglement_lib.methods.unsupervised import vae from six.moves import zip import tensorf...
Wrapper that creates weakly-supervised losses.
168,168
from __future__ import absolute_import from __future__ import division from __future__ import print_function from disentanglement_lib.methods.shared import losses from disentanglement_lib.methods.shared import optimizers from disentanglement_lib.methods.unsupervised import vae from six.moves import zip import tensorf...
Use labels to aggregate. Labels contains a one-hot encoding with a single 1 of a factor shared. We enforce which dimension of the latent code learn which factor (dimension 1 learns factor 1) and we enforce that each factor of variation is encoded in a single dimension. Args: z_mean: Mean of the encoder distribution for...
168,169
from __future__ import absolute_import from __future__ import division from __future__ import print_function from disentanglement_lib.methods.shared import losses from disentanglement_lib.methods.shared import optimizers from disentanglement_lib.methods.unsupervised import vae from six.moves import zip import tensorf...
Argmax aggregation with adaptive k. The bottom k dimensions in terms of distance are not averaged. K is estimated adaptively by binning the distance into two bins of equal width. Args: z_mean: Mean of the encoder distribution for the original image. z_logvar: Logvar of the encoder distribution for the original image. n...
168,170
from __future__ import absolute_import from __future__ import division from __future__ import print_function from disentanglement_lib.methods.shared import losses from disentanglement_lib.methods.shared import optimizers from disentanglement_lib.methods.unsupervised import vae from six.moves import zip import tensorf...
null
168,171
from __future__ import absolute_import from __future__ import division from __future__ import print_function from disentanglement_lib.methods.shared import losses from disentanglement_lib.methods.shared import optimizers from disentanglement_lib.methods.unsupervised import vae from six.moves import zip import tensorf...
Utility function to report tf.metrics in model functions.
168,172
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow.compat.v1 as tf import tensorflow_probability as tfp import gin.tf The provided code snippet includes necessary dependencies for implementing the `bernoulli_loss` function. ...
Computes the Bernoulli loss.
168,173
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow.compat.v1 as tf import tensorflow_probability as tfp import gin.tf The provided code snippet includes necessary dependencies for implementing the `make_reconstruction_loss` ...
Wrapper that creates reconstruction loss.