일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Torch
- 알고리즘
- nlp
- computervision
- SSL
- REACT
- nerf
- Front
- FGVC
- classification
- dl
- ML
- math
- Python
- cs
- clean code
- 자료구조
- pytorch
- Depth estimation
- Meta Learning
- 3d
- PRML
- 머신러닝
- algorithm
- FineGrained
- 딥러닝
- web
- GAN
- Vision
- CV
- Today
- Total
목록Python (20)
KalelPark's LAB

LangChain Expression Language (LCEL)- 라이브러리에서 제공하는 선언적 방식의 인터페이스로, 복잡한 LLM (Large Language Model) 애플리케이션을 구축하고 실행하기 위 한 도구. 쉽게 말하면, 각 구성 요소를 함수처럼 “파이프(|)”로 연결해 대화 흐름을 만들 수 있게 해주는 문법. - 목적은, 체인을 간결하게 표현하고, 동기/비동기 모두 지원하도록 설계한 것이다.from langchain_ollama import ChatOllamafrom langchain.prompts import PromptTemplatefrom langchain.schema.output_parser import StrOutputParser# 1. 프롬프트 템플릿 정의prompt =..

PromptTemplate 이란?- 언어 모델에 프롬프트를 생성하기 위한 사전 정의된 포맷이다. Template에는 instructions, few-shot 예제, 특정 컨텍스트와 질문등을 포함할 수 있습니다. - 다양한 것들을 활용하여, prompt template을 구축하는 것이 가능합니다.from langchain.prompts import PromptTemplatetemplate = "{task}을 수행하는 함수를 {language}으로 작성해 줘~"prompt_template = PromptTemplate.from_template(template)print(prompt_template) prompt = prompt_template.format(task="0부터 5까지 덧헴", languag..

Abstract 본 논문은 label 없이, model을 학습하는 Self-Supervised Learning을 분석합니다. 본 논문은 3가지 method를 비교합니다. (BiGAN, RotNet, DeepCluster). 데이터가 상당히 많더라도, Supervision과 같이 학습하는 것은 불가능합니다. 1) 본 논문은 초기 layer에서는 natural images의 통계에 대한 정보를 갖는 것이 힘들다는 것을 설명하고, 2) self-supervision에서는 그러한 표현력을 Self-supervision을 통해서, 학습될 수 있다고 설명합니다. 그리고, 대규모 데이터셋을 사용하는 것 대신 합성 변환을 활용하여, low-level statistics를 포착할 수 있습니다. Introduction 본..

import torch from PIL import Image import numpy as np from torchvision.transforms import transforms tf = transforms.ToPILImage() # Load image image = Image.open("/content/img.jpeg") image = np.array(image) tensor_image = torch.tensor(image) tensor_image = tensor_image.float() mask = torch.zeros_like(tensor_image) # Create binary mask mask[50:300, 200:300, :] = 1.0 # column, row mask[50:300, 420:..

Python에서의 일반적으로 자주 활용되는 메소드(Magic Method)인 __str__ 메서드와 __repr__ 메서드의 차이 두 메소드 간에는 미묘한 차이가 있습니다. 따라서 차이점을 명확하게 아는게 좋습니다. 공통점 - 두 메소드는 모두 "객체를 문자열로 반환"한다는 공통점이 존재 아래의 코드를 활용해보면 __repr__ 와 __str__이 겹친다는 것을 알 수 있습니다. import torch import torch.nn as nn class model(nn.Module): def __init__(self): super().__init__() self.linear1 = nn.Linear(10, 100) self.linear2 = nn.Linear(100, 100) self.linear3 = nn..

파이썬 프로그래밍의 상당 부분은 데이터를 포함하는 클래스를 정의하고, 클래스에 속하는 객체들이 서로 상호작용하는 방법을 기술하는 것으로 여겨집니다. 모든 파이썬 클래스는 함수와 attribute를 함께 캡슐화하는 일종의 컨테이너라고 할 수 있습니다. 파이썬은 데이터를 관리할 때 사용할 수 있도록, 리스트, 튜플, 집합, 딕셔너리 등에서 활용됩니다. * FrequencyList를 리스트(list)의 하위 클래스로 만듦으로써, 리스트가 제공하는 모든 표준 함수를 FrequencyList에서도 사용할 수 있습니다. class FrequencyList(list): def __init__(self, members): super().__init__(members) def frequency(self): counts ..

itertools 효율적인 루핑을 위한 이터레이터를 만드는 함수이다. 자체적으로 혹은 조합하여 유용하고 빠르고 메모리 효율적인 도구의 핵심 집합을 표준화합니다. 순수 파이썬에서 간결하고 효율적으로 특수화된 도구를 구성할 수 있도록 이터레이터 대수(iterator algebra)를 형성합니다. chain : 여러 iteration을 하나의 순차적인 이터레이터로 합칠 때 사용합니다. it = itertools.chain([1, 2, 3], [4, 5, 6]) for i in it: print(i) print(list(it)) repeat : 한 값을 게속 반복해 내놓고 싶을 때 사용합니다. it = itertools.repeat("안녕", 3) print(list(it)) cycle : 어떤 이터레이터가 원..

Dictionary - 일반적으로, Dictionary의 원소 삽입 순서와 iteration 순서는 일치하지 않는다. 이러한 일이 발생하는 이유는, Dictionary의 구현이 내장 hash와 난수 씨앗값(seed)을 사용하는 해시 테이블 알고리즘이기 때문이다. - 만약 dictionary를 순서에 의존하고 싶다면, 아래와 같은 명령어를 사용하면 됩니다. baby_names = { "cat" : "kitten", "dog" : "puppy" } print(baby_names.keys()) print(baby_names.values()) print(baby_names.items()) print(baby_names.popitem()) 기존 방법에서는, dictionary에서 값을 불러올 때, 순서대로 불러오..