Skip to content

Instantly share code, notes, and snippets.

View redzhepdx's full-sized avatar
㊙️
Focusing

Redzhep Mehmedov Redzhebov redzhepdx

㊙️
Focusing
  • Otsala
  • Munich
View GitHub Profile
class ImbalancedDatasetSampler(torch.utils.data.sampler.Sampler):
"""Samples elements randomly from a given list of indices for imbalanced dataset
Arguments:
indices (list, optional): a list of indices
num_samples (int, optional): number of samples to draw
Source : https://github.com/ufoym/imbalanced-dataset-sampler [UPDATED for CustomDataset]
"""
def __init__(self, dataset: object, indices=None, num_samples=None) -> object:
from functools import partial
from typing import Optional
import torch
import torch.nn.functional as F
from torch.nn.modules.loss import _Loss
#: Loss binary mode suppose you are solving binary segmentation task.
#: That mean yor have only one class which pixels are labled as **1**,
#: the rest pixels are background and labeled as **0**.
#include <iostream>
#include <memory>
#include <exception>
#include <vector>
#include <climits>
#ifdef _MSC_VER
#define _NOEXCEPT noexcept
#else
#define _NOEXCEPT noexcept
@redzhepdx
redzhepdx / source.c
Created December 11, 2017 20:53
PolygonShapeCreationAlgorithm
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef struct point2D {
int x, y;
}point2D;
typedef struct line2D {
point2D *start;
@redzhepdx
redzhepdx / Solution.cpp
Created November 4, 2017 10:17
Hackerrank Stack Balanced Brackets Question Solution
#include <bits/stdc++.h>
using namespace std;
string isBalanced(string s) {
std::vector<char> stack;
bool flag = false;
for(int i = 0; (i < s.length()) && !flag; i++){
switch(s[i]){
@redzhepdx
redzhepdx / Solution.cpp
Last active November 6, 2017 20:44
Hackerrank Maximum Element Stack Question Solution with New Extended Stack Datastructure
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class max_stack {
public:
max_stack(void);
@redzhepdx
redzhepdx / Solution.cpp
Created October 20, 2017 00:34
Isomorphic Cycle Counter
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stdio.h>
std::vector<int> shift_array(std::string str) {
int len = str.length();
int i = 0, j = 1;
@redzhepdx
redzhepdx / Solution.cpp
Created October 10, 2017 21:57
Find the Running Median Hackerrank Question Solution
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
@redzhepdx
redzhepdx / configure.sh
Created July 22, 2017 09:09
AWS-CLİ SETUP SHELL
sudo -i
mkdir aws
cd aws
wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
aws configure set aws_access_key_id your_access_key
aws configure set aws_secret_access your_secret_access
echo "AWS-CLI Done"
@redzhepdx
redzhepdx / Trie.cpp
Created March 2, 2017 18:49
Trie Data Structure
#include "Trie.h"
Node::Node() {
this->ch = ' ';
this->isLeaf = false;
this->str = "";
this->children = std::vector<Node*>(ALPHABET_SIZE, NULL);
}
Node::~Node() {