svm_head
Bases: head
A support vector machine (SVM)-based head for implementing multi-channel modules.
This head supports linear, Gaussian RBF, and inverse quadratic RBF kernels, along with optional parameter reconciliation, residual connections, and output processing functions.
Attributes:
Name | Type | Description |
---|---|---|
m |
int
|
Input dimension of the head. |
n |
int
|
Output dimension of the head. |
kernel |
str
|
Type of kernel function ('linear', 'gaussian_rbf', 'inverse_quadratic_rbf'). |
channel_num |
int
|
Number of channels for multi-channel processing. |
parameters_init_method |
str
|
Initialization method for parameters. |
device |
str
|
Device to host the head (e.g., 'cpu' or 'cuda'). |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the SVM head with specified configurations. |
Source code in tinybig/head/basic_heads.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
__init__(m, n, name='svm_head', kernel='linear', base_range=(-1, 1), num_interval=10, epsilon=1.0, enable_bias=False, with_lorr=False, r=3, with_residual=False, channel_num=1, with_batch_norm=False, with_softmax=False, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initializes the SVM head.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
Input dimension. |
required |
n
|
int
|
Output dimension. |
required |
name
|
str
|
Name of the SVM head, default is 'svm_head'. |
'svm_head'
|
kernel
|
str
|
Type of kernel function ('linear', 'gaussian_rbf', 'inverse_quadratic_rbf'), default is 'linear'. |
'linear'
|
base_range
|
tuple
|
Range for Gaussian RBF kernels, default is (-1, 1). |
(-1, 1)
|
num_interval
|
int
|
Number of intervals for the kernel, default is 10. |
10
|
epsilon
|
float
|
Epsilon value for kernels, default is 1.0. |
1.0
|
enable_bias
|
bool
|
Whether to enable bias in reconciliation functions, default is False. |
False
|
with_lorr
|
bool
|
Whether to use LORR reconciliation, default is False. |
False
|
r
|
int
|
Parameter for reconciliation functions, default is 3. |
3
|
with_residual
|
bool
|
Whether to include a residual connection, default is False. |
False
|
channel_num
|
int
|
Number of channels, default is 1. |
1
|
with_batch_norm
|
bool
|
Whether to include batch normalization, default is False. |
False
|
with_softmax
|
bool
|
Whether to use softmax activation, default is False. |
False
|
parameters_init_method
|
str
|
Initialization method for parameters, default is 'xavier_normal'. |
'xavier_normal'
|
device
|
str
|
Device to host the head, default is 'cpu'. |
'cpu'
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in tinybig/head/basic_heads.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|