Skip to content

Instantly share code, notes, and snippets.

View crcrpar's full-sized avatar

Masaki Kozuki crcrpar

  • NVIDIA
  • Tokyo
  • 01:45 (UTC +09:00)
View GitHub Profile
optuna ❯ python optuna_create_trial.py
Optuna version: 2.3.0
[I 2020-12-20 16:15:44,324] A new study created in memory with name: no-name-e5c3d5a2-c5b0-43a6-91d0-d20150726e9d
optuna_create_trial.py:12: ExperimentalWarning: create_trial is experimental (supported from v2.0.0). The interface can change in the future.
trial: optuna.trial.FrozenTrial = optuna.trial.create_trial(value=-80, params={"x": -5})
Traceback (most recent call last):
File "optuna_create_trial.py", line 20, in <module>
main()
File "optuna_create_trial.py", line 12, in main
trial: optuna.trial.FrozenTrial = optuna.trial.create_trial(value=-80, params={"x": -5})
@crcrpar
crcrpar / README
Last active August 29, 2020 06:30
VSCode Dev Container Configuration for Optuna
If you want to use VSCode's fantastic feature: Dev Container, put the `devcontainer.json` in `.devcontainer` directory.
// ref: https://www.youtube.com/watch?v=VIz6xBvwYd8
#include <stdio.h>
#include <type_traits>
#include <memory>
template <typename Element>
struct tree_iterator {
tree_iterator& operator ++();
@crcrpar
crcrpar / uniform_initiralization.cc
Created August 1, 2020 15:36
Some epitome-ish code snippets from CppCon 2018: Nicolai Josuttis "The Nightmare of Initialization in C++"
// https://youtu.be/7DTlWPgX6zs
// x86-64 Clang 9
// opts: either `-std=c++17 --pedantic-errors` or `-std=c++14 --pedantic-errors`
#include <vector>
#include <string>
#include <atomic>
long long getLongInt();
struct C{};
// Type your code here, or load an example.
#include <string>
#include <map>
using namespace std;
// https://youtu.be/hEx5DNLWGgA?t=4261
void f(void) {
@crcrpar
crcrpar / baka_para.cpp
Last active July 11, 2020 05:23
OpenMP reduction with custom types
// ref: https://stackoverflow.com/a/39990387
#include <iostream>
#include <vector>
#include <omp.h>
struct Value {
Value(void) : x(-1) {}
Value(float x) : x(x) {}
float x;
Collecting pip
[?25l Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
[?25hInstalling collected packages: pip
Found existing installation: pip 19.3.1
Uninstalling pip-19.3.1:
Successfully uninstalled pip-19.3.1
Successfully installed pip-20.0.2
Obtaining file:///opt
Collecting alembic
import inspect
from typing import (Any, Callable, Tuple)
def str_func_name_args(
func: Callable[[Any], Any]
) -> Tuple[str, Callable[[Any], Any]]:
name = func.__name__
argspec = inspect.getfullargspec(func)
# Copied from https://blog.amedama.jp/entry/lightgbm-custom-metric (written in Japanese)
from lightgbm import callback
import lightgbm as lgb
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
def accuracy(preds, data):
y_true = data.get_label()
@crcrpar
crcrpar / Pipfile
Created January 25, 2020 09:09
Pipenv for TensorFlow==2.1.0 and Optuna master
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
tensorflow = "*"
optuna = {editable = true,git = "https://github.com/optuna/optuna.git"}